-
Notifications
You must be signed in to change notification settings - Fork 2
209 lines (185 loc) · 8.92 KB
/
wheels-rapidgzip.yml
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
198
199
200
201
202
203
204
205
206
207
208
209
name: Build Wheels for rapidgzip
on:
push:
branches: 'master'
tags: 'rapidgzip-v*.*.*'
jobs:
Build-Wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14, windows-latest]
archs: [auto64]
# Build with both x86-64 (macos-13) and ARM64 (macos-14) runners.
# For some reason, macos-14-latest seems to use macos-14-arm64, but when I try to specify macos-14-arm64
# directly, then the actions does not find any runner to run on and macos-14 also uses arm64...
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
#
# manylinux1 is not supported anymore because it won't compile C++17 code
# manylinux2010 runs into this problem https://github.com/pypa/cibuildwheel/issues/1001
# MacOS and Windows ignore the manylinux-image version because they are not Linux.
include:
- os: ubuntu-latest
manylinux-image: manylinux2014
archs: auto64
- os: ubuntu-latest
manylinux-image: manylinux2014
archs: auto32
- os: ubuntu-latest
manylinux-image: manylinux_2_28
archs: auto64
env:
# By default, both build (https://pypi.org/project/build/)
# and cibuildwheel (https://pypi.org/project/cibuildwheel/) seem to try to compile for macOS 10.9
# based on the wheel output names in the logs. However, C++17 seems to have introduced some alignment
# for classes, which results in this error for the GzipReader class itself even without "alignas" being used:
# > error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)'
# > is only available on macOS 10.14 or newer
# See also this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=1274388
#
# In the end, 10.9 support should not be necessary anymore in almost 2023. Apple-support for that seems
# to have stopped 2016-12-01 (https://endoflife.date/macos) and even support for 10.14, which was introduced
# in 2019-09-24 has already stopped in 2021-10-25, so more than a year ago.
#
# Release | Release Date | End of Life
# -------------------------+---------------+-------------
# macOS 13 (Ventura) | 2022-10-24 | some time after 2022-11
# macOS 12 (Monterey) | 2021-10-25 | some time after 2022-11
# macOS 11 (Big Sur) | 2020-11-12 | some time after 2022-11
# macOS 10.15 (Catalina) | 2019-10-07 | 2022-09-12
# macOS 10.14 (Mojave) | 2018-09-24 | 2021-10-25
# macOS 10.13 (High Sierra)| 2017-09-25 | 2020-12-01
# macOS 10.12 (Sierra) | 2016-09-20 | 2019-10-01
# OS X 10.11 (El Capitan) | 2015-09-30 | 2018-12-01
# OS X 10.10 (Yosemite) | 2014-10-16 | 2017-08-01
# OS X 10.9 (Mavericks) | 2013-10-22 | 2016-12-01
MACOSX_DEPLOYMENT_TARGET: "10.14"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel build requests
- name: Install NASM (Windows)
if: matrix.os == 'windows-latest'
run: |
python3 .github/workflows/install-python-on-windows.py
echo "${PWD}/nasm" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build Tarball
working-directory: python/rapidgzip
run: python3 -m build --sdist
- name: Build Musllinux Wheels
if: matrix.os == 'ubuntu-latest'
env:
# The Musllinux containers are based on Alpine and therefore
# "apk add" needs to be used instead of "yum install".
# https://cibuildwheel.readthedocs.io/en/stable/options/
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux-image }}
CIBW_BEFORE_ALL_LINUX: "uname -a; apk add nasm"
CIBW_BUILD_VERBOSITY: 2
CIBW_BUILD: "*musllinux*"
run: python -m cibuildwheel --output-dir dist python/rapidgzip
- name: Build CPython Wheels
env:
# https://cibuildwheel.readthedocs.io/en/stable/options/
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux-image }}
CIBW_BEFORE_ALL_LINUX: "uname -a; yum install -y nasm"
CIBW_BEFORE_ALL_MACOS: |
brew install nasm;
export PATH="$PATH:/usr/local/bin"
CIBW_BUILD_VERBOSITY: 2
CIBW_SKIP: "*musllinux*"
run: python -m cibuildwheel --output-dir dist python/rapidgzip
- name: Check Wheels
run: twine check dist/* python/rapidgzip/dist/*
- name: Test Wheel
if: matrix.os == 'ubuntu-latest' && matrix.archs == 'auto64'
run: |
PYTHON_VERSION=$( python3 --version | sed -nr 's|.* (3)[.]([0-9]+)[.].*|\1\2|p' )
python -m pip install dist/*-cp${PYTHON_VERSION}-cp${PYTHON_VERSION}-manylinux*.whl
# Ensure that it is built with ISA-L
rapidgzip --oss-attributions | grep -i ISA-L
- name: Test Wheel (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
python -m pip install dist/*-cp310-win_amd64.whl
# Ensure that it is built with ISA-L
rapidgzip --oss-attributions | grep -i ISA-L
- uses: actions/upload-artifact@v4
with:
name: Linux x86-64 CPython Wheels
path: "dist/*-cp31*manylinux_2_28_x86_64.whl"
- name: Publish Tarball to PyPI
# Only one out of the OS matrix needs to upload the tarball.
if: startsWith(github.ref, 'refs/tags/') && matrix.manylinux-image == 'manylinux2014' && matrix.os == 'ubuntu-latest'
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_RAPIDGZIP }}
working-directory: python/rapidgzip
run: twine upload --skip-existing -u __token__ dist/*
- name: Publish Wheels to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_RAPIDGZIP }}
run: twine upload --skip-existing -u __token__ dist/*
Deploy-AUR:
if: startsWith(github.ref, 'refs/tags/')
needs: Build-Wheels
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Set Up Non-Root User # Because makepkg is an ass and forbids root from using it
run: |
groupadd sudo
useradd -m -G sudo user
echo '%sudo ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
- name: Install System Dependencies
run: |
pacman -Syu --noconfirm
pacman -Sy --noconfirm base-devel git python python-pip python-setuptools rhash openssh
- name: Clone Repository
env:
RAPIDGZIP_AUR_SSH: ${{ secrets.RAPIDGZIP_AUR_SSH }}
run: |
chmod a+rwx .
chown user .
su user -c 'mkdir -p "$HOME/.ssh/"'
su user -c 'echo "$RAPIDGZIP_AUR_SSH" > "$HOME/.ssh/aur"'
su user -c 'echo -e "Host aur.archlinux.org\n IdentityFile ~/.ssh/aur\n User mxmln\n StrictHostKeyChecking no" > "$HOME/.ssh/config"'
su user -c 'chmod 0600 "$HOME/.ssh/config" "$HOME/.ssh/aur"'
su user -c 'chmod 0700 "$HOME/.ssh/"'
su user -c 'git clone ssh://aur@aur.archlinux.org/python-rapidgzip.git .'
- name: Update PKGBUILD
run: |
# Annoyingly, --no-deps is not sufficient and building the wheels would still be triggered even
# just for downloading the source tarball! But, --no-build-isolation seems to avoid that:
# https://discuss.python.org/t/pip-download-just-the-source-packages-no-building-no-metadata-etc/4651/7
pip download --no-binary :all: --no-deps --no-build-isolation rapidgzip
pkgver=$( echo rapidgzip-*.tar.gz | sed -E 's|rapidgzip-([0-9.]*).*[.]tar.gz|\1|' )
blake2b=$( python3 -c 'import hashlib, sys; h=hashlib.blake2b(digest_size=256 // 8); h.update(open(sys.argv[1], "rb").read()); print(h.digest().hex())' rapidgzip-*.tar.gz )
# Update PKGBUILD
sed -i "s|pkgver=.*|pkgver=$pkgver|" PKGBUILD
sed -i "s|sha256sums=.*|sha256sums=('$( rhash -p"%x{sha-256}" rapidgzip-*.tar.gz )')|" PKGBUILD
sed -i -E "s|(.*pythonhosted.org/packages)/[0-9a-f]{2}/[0-9a-f]{2}/[0-9a-f]*/(.*)|\1/${blake2b:0:2}/${blake2b:2:2}/${blake2b:4}/\2|" PKGBUILD
su user -c 'makepkg --printsrcinfo > .SRCINFO'
su user -c 'git add -f PKGBUILD .SRCINFO'
su user -c 'git config --local user.email "mxmlnknp@gmail.com"'
su user -c 'git config --local user.name "Maximilian Knespel"'
su user -c "git commit -m 'Update to $pkgver'"
su user -c 'git show'
- name: Test PKGBUILD
run: |
su user -c 'makepkg -s --noconfirm'
su user -c 'makepkg --noconfirm --install python-rapidgzip-*.tar.zst'
- name: Push PKGBUILD
run: |
su user -c 'git push'