Skip to content

Commit

Permalink
Fixed bug in how Python executables are found.
Browse files Browse the repository at this point in the history
We can't rely on the `executable` field in `pyvenv.cfg`
becuase it refers to the base executable, not that in
the venv.
  • Loading branch information
abingham committed Oct 18, 2024
1 parent c6735db commit a730147
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/venv_management/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,10 @@ def python_executable_path(env_dirpath: Union[Path, str]) -> Path:
ValueError: If the env_dirpath is not a virtual environment.
"""
env_dirpath = Path(env_dirpath)
exe_filepath = pyvenv_config(env_dirpath, "executable")

if not exe_filepath:
exe_filepath = (
env_dirpath / "Scripts" / "python.exe"
if sys.platform == "win32" else
env_dirpath / "bin" / "python"
)
exe_filepath = Path(exe_filepath)
if sys.platform == 'win32':
exe_filepath = env_dirpath / "Scripts" / "python.exe"
else:
exe_filepath = env_dirpath / "bin" / "python"

if not exe_filepath.exists():
raise ValueError(
Expand Down

0 comments on commit a730147

Please sign in to comment.