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

env: fix global pip #746

Merged
merged 3 commits into from
Feb 29, 2024
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
10 changes: 7 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ Changelog
+++++++++


next release
============
1.1.1 (2024-02-29)
==================

- Fixed invoking outer pip from user site packages
(PR :pr:`746`, fixes issue :issue:`745`)
- Corrected the minimum pip version required to use an outer pip
(PR :pr:`746`, fixes issue :issue:`745`)

Python 3.7 (past EoL) support will be removed.

1.1.0 (2024-02-29)
==================
Expand Down
9 changes: 5 additions & 4 deletions src/build/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _minimum_pip_version() -> str:
return '19.1.0'


def _has_valid_pip(**distargs: object) -> bool:
def _has_valid_pip(__version: str | None = None, **distargs: object) -> bool:
"""
Given a path, see if Pip is present and return True if the version is
sufficient for build, False if it is not. ModuleNotFoundError is thrown if
Expand All @@ -90,7 +90,7 @@ def _has_valid_pip(**distargs: object) -> bool:

current_pip_version = packaging.version.Version(pip_distribution.version)

return current_pip_version >= packaging.version.Version(_minimum_pip_version())
return current_pip_version >= packaging.version.Version(__version or _minimum_pip_version())


@functools.lru_cache(maxsize=None)
Expand All @@ -101,7 +101,8 @@ def _valid_global_pip() -> bool | None:
"""

try:
return _has_valid_pip()
# Version to have added the `--python` option.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was a newer option but didn't see it from quick searches. Thanks!

return _has_valid_pip('22.3')
except ModuleNotFoundError:
return None

Expand Down Expand Up @@ -157,7 +158,7 @@ def python_executable(self) -> str:

def _pip_args(self) -> list[str]:
if _valid_global_pip():
return [sys.executable, '-Im', 'pip', '--python', self.python_executable]
return [sys.executable, '-m', 'pip', '--python', self.python_executable]
else:
return [self.python_executable, '-Im', 'pip']

Expand Down