(ns)
| 42 | |
| 43 | |
| 44 | def 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 |
no test coverage detected
searching dependent graphs…