MCPcopy Index your code
hub / github.com/RustPython/RustPython / _run_pip

Function _run_pip

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

Source from the content-addressed store, hash-verified

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

Callers 2

_bootstrapFunction · 0.85
_uninstall_helperFunction · 0.85

Calls 2

insertMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected