Skip to content

Commit

Permalink
Refactor misc.py (#1276)
Browse files Browse the repository at this point in the history
* Fix Vale

* Refactor and check for aisol path in install

* Check for existence of dpf/bin folder in AWP_ROOT location

* Test for dpf folder only starting with 231

* Revert Update docs/source/getting_started/index.rst

* Revert renaming

* Simplify modifications on load_api.py

* Revert changes to gate
  • Loading branch information
PProfizi committed Nov 27, 2023
1 parent 8048e2b commit de0a677
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions src/ansys/dpf/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,7 @@ def _pythonize_awp_version(version):


def _find_latest_ansys_versions():
if hasattr(load_api, "_find_latest_ansys_versions"):
return load_api._find_latest_ansys_versions()
awp_versions = [key[-3:] for key in os.environ.keys() if "AWP_ROOT" in key]
installed_packages_list = {}

for awp_version in awp_versions:
if not awp_version.isnumeric():
continue
ansys_path = os.environ.get("AWP_ROOT" + awp_version)
if ansys_path:
installed_packages_list[
packaging.version.parse(_pythonize_awp_version(awp_version))
] = ansys_path

installed_packages = pkg_resources.working_set
for i in installed_packages:
if "ansys-dpf-server" in i.key:
file_name = pkg_resources.to_filename(i.project_name.replace("ansys-dpf-", ""))
try:
module = importlib.import_module("ansys.dpf." + file_name)
installed_packages_list[
packaging.version.parse(module.__version__)
] = module.__path__[0]
except ModuleNotFoundError:
pass
except AttributeError:
pass
if len(installed_packages_list) > 0:
return installed_packages_list[sorted(installed_packages_list)[-1]]
return load_api._find_latest_ansys_versions()


def find_ansys():
Expand Down

0 comments on commit de0a677

Please sign in to comment.