Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor misc.py #1276

Merged
merged 9 commits into from
Nov 27, 2023
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()
rafacanton marked this conversation as resolved.
Show resolved Hide resolved


def find_ansys():
Expand Down
Loading