Skip to content

Commit f8e0a9d

Browse files
committed
fix(environment): update python executable lookup
This fix resolves a faulty path on MSYS2 MinGW CPython, where the bin/ segment is missing altogether. This is required by the uninstall routine. It also simplifies the lookup on all other platforms.
1 parent 3babe0a commit f8e0a9d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

pipenv/environment.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pipenv.utils.indexes import prepare_pip_source_args
2727
from pipenv.utils.processes import subprocess_run
2828
from pipenv.utils.shell import temp_environ
29+
from pipenv.utils.virtualenv import virtualenv_scripts_dir
2930
from pipenv.vendor.importlib_metadata.compat.py39 import normalized_name
3031
from pipenv.vendor.pythonfinder.utils import is_in_path
3132

@@ -248,14 +249,8 @@ def python(self) -> str:
248249
"""Path to the environment python"""
249250
if self._python is not None:
250251
return self._python
251-
if os.name == "nt" and not self.is_venv:
252-
py = Path(self.prefix).joinpath("python").absolute().as_posix()
253-
else:
254-
py = Path(self.script_basedir).joinpath("python").absolute().as_posix()
255-
if not py:
256-
py = Path(sys.executable).as_posix()
257-
self._python = py
258-
return py
252+
253+
return (virtualenv_scripts_dir(self.prefix) / "python").absolute().as_posix()
259254

260255
@cached_property
261256
def sys_path(self) -> list[str]:

0 commit comments

Comments
 (0)