Skip to content

Commit

Permalink
Fix support for pyenv-win(#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Nov 19, 2021
1 parent 2c43589 commit bf4ea7a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/745.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the python finder to support pyenv-win.
6 changes: 4 additions & 2 deletions pdm/project/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,12 @@ def find_interpreters(self, python_spec: str | None = None) -> Iterable[PythonIn
if not python_spec:
if config.get("python.use_pyenv", True) and PYENV_INSTALLED:
pyenv_shim = os.path.join(PYENV_ROOT, "shims", "python3")
if os.name == "nt":
pyenv_shim += ".bat"
if os.path.exists(pyenv_shim):
yield PythonInfo.from_path(pyenv_shim)
elif os.path.exists(pyenv_shim[:-1]):
yield PythonInfo.from_path(pyenv_shim[:-1])
elif os.path.exists(pyenv_shim.replace("python3", "python")):
yield PythonInfo.from_path(pyenv_shim.replace("python3", "python"))
if config.get("use_venv"):
python = get_in_project_venv_python(self.root)
if python:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def test_project_python_with_pyenv_support(project, mocker):
mocker.patch("pdm.project.core.PYENV_INSTALLED", True)
mocker.patch("pdm.project.core.PYENV_ROOT", str(project.root))
pyenv_python = project.root / "shims/python"
if os.name == "nt":
pyenv_python = pyenv_python.with_suffix(".bat")
pyenv_python.parent.mkdir()
pyenv_python.touch()
mocker.patch(
Expand Down

0 comments on commit bf4ea7a

Please sign in to comment.