Skip to content

Commit de923e6

Browse files
authored
Adding ansys student support (#1335)
* Adding ansys student to search * Adding SUPPORTED_ANSYS_VERSIONS * Replacing supported versions in more places. * Fixing coverage. * Update src/ansys/mapdl/core/launcher.py
1 parent 5e65ac1 commit de923e6

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

src/ansys/mapdl/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
2929

3030
from ansys.mapdl.core import examples
31+
from ansys.mapdl.core._version import SUPPORTED_ANSYS_VERSIONS
3132
from ansys.mapdl.core.convert import convert_apdl_block, convert_script
3233
from ansys.mapdl.core.launcher import (
3334
change_default_ansys_path,

src/ansys/mapdl/core/_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
# Read from the pyproject.toml
1717
# major, minor, patch
1818
__version__ = importlib_metadata.version("ansys-mapdl-core")
19+
20+
# In descending order
21+
SUPPORTED_ANSYS_VERSIONS = [222, 221, 212, 211, 202, 201, 195, 194, 193, 192, 191]

src/ansys/mapdl/core/launcher.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from ansys.mapdl import core as pymapdl
2424
from ansys.mapdl.core import LOG
25+
from ansys.mapdl.core._version import SUPPORTED_ANSYS_VERSIONS
2526
from ansys.mapdl.core.errors import LockFileException, MapdlDidNotStart, VersionError
2627
from ansys.mapdl.core.licensing import ALLOWABLE_LICENSES, LicenseChecker
2728
from ansys.mapdl.core.mapdl import _MapdlCore
@@ -637,8 +638,8 @@ def _get_available_base_ansys():
637638
211: '/usr/ansys_inc/v211'}
638639
"""
639640
base_path = None
640-
if os.name == "nt":
641-
supported_versions = [194, 202, 211, 212, 221]
641+
if os.name == "nt": # pragma: no cover
642+
supported_versions = SUPPORTED_ANSYS_VERSIONS
642643
awp_roots = {
643644
ver: os.environ.get(f"AWP_ROOT{ver}", "") for ver in supported_versions
644645
}
@@ -647,20 +648,32 @@ def _get_available_base_ansys():
647648
}
648649
if installed_versions:
649650
return installed_versions
650-
else:
651+
else: # pragma: no cover
652+
LOG.debug(
653+
"No installed ANSYS found using 'AWP_ROOT' environments. Let's suppose a base path."
654+
)
651655
base_path = os.path.join(os.environ["PROGRAMFILES"], "ANSYS INC")
656+
if not os.path.exists(base_path):
657+
LOG.debug(
658+
f"The supposed 'base_path'{base_path} does not exist. No available ansys found."
659+
)
660+
return {}
652661
elif os.name == "posix":
653662
for path in ["/usr/ansys_inc", "/ansys_inc"]:
654663
if os.path.isdir(path):
655664
base_path = path
656-
else:
665+
else: # pragma: no cover
657666
raise OSError(f"Unsupported OS {os.name}")
658667

659668
if base_path is None:
660669
return {}
661670

662671
paths = glob(os.path.join(base_path, "v*"))
663672

673+
# Testing for ANSYS STUDENT version
674+
if not paths: # pragma: no cover
675+
paths = glob(os.path.join(base_path, "ANSYS*"))
676+
664677
if not paths:
665678
return {}
666679

tests/conftest.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,11 @@ def pytest_configure(config):
5959

6060
# Check if MAPDL is installed
6161
# NOTE: checks in this order to get the newest installed version
62-
valid_rver = [
63-
"222",
64-
"221",
65-
"212",
66-
"211",
67-
"202",
68-
"201",
69-
"195",
70-
"194",
71-
"193",
72-
"192",
73-
"191",
74-
]
62+
63+
from ansys.mapdl.core._version import SUPPORTED_ANSYS_VERSIONS
64+
65+
valid_rver = [str(each) for each in SUPPORTED_ANSYS_VERSIONS]
66+
7567
EXEC_FILE = None
7668
for rver in valid_rver:
7769
if os.path.isfile(get_ansys_bin(rver)):

tests/test_pool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727

2828
TWAIT = 90
2929

30-
valid_rver = ["221", "212", "211", "202", "201", "195", "194", "193", "192", "191"]
30+
from ansys.mapdl.core._version import SUPPORTED_ANSYS_VERSIONS
31+
32+
valid_rver = [str(each) for each in SUPPORTED_ANSYS_VERSIONS]
33+
3134
EXEC_FILE = None
3235
for rver in valid_rver:
3336
if os.path.isfile(get_ansys_bin(rver)):

0 commit comments

Comments
 (0)