Skip to content

Commit

Permalink
env: fix global pip (#746)
Browse files Browse the repository at this point in the history
* Fix invoking outer pip from user site packages

* Specify minimum pip version required for outer pip

* Update changelog
  • Loading branch information
layday committed Feb 29, 2024
1 parent da06973 commit 9588222
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.rst
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
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.
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

0 comments on commit 9588222

Please sign in to comment.