From 4f983c4476251c83bc320ebaaff0cb9b71d2e981 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Thu, 6 May 2021 22:14:28 +0200 Subject: [PATCH] Handle standalone pip creation from pip wheel This change ensures that when pip is executed from a wheel/zip, standalone pip creation for build environment reuses the source. Resolves: #9953 Co-authored-by: Tzu-ping Chung --- news/9953.bugfix.rst | 1 + src/pip/_internal/build_env.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 news/9953.bugfix.rst diff --git a/news/9953.bugfix.rst b/news/9953.bugfix.rst new file mode 100644 index 00000000000..227f012b899 --- /dev/null +++ b/news/9953.bugfix.rst @@ -0,0 +1 @@ +Fix detection of existing standalone pip instance for PEP 517 builds. diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py index cdf04324107..680e49f5b38 100644 --- a/src/pip/_internal/build_env.py +++ b/src/pip/_internal/build_env.py @@ -50,9 +50,9 @@ 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 `source` is not a directory. We can't build + # a zip from this, and it likely means the instance is already standalone. + if not source.is_dir(): yield str(source) return