Skip to content

Commit 1799400

Browse files
Uv bugfix (#465)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 501021c commit 1799400

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/ansys/tools/installer/windows_functions.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,26 @@ def create_venv_windows(venv_dir: str, py_path: str):
4646
4747
"""
4848
user_profile = os.path.expanduser("~")
49-
scripts_path = os.path.join(py_path, "Scripts")
50-
new_path = f"{py_path};{scripts_path};%PATH%"
5149

5250
# Update the package managers
53-
subprocess.call(
54-
f'start /w /min cmd /K "set PATH={new_path} && python -m pip install --upgrade pip uv && exit"',
55-
shell=True,
56-
cwd=user_profile,
57-
)
58-
59-
# Create venv using uv
60-
subprocess.call(
61-
f'start /w /min cmd /K "set PATH={new_path} && python -m uv venv {venv_dir} && exit"',
62-
shell=True,
63-
cwd=user_profile,
64-
)
51+
try:
52+
# Update pip and uv using the py_path
53+
LOG.debug("Updating package managers - pip & uv...")
54+
subprocess.call(
55+
f'start /w /min cmd /K ""{py_path}\\python.exe" -m pip install --upgrade pip uv && exit"',
56+
shell=True,
57+
cwd=user_profile,
58+
)
59+
60+
# Create venv using uv
61+
LOG.debug("Creating virtual environment using uv...")
62+
subprocess.call(
63+
f'start /w /min cmd /K ""{py_path}\\python.exe" -m uv venv {venv_dir} && exit"',
64+
shell=True,
65+
cwd=user_profile,
66+
)
67+
except Exception as e:
68+
LOG.debug(f"Error creating virtual environment: {e}")
6569

6670

6771
def create_venv_windows_conda(venv_dir: str, py_path: str):

0 commit comments

Comments
 (0)