(args, additional_paths=None)
| 63 | |
| 64 | |
| 65 | def _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""" |
| 71 | import runpy |
| 72 | import sys |
| 73 | sys.path = {additional_paths or []} + sys.path |
| 74 | sys.argv[1:] = {args} |
| 75 | runpy.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 | |
| 91 | def version(): |
no test coverage detected
searching dependent graphs…