-
Notifications
You must be signed in to change notification settings - Fork 4
/
wheels.py
55 lines (42 loc) · 1.79 KB
/
wheels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-License-Identifier: BSD-2-Clause
# Taken and heavily adjusted from:
# https://github.com/meshy/pythonwheels/blob/fb1d09e6e2ae718db8f2379ecf854570ad86ebb9/utils.py
import json
import urllib.request
PYPI_URL = "https://pypi.org/pypi/{name}/json"
NEWEST_PYTHON_ABI_TAG = "cp313"
def get_top_360_packages():
print("Generating packages...")
with open("data/top-pypi-packages.json") as data_file:
packages = json.load(data_file)["rows"]
package_list = []
for package in packages[:360]:
package_list.append(package["project"])
return package_list
def find_wheels(packages):
results = []
for package in packages:
print(f"Fetching {package} data")
has_newest_wheel = False
try:
response = urllib.request.urlopen(PYPI_URL.format(name=package))
data = json.loads(response.read())
except urllib.error.HTTPError as e:
print(f"Failed to fetch '{package}': {e}")
results.append((package, has_newest_wheel))
continue
for download in data["urls"]:
if download["packagetype"] == "bdist_wheel":
abi_tag = download["filename"].split("-")[-2]
# wheel can be universal or compiled for the specific Python version
# there can be additional letters at the end of the abi tag
# e.g. "cp313t" built for free-threading
if abi_tag in ["none", "abi3"] or abi_tag.startswith(NEWEST_PYTHON_ABI_TAG):
has_newest_wheel = True
results.append((package, has_newest_wheel))
return results
def generate_wheel_readiness_data():
results = find_wheels(get_top_360_packages())
do_support = sum(result[1] for result in results)
print("Done")
return results, do_support