Skip to content

Commit e98bd66

Browse files
committed
optimize
1 parent 6f912c6 commit e98bd66

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

src/build.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import argparse
34
import subprocess
45
from config import *
@@ -45,10 +46,12 @@ def build(ver: str, py_path: str, plat: str = 'win', since: str = None, only: st
4546
if since:
4647
index = packages.index(since)
4748
if index > 0:
48-
packages = packages[index - 1:]
49+
packages = ['NotARealPackage'] * (index - 1) + packages[index - 1:]
4950

5051
pbar = tqdm(packages)
5152
for pkg in pbar:
53+
if pkg == 'NotARealPackage':
54+
continue
5255
pbar.set_description(f'S: {len(success)}, F: {len(failed)}, C: {pkg}')
5356
flags = ''
5457
if only:
@@ -59,9 +62,7 @@ def build(ver: str, py_path: str, plat: str = 'win', since: str = None, only: st
5962
f'--find-links https://pypy.kmtea.eu/wheels.html')
6063
try:
6164
result = subprocess.run(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
62-
if f'Successfully installed {pkg}' in (result.stdout.decode('utf-8') + result.stdout.decode('utf-8')):
63-
success.append(pkg)
64-
elif f'Requirement already satisfied: {pkg}' in (result.stdout.decode('utf-8') + result.stdout.decode('utf-8')):
65+
if ('error' not in result.stderr.decode('utf-8').lower()) or (f'Successfully installed {pkg}'.lower() in result.stdout.decode('utf-8').lower()):
6566
success.append(pkg)
6667
else:
6768
failed.append(pkg)
@@ -71,6 +72,12 @@ def build(ver: str, py_path: str, plat: str = 'win', since: str = None, only: st
7172
print('########## ERROR ##########')
7273
print(result.stderr.decode('utf-8'))
7374
print('########## END ##########')
75+
except KeyboardInterrupt:
76+
print('Exiting...')
77+
print(f'{success=}')
78+
print(f'{failed=}')
79+
print(f'{pkg=}')
80+
sys.exit(1)
7481
except Exception as e:
7582
failed.append(pkg)
7683
print(e)

src/build_linux.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def get_pypy(ver: str):
77
return f'/opt/python/pp{ver.replace(".", "")}-pypy{ver.replace(".", "")}_pp73/bin/python3'
88

99

10-
def build_linux(ver: str = None, since: str = None):
10+
def build_linux(ver: str = None, since: str = None, only: str = None):
1111
if not ver:
1212
ver = args.ver
1313
if ver not in build_versions:
@@ -21,12 +21,15 @@ def build_linux(ver: str = None, since: str = None):
2121
ver=ver,
2222
py_path=pypy_path,
2323
plat=plat,
24-
since=since
24+
since=since,
25+
only=only
2526
)
2627

2728

2829
if __name__ == '__main__':
2930
build_linux(
3031
ver=args.ver,
31-
since=args.since
32+
since=args.since,
33+
only=args.only
3234
)
35+

src/pick_uploads.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
if __name__ == '__main__':
1818
os.makedirs(TO_UPLOAD, exist_ok=True)
19+
os.makedirs(os.path.join(TO_UPLOAD, 'nomany'), exist_ok=True)
20+
for ver in VERS:
21+
os.makedirs(os.path.join(TO_UPLOAD, ver), exist_ok=True)
1922

2023
with open(CURRENT_INDEX, 'r', encoding='utf-8') as f:
2124
current_index = f.read()
@@ -40,15 +43,17 @@
4043
if pkg_name in ver_wheel and pkg_ver in ver_wheel and pkg_python in ver_wheel:
4144
if ver_wheel not in current_index:
4245
done = True
46+
shutil.move(
47+
os.path.join(LINUX_WHEELS_MANY_ORIGIN_DIR, wheel),
48+
os.path.join(TO_UPLOAD, ver, wheel)
49+
)
4350
break
4451
if not done:
4552
shutil.move(
4653
os.path.join(LINUX_WHEELS_MANY_ORIGIN_DIR, wheel),
47-
os.path.join(TO_UPLOAD, wheel)
54+
os.path.join(TO_UPLOAD, 'nomany', wheel)
4855
)
4956

50-
for ver in VERS:
51-
os.makedirs(os.path.join(TO_UPLOAD, ver), exist_ok=True)
5257
for wheel in tqdm(os.listdir(os.path.join(TO_UPLOAD, 'nomany'))):
5358
for ver in VERS:
5459
if f'pp{ver.replace(".", "")}-pypy{ver.replace(".", "")}' in wheel:

0 commit comments

Comments
 (0)