Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.5] fix check for in-project-venv #7985

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def get(self, reload: bool = False) -> Env:

if not in_venv or env is not None:
# Checking if a local virtualenv exists
if self.use_in_project_venv():
if self.in_project_venv_exists():
venv = self.in_project_venv

return VirtualEnv(venv)
Expand Down Expand Up @@ -736,7 +736,7 @@ def list(self, name: str | None = None) -> list[VirtualEnv]:
venv_path = self._poetry.config.virtualenvs_path
env_list = [VirtualEnv(p) for p in sorted(venv_path.glob(f"{venv_name}-py*"))]

if self.use_in_project_venv():
if self.in_project_venv_exists():
venv = self.in_project_venv
env_list.insert(0, VirtualEnv(venv))
return env_list
Expand Down Expand Up @@ -855,6 +855,14 @@ def use_in_project_venv(self) -> bool:
in_project: bool | None = self._poetry.config.get("virtualenvs.in-project")
if in_project is not None:
return in_project

return self.in_project_venv.is_dir()

def in_project_venv_exists(self) -> bool:
in_project: bool | None = self._poetry.config.get("virtualenvs.in-project")
if in_project is False:
return False

return self.in_project_venv.is_dir()

def create_venv(
Expand Down