MCPcopy Index your code
hub / github.com/python/cpython / _run_pip

Function _run_pip

Lib/ensurepip/__init__.py:65–88  ·  view source on GitHub ↗
(args, additional_paths=None)

Source from the content-addressed store, hash-verified

63
64
65def _run_pip(args, additional_paths=None):
66 # Run the bootstrapping in a subprocess to avoid leaking any state that happens
67 # after pip has executed. Particularly, this avoids the case when pip holds onto
68 # the files in *additional_paths*, preventing us to remove them at the end of the
69 # invocation.
70 code = f"""
71import runpy
72import sys
73sys.path = {additional_paths or []} + sys.path
74sys.argv[1:] = {args}
75runpy.run_module("pip", run_name="__main__", alter_sys=True)
76"""
77
78 cmd = [
79 sys.executable,
80 '-W',
81 'ignore::DeprecationWarning',
82 '-c',
83 code,
84 ]
85 if sys.flags.isolated:
86 # run code in isolated mode if currently running isolated
87 cmd.insert(1, '-I')
88 return subprocess.run(cmd, check=True).returncode
89
90
91def version():

Callers 2

_bootstrapFunction · 0.85
_uninstall_helperFunction · 0.85

Calls 2

insertMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…