Skip to content

Commit

Permalink
pythongh-90355: Add isolated flag if currently isolated (pythonGH-92857)
Browse files Browse the repository at this point in the history
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit c8556bc)

Co-authored-by: Carter Dodd <carter.dodd@gmail.com>
  • Loading branch information
kcdodd authored and miss-islington committed Jul 5, 2022
1 parent 7a3dae0 commit d4d80bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,18 @@ def _run_pip(args, additional_paths=None):
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():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`ensurepip` environment isolation for subprocess running ``pip``.

0 comments on commit d4d80bb

Please sign in to comment.