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

Handle locked pip version on Windows #6430

Merged
Merged
Show file tree
Hide file tree
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
24 changes: 4 additions & 20 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,10 @@ def get_marker_env(self) -> dict[str, Any]:
raise NotImplementedError()

def get_pip_command(self, embedded: bool = False) -> list[str]:
raise NotImplementedError()
if embedded or not Path(self._bin(self._pip_executable)).exists():
return [self.python, self.pip_embedded]
# run as module so that pip can update itself on Windows
return [self.python, "-m", "pip"]

def get_supported_tags(self) -> list[Tag]:
raise NotImplementedError()
Expand Down Expand Up @@ -1556,11 +1559,6 @@ def get_version_info(self) -> tuple[Any, ...]:
def get_python_implementation(self) -> str:
return platform.python_implementation()

def get_pip_command(self, embedded: bool = False) -> list[str]:
# If we're not in a venv, assume the interpreter we're running on
# has a pip and use that
return [sys.executable, self.pip_embedded if embedded else self.pip]

def get_paths(self) -> dict[str, str]:
# We can't use sysconfig.get_paths() because
# on some distributions it does not return the proper paths
Expand Down Expand Up @@ -1672,14 +1670,6 @@ def get_python_implementation(self) -> str:
implementation: str = self.marker_env["platform_python_implementation"]
return implementation

def get_pip_command(self, embedded: bool = False) -> list[str]:
# We're in a virtualenv that is known to be sane,
# so assume that we have a functional pip
return [
self._bin(self._executable),
self.pip_embedded if embedded else self.pip,
]

def get_supported_tags(self) -> list[Tag]:
output = self.run_python_script(GET_SYS_TAGS)
assert isinstance(output, str)
Expand Down Expand Up @@ -1858,12 +1848,6 @@ def __init__(
self._execute = execute
self.executed: list[list[str]] = []

def get_pip_command(self, embedded: bool = False) -> list[str]:
return [
self._bin(self._executable),
self.pip_embedded if embedded else self.pip,
]

def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
self.executed.append(cmd)

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ def test_build_environment_called_build_script_specified(
assert env == ephemeral_env
assert env.executed == [
[
"python",
sys.executable,
env.pip_embedded,
"install",
"--disable-pip-version-check",
Expand Down