Skip to content

Commit

Permalink
WIP: Fix pyenv local venv
Browse files Browse the repository at this point in the history
The virtualenvs.prefer-active-python flag is currently not
working for me; instead of selecting the local env, I get they
poetry venv.

This change resolves the problem for me.

FIXES: python-poetry#8119
  • Loading branch information
paultiplady committed Jun 21, 2023
1 parent fedff6d commit 5498f68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/poetry/utils/env/env_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ def get(self, reload: bool = False) -> Env:
prefer_active_python = self._poetry.config.get(
"virtualenvs.prefer-active-python"
)
if prefer_active_python:
executable = self._detect_active_python()
bin_dir = executable.parent
path = bin_dir.parent
return VirtualEnv(path, Path(executable.name))

python_minor = self.get_python_version(
precision=2, prefer_active_python=prefer_active_python, io=self._io
).to_string()
Expand Down

0 comments on commit 5498f68

Please sign in to comment.