Skip to content

Commit

Permalink
Improved how venv driver finds Python executables.
Browse files Browse the repository at this point in the history
The venv driver will now look on the system PATH for the Python
to use for creating new virtual environments.
abingham committed Mar 12, 2024
1 parent 791ab21 commit 0cecbdc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/venv_management/ext/drivers/venv/driver.py
Original file line number Diff line number Diff line change
@@ -53,7 +53,14 @@ def make_virtual_env(self, name, *, python=None, project_path=None, packages=Non
self._venvs_dirpath.mkdir(parents=True, exist_ok=True)

virtualenv_dirpath = self._venvs_dirpath / name
python_exe = Path(python or sys.executable)

if python:
python_exe = Path(python)
if not python_exe.is_file():
if (found := shutil.which(python)) is not None:
python_exe = Path(found)
else:
python_exe = Path(sys.executable)

if not python_exe.is_file():
raise PythonNotFound(f"Could not locate Python {python}")

0 comments on commit 0cecbdc

Please sign in to comment.