diff options
author | Łukasz Langa <lukasz@langa.pl> | 2022-07-05 16:07:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 16:07:36 (GMT) |
commit | f78733b332966cef7d0c61165389549f4ffe0727 (patch) | |
tree | 3da7e31b9690595654fdff08dcecc9398b024ac8 | |
parent | bd0f2a1955f99dc504d6c7bed495ec2a0ee74859 (diff) | |
download | cpython-f78733b332966cef7d0c61165389549f4ffe0727.zip cpython-f78733b332966cef7d0c61165389549f4ffe0727.tar.gz cpython-f78733b332966cef7d0c61165389549f4ffe0727.tar.bz2 |
[3.8] gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94571)
Co-authored-by: Carter Dodd <carter.dodd@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit c8556bcf6c0b05ac46bd74880626a2853e7c99a1)
-rw-r--r-- | Lib/ensurepip/__init__.py | 7 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index b291e9a..88ddc63 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -29,7 +29,12 @@ sys.path = {additional_paths or []} + sys.path sys.argv[1:] = {args} runpy.run_module("pip", run_name="__main__", alter_sys=True) """ - return subprocess.run([sys.executable, "-c", code], check=True).returncode + + cmd = [sys.executable, '-c', code] + if sys.flags.isolated: + # run code in isolated mode if currently running isolated + cmd.insert(1, '-I') + return subprocess.run(cmd, check=True).returncode def version(): diff --git a/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst b/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst new file mode 100644 index 0000000..7a3b2d5 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst @@ -0,0 +1 @@ +Fix :mod:`ensurepip` environment isolation for subprocess running ``pip``. |