Skip to content

Commit 9f50bae

Browse files
committed
Merge branch 'main' into release/0.2
2 parents 33e417b + caee5b5 commit 9f50bae

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ tests = [
4141
"packaging==23.1",
4242
"PyGithub==1.58.1",
4343
"appdirs==1.4.4",
44-
"requests==2.28.2",
44+
"requests==2.29.0",
4545
"PySide6==6.5.0",
4646
"pytest==7.3.1",
4747
"pytest-cov==4.0.0",
4848
"pytest-qt==4.2.0",
4949
]
5050
doc = [
51-
"Sphinx==6.2.0",
51+
"Sphinx==7.0.0",
5252
"ansys-sphinx-theme==0.9.8",
5353
"sphinx-copybutton==0.5.2",
5454
]
@@ -57,7 +57,7 @@ freeze = [
5757
"packaging==23.1",
5858
"PyGithub==1.58.1",
5959
"appdirs==1.4.4",
60-
"requests==2.28.2",
60+
"requests==2.29.0",
6161
"PySide6==6.5.0",
6262
]
6363

src/ansys/tools/installer/constants.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
LOG = logging.getLogger(__name__)
1010
LOG.setLevel("DEBUG")
1111

12-
1312
ABOUT_TEXT = f"""<h2>Ansys Python Installer {__version__}</h2>
1413
<p>Created by the PyAnsys Team.</p>
1514
<p>If you have any questions or issues, please open an issue in <a href='https://github.com/pyansys/python-installer-qt-gui/issues'>python-installer-qt-gui Issues</a> page.</p>
@@ -26,13 +25,16 @@
2625

2726
ANSYS_VENVS = ".ansys_python_venvs"
2827

28+
ANSYS_ENV_VAR_START = "awp_root"
29+
30+
ANSYS_SUPPORTED_PYTHON_VERSIONS = ["3_7", "3_10"]
31+
2932
INSTALL_TEXT = """Choose to use either the standard Python install from <a href='https://www.python.org/'>python.org</a> or <a href='https://github.com/conda-forge/miniforge'>miniforge</a>."""
3033

3134
PYTHON_VERSION_TEXT = """Choose the version of Python to install.
3235
3336
While choosing the latest version of Python is generally recommended, some third-party libraries and applications may not yet be fully compatible with the newest release. Therefore, it is recommended to try the second newest version, as it will still have most of the latest features and improvements while also having broader support among third-party packages."""
3437

35-
3638
PYTHON_VERSION_SELECTION_FOR_VENV = """Choose the version of Python to use for your virtual environment.
3739
3840
Please select the Python version from the table below to create its respective virtual environment."""
@@ -57,6 +59,7 @@
5759

5860

5961
ASSETS_PATH = os.path.join(THIS_PATH, "assets")
62+
6063
ANSYS_FAVICON = os.path.join(ASSETS_PATH, "ansys-favicon.png")
6164

6265
PYANSYS_DOCS_SITES = {

src/ansys/tools/installer/find_python.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
from pathlib import Path
66
import subprocess
77

8-
from ansys.tools.installer.constants import ANSYS_VENVS
8+
from ansys.tools.installer.constants import (
9+
ANSYS_ENV_VAR_START,
10+
ANSYS_SUPPORTED_PYTHON_VERSIONS,
11+
ANSYS_VENVS,
12+
)
913

1014
# only used on windows
1115
try:
@@ -100,30 +104,35 @@ def _find_installed_python_win(admin=False):
100104
return paths
101105

102106

103-
def _find_installed_python_win(admin=False):
104-
"""Check the windows registry for any installed instances of Python."""
105-
if admin:
106-
root_key = winreg.HKEY_LOCAL_MACHINE
107-
else:
108-
root_key = winreg.HKEY_CURRENT_USER
107+
def _find_installed_ansys_win():
108+
"""Check the environment variables for Ansys installations."""
109+
env_keys = []
110+
for key in os.environ.keys():
111+
if key.lower().startswith(ANSYS_ENV_VAR_START):
112+
env_keys.append(key)
113+
return env_keys
109114

110-
paths = {}
111-
try:
112-
base_key = "SOFTWARE\\Python\\PythonCore"
113-
with winreg.OpenKey(
114-
root_key,
115-
base_key,
116-
access=winreg.KEY_READ,
117-
) as reg_key:
118-
info = winreg.QueryInfoKey(reg_key)
119-
for i in range(info[0]):
120-
name = winreg.EnumKey(reg_key, i)
121-
ver, path = _get_python_info_win(f"{base_key}\\{name}", root_key)
122-
if ver is not None and path is not None:
123-
paths[path] = (ver, admin)
124115

125-
except FileNotFoundError:
126-
pass
116+
def _find_installed_ansys_python_win():
117+
"""Check the Ansys installation folder for installed Python."""
118+
installed_ansys = _find_installed_ansys_win()
119+
paths = {}
120+
for ansys_ver_env_key in installed_ansys:
121+
ansys_path = os.environ[ansys_ver_env_key]
122+
for ansys_py_ver in ANSYS_SUPPORTED_PYTHON_VERSIONS:
123+
path = os.path.join(
124+
ansys_path,
125+
f"commonfiles\\CPython\\{ansys_py_ver}\\winx64\\Release\\python",
126+
)
127+
if os.path.exists(path):
128+
version_output = subprocess.check_output(
129+
[f"{path}\\python.exe", "--version"], text=True
130+
).strip()
131+
try:
132+
version = version_output.split()[1]
133+
paths[path] = (version, False)
134+
except Exception:
135+
pass
127136

128137
return paths
129138

@@ -204,6 +213,7 @@ def find_all_python():
204213
if os.name == "nt":
205214
paths = _find_installed_python_win(True)
206215
paths.update(_find_installed_python_win(False))
216+
paths.update(_find_installed_ansys_python_win())
207217
else:
208218
paths = _find_installed_python_linux()
209219

0 commit comments

Comments
 (0)