|
2 | 2 | """ |
3 | 3 | Script to download all required wheels (including dependencies) of the ddtrace |
4 | 4 | Python package for relevant Python versions (+ abis), C library platforms and |
5 | | -architectures and merge them into a "megawheel" directory. |
| 5 | +architectures and unpack them into Python-specific site-packages directories. |
6 | 6 |
|
7 | | -This directory provides a portable installation of ddtrace which can be used |
8 | | -on multiple platforms and architectures. |
| 7 | +These site-package directories provide a portable installation of ddtrace which can be |
| 8 | +used on multiple platforms and architectures. |
9 | 9 |
|
10 | | -Currently the only OS supported is Linux. |
| 10 | +Currently, the only OS supported is Linux. |
11 | 11 |
|
12 | | -This script has been tested with 21.0.0 and is confirmed to not work with |
| 12 | +This script has been tested with pip 21.0.0 and is confirmed to not work with |
13 | 13 | 20.0.2. |
14 | 14 |
|
15 | 15 | Usage: |
16 | 16 | ./dl_wheels.py --help |
17 | 17 |
|
18 | | -
|
19 | | -The downloaded wheels can then be installed locally using: |
20 | | - pip install --no-index --find-links <dir_of_downloaded_wheels> ddtrace |
21 | 18 | """ |
22 | 19 | import argparse |
23 | 20 | import itertools |
| 21 | +import os |
24 | 22 | import subprocess |
25 | 23 | import sys |
26 | 24 |
|
|
73 | 71 | dl_dir = args.output_dir |
74 | 72 | print("saving wheels to %s" % dl_dir) |
75 | 73 |
|
76 | | -for python_version, arch, platform in itertools.product(args.python_version, args.arch, args.platform): |
77 | | - print("Downloading %s %s %s wheel" % (python_version, arch, platform)) |
78 | | - abi = "cp%s" % python_version.replace(".", "") |
79 | | - # Have to special-case these versions of Python for some reason. |
80 | | - if python_version in ["2.7", "3.5", "3.6", "3.7"]: |
81 | | - abi += "m" |
82 | | - |
83 | | - # See the docs for an explanation of all the options used: |
84 | | - # https://pip.pypa.io/en/stable/cli/pip_download/ |
85 | | - # only-binary=:all: is specified to ensure we get all the dependencies of ddtrace as well. |
86 | | - cmd = [ |
87 | | - sys.executable, |
88 | | - "-m", |
89 | | - "pip", |
90 | | - "download", |
91 | | - "ddtrace==%s" % args.ddtrace_version, |
92 | | - "--platform", |
93 | | - "%s_%s" % (platform, arch), |
94 | | - "--python-version", |
95 | | - python_version, |
96 | | - "--abi", |
97 | | - abi, |
98 | | - "--only-binary=:all:", |
99 | | - "--dest", |
100 | | - dl_dir, |
101 | | - ] |
102 | | - if args.verbose: |
103 | | - print(" ".join(cmd)) |
104 | | - |
105 | | - if not args.dry_run: |
106 | | - subprocess.run(cmd, capture_output=not args.verbose, check=True) |
| 74 | + |
| 75 | +for python_version, platform in itertools.product(args.python_version, args.platform): |
| 76 | + for arch in args.arch: |
| 77 | + print("Downloading %s %s %s wheel" % (python_version, arch, platform)) |
| 78 | + abi = "cp%s" % python_version.replace(".", "") |
| 79 | + # Have to special-case these versions of Python for some reason. |
| 80 | + if python_version in ["2.7", "3.5", "3.6", "3.7"]: |
| 81 | + abi += "m" |
| 82 | + |
| 83 | + # See the docs for an explanation of all the options used: |
| 84 | + # https://pip.pypa.io/en/stable/cli/pip_download/ |
| 85 | + # only-binary=:all: is specified to ensure we get all the dependencies of ddtrace as well. |
| 86 | + cmd = [ |
| 87 | + sys.executable, |
| 88 | + "-m", |
| 89 | + "pip", |
| 90 | + "download", |
| 91 | + "ddtrace==%s" % args.ddtrace_version, |
| 92 | + "--platform", |
| 93 | + "%s_%s" % (platform, arch), |
| 94 | + "--python-version", |
| 95 | + python_version, |
| 96 | + "--abi", |
| 97 | + abi, |
| 98 | + "--only-binary=:all:", |
| 99 | + "--dest", |
| 100 | + dl_dir, |
| 101 | + ] |
| 102 | + if args.verbose: |
| 103 | + print(" ".join(cmd)) |
| 104 | + |
| 105 | + if not args.dry_run: |
| 106 | + subprocess.run(cmd, capture_output=not args.verbose, check=True) |
| 107 | + |
| 108 | + wheel_files = [f for f in os.listdir(dl_dir) if f.endswith(".whl")] |
| 109 | + for whl in wheel_files: |
| 110 | + wheel_file = os.path.join(dl_dir, whl) |
| 111 | + print("Unpacking %s" % wheel_file) |
| 112 | + # -q for quieter output, else we get all the files being unzipped. |
| 113 | + subprocess.run( |
| 114 | + [ |
| 115 | + "unzip", |
| 116 | + "-q", |
| 117 | + "-o", |
| 118 | + wheel_file, |
| 119 | + "-d", |
| 120 | + os.path.join(dl_dir, "site-packages-ddtrace-py%s-%s" % (python_version, platform)), |
| 121 | + ] |
| 122 | + ) |
| 123 | + # Remove the wheel as it has been unpacked |
| 124 | + os.remove(wheel_file) |
0 commit comments