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

Function extract_pip_files

PC/layout/support/pip.py:44–93  ·  view source on GitHub ↗
(ns)

Source from the content-addressed store, hash-verified

42
43
44def extract_pip_files(ns):
45 dest = get_pip_dir(ns)
46 try:
47 dest.mkdir(parents=True, exist_ok=False)
48 except IOError:
49 return
50
51 src = ns.source / "Lib" / "ensurepip" / "_bundled"
52
53 ns.temp.mkdir(parents=True, exist_ok=True)
54 wheels = [shutil.copy(whl, ns.temp) for whl in src.glob("*.whl")]
55 search_path = os.pathsep.join(wheels)
56 if os.environ.get("PYTHONPATH"):
57 search_path += ";" + os.environ["PYTHONPATH"]
58
59 env = os.environ.copy()
60 env["PYTHONPATH"] = search_path
61
62 output = subprocess.check_output(
63 [
64 sys.executable,
65 "-m",
66 "pip",
67 "--no-color",
68 "install",
69 "pip",
70 "--upgrade",
71 "--target",
72 str(dest),
73 "--no-index",
74 "--no-compile",
75 "--no-cache-dir",
76 "-f",
77 str(src),
78 "--only-binary",
79 ":all:",
80 ],
81 env=env,
82 )
83
84 try:
85 shutil.rmtree(dest / "bin")
86 except OSError:
87 pass
88
89 for file in wheels:
90 try:
91 os.remove(file)
92 except OSError:
93 pass

Callers 1

generate_source_filesFunction · 0.85

Calls 9

get_pip_dirFunction · 0.85
strFunction · 0.85
mkdirMethod · 0.45
copyMethod · 0.45
globMethod · 0.45
joinMethod · 0.45
getMethod · 0.45
check_outputMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…