Skip to content

Commit

Permalink
Handle standalone pip creation from pip wheel
Browse files Browse the repository at this point in the history
This change ensures that when pip is executed from a wheel, standalone
pip creation for build environment reuses the wheel.

Resolves: pypa#9953
  • Loading branch information
abn committed May 6, 2021
1 parent e6414d6 commit 083e24e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/9953.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix PEP 517 builds when pip is executed from within a wheel.
10 changes: 7 additions & 3 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ def _create_standalone_pip() -> Iterator[str]:
"""
source = pathlib.Path(pip_location).resolve().parent

# Return the current instance if it is already a zip file. This can happen
# if a PEP 517 requirement is an sdist itself.
if not source.is_dir() and source.parent.name == "__env_pip__.zip":
# Return the current instance if it is already a zip or wheel file. This can happen
# if a PEP 517 requirement is an sdist itself or pip is being executed from within
# a wheel respectively.
if not source.is_dir() and (
source.parent.name == "__env_pip__.zip"
or source.parent.suffix == ".whl"
):
yield str(source)
return

Expand Down

0 comments on commit 083e24e

Please sign in to comment.