-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheck_release_assets.py
executable file
·197 lines (162 loc) · 5.83 KB
/
check_release_assets.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/usr/bin/env python
import argparse
import itertools
import os
import subprocess
import sys
import distlib.locators
CP36 = 'cp36-cp36m'
CP37 = 'cp37-cp37m'
CP38 = 'cp38-cp38'
CP39 = 'cp39-cp39'
CP310 = 'cp310-cp310'
CP311 = 'cp311-cp311'
CP312 = 'cp312-cp312'
LINUX = 'manylinux2014_x86_64'
LINUX_V11 = 'manylinux1_x86_64'
LINUX_AARCH64 = 'manylinux2014_aarch64'
WINDOWS = 'win_amd64'
sdist_project = 'cupy'
_v13_cuda_matrix = list(itertools.product(
(CP39, CP310, CP311, CP312), (LINUX, WINDOWS)))
_v13_aarch64_matrix = list(itertools.product(
(CP39, CP310, CP311, CP312), (LINUX_AARCH64,)))
_v13_rocm_matrix = list(itertools.product(
(CP39, CP310, CP311, CP312), (LINUX,)))
_v12_cuda_matrix = list(itertools.product(
(CP38, CP39, CP310, CP311, CP312), (LINUX, WINDOWS)))
_v12_aarch64_matrix = list(itertools.product(
(CP38, CP39, CP310, CP311, CP312), (LINUX_AARCH64,)))
_v12_rocm_matrix = list(itertools.product(
(CP38, CP39, CP310, CP311, CP312), (LINUX,)))
pypi_wheel_projects = {
# v13.x
'13': [
('cupy-cuda11x', _v13_cuda_matrix + _v13_aarch64_matrix),
('cupy-cuda12x', _v13_cuda_matrix + _v13_aarch64_matrix),
('cupy-rocm-4-3', _v13_rocm_matrix),
('cupy-rocm-5-0', _v13_rocm_matrix),
],
# v12.x
'12': [
('cupy-cuda102', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-cuda110', _v12_cuda_matrix),
('cupy-cuda111', _v12_cuda_matrix),
('cupy-cuda11x', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-cuda12x', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-rocm-4-3', _v12_rocm_matrix),
('cupy-rocm-5-0', _v12_rocm_matrix),
],
}
github_wheel_projects = {
# v13.x
'13': [
('cupy-cuda11x', _v13_cuda_matrix + _v13_aarch64_matrix),
('cupy-cuda12x', _v13_cuda_matrix + _v13_aarch64_matrix),
('cupy-rocm-4-3', _v13_rocm_matrix),
('cupy-rocm-5-0', _v13_rocm_matrix),
],
# v12.x
'12': [
('cupy-cuda102', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-cuda110', _v12_cuda_matrix),
('cupy-cuda111', _v12_cuda_matrix),
('cupy-cuda11x', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-cuda12x', _v12_cuda_matrix + _v12_aarch64_matrix),
('cupy-rocm-4-3', _v12_rocm_matrix),
('cupy-rocm-5-0', _v12_rocm_matrix),
],
}
def get_basenames(project, version):
# List all wheels including unsupported ones by the current Python
distlib.locators.is_compatible = lambda *args: True
locator = distlib.locators.SimpleScrapingLocator(
'https://pypi.org/simple/')
proj = locator.get_project(project)['urls']
if version not in proj:
return []
return [os.path.basename(url) for url in proj[version]]
def get_basenames_github(version):
return subprocess.check_output([
'gh', 'release', '--repo', 'cupy/cupy',
'view', f'v{version}',
'--json', 'assets',
'--jq', '.assets[].name']).decode().splitlines()
def get_expected_sdist_basename(project, version):
return '{project}-{version}.tar.gz'.format(
project=project,
version=version,
)
def get_expected_wheel_basename(project, version, abi, arch):
return '{project}-{version}-{abi}-{arch}.whl'.format(
project=project.replace('-', '_'),
version=version,
abi=abi,
arch=arch,
)
def verify(project, expected, actual) -> bool:
print('🔵 Project: {}'.format(project))
expected = set(expected)
actual = set(actual)
error = False
for project in sorted(expected - actual):
error = True
print(' ❓ Missing: {}'.format(project))
for project in sorted(actual - expected):
error = True
print(' ⚠️ Unexpected: {}'.format(project))
for project in sorted(actual & expected):
print(' 👀 Found: {}'.format(project))
if error:
print(' ❌ Check Fail')
else:
print(' ✅ Check Pass')
print()
return not error
def get_expected_wheels(wheel_projects, version):
branch = str(version.split('.')[0])
return {
project: [
get_expected_wheel_basename(project, version, cpython, arch)
for (cpython, arch) in matrix
]
for (project, matrix) in wheel_projects[branch]
}
def parse_args(argv) -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('--version')
parser.add_argument('--github', action='store_true', default=False)
parser.add_argument('--pypi-sdist', action='store_true', default=False)
parser.add_argument('--pypi-wheel', action='store_true', default=False)
return parser.parse_args(argv[1:])
def main(argv):
options = parse_args(argv)
version = options.version
if version.startswith('v'):
version = version[1:]
branch = str(version.split('.')[0])
success = True
# Verify assets on GitHub release
if options.github:
expected = (
list(itertools.chain(*get_expected_wheels(
github_wheel_projects, version).values())) +
[get_expected_sdist_basename(sdist_project, version)])
success = verify(
'GitHub Release',
expected,
get_basenames_github(version)) and success
if options.pypi_sdist:
expected = [get_expected_sdist_basename(sdist_project, version)]
actual = get_basenames(sdist_project, version)
success = verify(sdist_project, expected, actual) and success
if options.pypi_wheel:
expected = get_expected_wheels(pypi_wheel_projects, version)
for project, _ in pypi_wheel_projects[branch]:
actual = get_basenames(project, version)
success = verify(project, expected[project], actual) and success
if not success:
return 1
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))