Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GitHub Actions for CI #706

Merged
merged 18 commits into from
Nov 19, 2024
Merged
Prev Previous commit
Next Next commit
Merge wheels
  • Loading branch information
t-sommer committed Nov 19, 2024
commit c124c258f4ca4d94a99e014137e0695544c9dda9
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,29 @@ jobs:
name: ${{ matrix.name }}
path: dist
if-no-files-found: error
merge-wheels:
runs-on: ubuntu-22.04
needs: [build]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: linux
path: wheels/linux
- uses: actions/download-artifact@v4
with:
name: darwin
path: wheels/darwin
- uses: actions/download-artifact@v4
with:
name: windows
path: wheels/windows
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: python merge_wheels.py
- uses: actions/upload-artifact@v4
with:
name: merged
path: wheels/merged
if-no-files-found: error
20 changes: 10 additions & 10 deletions merge_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from shutil import make_archive, unpack_archive

root = Path(__file__).parent
merge = root / 'merge'
merged = root / 'merged'
temp = root / 'wheels' / 'temp'
merged = root / 'wheels' / 'merged'


if merge.exists():
shutil.rmtree(merge)
if temp.exists():
shutil.rmtree(temp)

os.makedirs(merge)
os.makedirs(temp)

if merged.exists():
shutil.rmtree(merged)
Expand All @@ -21,7 +21,7 @@

wheels = []

for dirpath, dirnames, filenames in os.walk(root):
for dirpath, _, filenames in os.walk(root / 'wheels'):
for filename in filenames:
if filename.endswith('.whl'):
wheels.append(root / dirpath / filename)
Expand All @@ -35,15 +35,15 @@
record = info.filename
break
records.update(archive.read(record).split(b'\n'))
archive.extractall(merge)
archive.extractall(temp)

unpack_archive(wheel, merge, 'zip')
unpack_archive(wheel, temp, 'zip')

with open(merge / record, 'w') as record:
with open(temp / record, 'w') as record:
lines = [line.decode('utf-8') for line in records]
lines.sort()
lines = list(filter(lambda line: line != "", lines))
record.writelines('\n'.join(lines))

make_archive(str(merged / wheels[0].stem), 'zip', merge)
make_archive(str(merged / wheels[0].stem), 'zip', temp)
os.rename(merged / (wheels[0].stem + '.zip'), merged / wheels[0].name)