gh-90355: Add isolated flag if currently isolated (GH-92857)

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
Carter Dodd 2022-07-05 10:23:44 -05:00 committed by GitHub
parent 067597522a
commit c8556bcf6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -89,8 +89,18 @@ 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, '-W', 'ignore::DeprecationWarning',
"-c", code], check=True).returncode
cmd = [
sys.executable,
'-W',
'ignore::DeprecationWarning',
'-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``.