File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11"""Module for launching MAPDL locally."""
2+ import pathlib
3+ from glob import glob
24import time
35import subprocess
46import re
@@ -58,6 +60,20 @@ def find_ansys():
5860 if is_float (version_str ):
5961 paths [int (version_str )] = path
6062
63+ # On Linux ansys is usually installed at the root directory at
64+ # /usr/ansys_inc
65+ # /ansys_inc
66+ if not paths and os .name == 'posix' :
67+ for directory in ['/usr/ansys_inc/' , '/ansys_inc/' ]:
68+ if os .path .isdir (directory ):
69+ # construct ansys path
70+ for subdirectory in glob ('%s*/' % directory ):
71+ ver = os .path .basename (os .path .normpath ('/usr/ansys_inc/v202/' ))
72+ groups = re .findall (r'v\d\d\d' , ver )
73+ if groups :
74+ ver = int (groups [0 ][1 :])
75+ paths [ver ] = os .path .join (subdirectory , 'ansys' )
76+
6177 if not paths :
6278 return '' , ''
6379
Original file line number Diff line number Diff line change 2929 pytestmark = pytest .mark .skip ("Requires MAPDL" )
3030
3131
32+ @pytest .mark .skipif (os .name != 'posix' , reason = "Requires Linux" )
33+ @pytest .mark .skipif (not versions , reason = "Requires ANSYS install" )
34+ def test_find_ansys_linux ():
35+ # assuming ansys is installed, should be able to find it on linux
36+ # without env var
37+ bin_file , ver = pyansys .launcher .find_ansys ()
38+ assert os .path .isfile (bin_file )
39+ assert isinstance (ver , float )
40+
41+
3242def test_invalid_mode ():
3343 with pytest .raises (ValueError ):
3444 exec_file = get_ansys_bin (valid_versions [0 ])
You can’t perform that action at this time.
0 commit comments