[3.9] gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94570)

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 c8556bcf6c)
This commit is contained in:
Łukasz Langa 2022-07-05 18:06:57 +02:00 committed by GitHub
parent 224cd0c3bf
commit eff4aa5409
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -31,7 +31,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():

View file

@ -0,0 +1 @@
Fix :mod:`ensurepip` environment isolation for subprocess running ``pip``.