summaryrefslogtreecommitdiffstats
path: root/PC/layout/support/pip.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2018-12-07 05:09:53 (GMT)
committerGitHub <noreply@github.com>2018-12-07 05:09:53 (GMT)
commit253209149389e6793a052034e1f2d97691086f18 (patch)
tree21ebd5df1c2ce59a2d71a5d28ea879be7ad835a4 /PC/layout/support/pip.py
parent72c71956cade606bd5500cf76d4d7c1d50a7ccae (diff)
downloadcpython-253209149389e6793a052034e1f2d97691086f18.zip
cpython-253209149389e6793a052034e1f2d97691086f18.tar.gz
cpython-253209149389e6793a052034e1f2d97691086f18.tar.bz2
[3.7] bpo-34977: Add Windows App Store package (GH-10245)
Diffstat (limited to 'PC/layout/support/pip.py')
-rw-r--r--PC/layout/support/pip.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/PC/layout/support/pip.py b/PC/layout/support/pip.py
new file mode 100644
index 0000000..369a923
--- /dev/null
+++ b/PC/layout/support/pip.py
@@ -0,0 +1,79 @@
+"""
+Extraction and file list generation for pip.
+"""
+
+__author__ = "Steve Dower <steve.dower@python.org>"
+__version__ = "3.8"
+
+
+import os
+import shutil
+import subprocess
+import sys
+
+__all__ = []
+
+
+def public(f):
+ __all__.append(f.__name__)
+ return f
+
+
+@public
+def get_pip_dir(ns):
+ if ns.copy:
+ if ns.zip_lib:
+ return ns.copy / "packages"
+ return ns.copy / "Lib" / "site-packages"
+ else:
+ return ns.temp / "packages"
+
+
+@public
+def extract_pip_files(ns):
+ dest = get_pip_dir(ns)
+ dest.mkdir(parents=True, exist_ok=True)
+
+ src = ns.source / "Lib" / "ensurepip" / "_bundled"
+
+ ns.temp.mkdir(parents=True, exist_ok=True)
+ wheels = [shutil.copy(whl, ns.temp) for whl in src.glob("*.whl")]
+ search_path = os.pathsep.join(wheels)
+ if os.environ.get("PYTHONPATH"):
+ search_path += ";" + os.environ["PYTHONPATH"]
+
+ env = os.environ.copy()
+ env["PYTHONPATH"] = search_path
+
+ output = subprocess.check_output(
+ [
+ sys.executable,
+ "-m",
+ "pip",
+ "--no-color",
+ "install",
+ "pip",
+ "setuptools",
+ "--upgrade",
+ "--target",
+ str(dest),
+ "--no-index",
+ "--no-cache-dir",
+ "-f",
+ str(src),
+ "--only-binary",
+ ":all:",
+ ],
+ env=env,
+ )
+
+ try:
+ shutil.rmtree(dest / "bin")
+ except OSError:
+ pass
+
+ for file in wheels:
+ try:
+ os.remove(file)
+ except OSError:
+ pass