forked from sqlalchemy/sqlalchemy
-
Notifications
You must be signed in to change notification settings - Fork 0
381 lines (337 loc) · 16.6 KB
/
create-wheels.yaml
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
name: Create wheel
on:
# run when a release has been created
release:
types: [created]
env:
# set this so the sqlalchemy test uses the installed version and not the local one
PYTHONNOUSERSITE: 1
# comment TWINE_REPOSITORY_URL to use the real pypi. NOTE: change also the secret used in TWINE_PASSWORD
# TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
jobs:
# two jobs are defined make-wheel-win-osx and make-wheel-linux.
# they do the the same steps, but linux wheels need to be build to target manylinux
make-wheel-win-osx:
name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "windows-latest"
- "macos-latest"
python-version:
- "2.7"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
architecture:
- x64
- x86
include:
- python-version: "2.7"
extra-requires: "mock"
exclude:
- os: "macos-latest"
architecture: x86
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Remove tag_build from setup.cfg
# sqlalchemy has `tag_build` set to `dev` in setup.cfg. We need to remove it before creating the weel
# otherwise it gets tagged with `dev0`
shell: pwsh
# This is equivalent to the sed commands:
# `sed -i '/tag_build=dev/d' setup.cfg`
# `sed -i '/tag_build = dev/d' setup.cfg`
# `-replace` uses a regexp match
# alternative form: `(get-content setup.cfg) | foreach-object{$_ -replace "tag_build.=.dev",""} | set-content setup.cfg`
run: |
(cat setup.cfg) | %{$_ -replace "tag_build.?=.?dev",""} | set-content setup.cfg
- name: Create wheel
# create the wheel using --no-use-pep517 since locally we have pyproject
# this flag should be removed once sqlalchemy supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
run: |
python -m pip install --upgrade pip
pip --version
pip install 'setuptools>=44' 'wheel>=0.34'
pip list
pip wheel -w dist --no-use-pep517 -v --no-deps .
- name: Install wheel
# install the created wheel without using the pypi index
run: |
pip install greenlet "importlib-metadata;python_version<'3.8'" &&
pip install -f dist --no-index sqlalchemy
- name: Check c extensions
# on windows in python 2.7 the cextension fail to build.
# for python 2.7 visual studio 9 is missing
if: matrix.os != 'windows-latest' || matrix.python-version != '2.7'
run: |
python -c 'from sqlalchemy.util import has_compiled_ext; assert has_compiled_ext()'
- name: Test created wheel
# the mock reconnect test seems to fail on the ci in windows
run: |
pip install pytest pytest-xdist ${{ matrix.extra-requires }}
pytest -n2 -q test --nomemory --notimingintensive
- name: Upload wheels to release
# upload the generated wheels to the github release
uses: AButler/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
files: 'dist/*.whl'
- name: Set up Python for twine
# twine on py2 is very old and is no longer updated, so we change to python 3.8 before upload
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Publish wheel
# the action https://github.com/marketplace/actions/pypi-publish runs only on linux and we cannot specify
# additional options
env:
TWINE_USERNAME: __token__
# replace TWINE_PASSWORD with token for real pypi
# TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: |
pip install -U twine
twine upload --skip-existing dist/*
make-wheel-linux:
name: ${{ matrix.python-version }}-${{ matrix.architecture }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
# the versions are <python tag>-<abi tag> as specified in PEP 425.
- cp27-cp27m
- cp27-cp27mu
- cp36-cp36m
- cp37-cp37m
- cp38-cp38
- cp39-cp39
architecture:
- x64
include:
- python-version: "cp27-cp27m"
extra-requires: "mock"
- python-version: "cp27-cp27mu"
extra-requires: "mock"
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get python version
id: linux-py-version
env:
py_tag: ${{ matrix.python-version }}
# the command `echo "::set-output ...` is used to create an step output that can be used in following steps
# this is from https://github.community/t5/GitHub-Actions/Using-the-output-of-run-inside-of-if-condition/td-p/33920
run: |
version="${py_tag: 2:1}.${py_tag: 3:1}"
echo $version
echo "::set-output name=python-version::$version"
- name: Remove tag_build from setup.cfg
# sqlalchemy has `tag_build` set to `dev` in setup.cfg. We need to remove it before creating the weel
# otherwise it gets tagged with `dev0`
shell: pwsh
# This is equivalent to the sed commands:
# `sed -i '/tag_build=dev/d' setup.cfg`
# `sed -i '/tag_build = dev/d' setup.cfg`
# `-replace` uses a regexp match
# alternative form: `(get-content setup.cfg) | foreach-object{$_ -replace "tag_build.=.dev",""} | set-content setup.cfg`
run: |
(cat setup.cfg) | %{$_ -replace "tag_build.?=.?dev",""} | set-content setup.cfg
- name: Create wheel for manylinux1 and manylinux2010 for py3
if: ${{ matrix.python-version != 'cp27-cp27m' && matrix.python-version != 'cp27-cp27mu' }}
# this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
# the action uses the image for manylinux2010 but can generate also a manylinux1 wheel
# change the tag of this image to change the image used
uses: RalfG/[email protected]_x86_64
# this action generates 3 wheels in dist/. linux, manylinux1 and manylinux2010
with:
# python-versions is the output of the previous step and is in the form <python tag>-<abi tag>. Eg cp27-cp27mu
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34"
# Create the wheel using --no-use-pep517 since locally we have pyproject
# This flag should be removed once sqlalchemy supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
- name: Create wheel for manylinux2014 for py3
if: ${{ matrix.python-version != 'cp27-cp27m' && matrix.python-version != 'cp27-cp27mu' }}
# this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
# the action uses the image for manylinux2010 but can generate also a manylinux1 wheel
# change the tag of this image to change the image used
uses: RalfG/[email protected]_x86_64
# this action generates 2 wheels in dist/. linux and manylinux2014
with:
# python-versions is the output of the previous step and is in the form <python tag>-<abi tag>. Eg cp27-cp27mu
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34"
# Create the wheel using --no-use-pep517 since locally we have pyproject
# This flag should be removed once sqlalchemy supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
- name: Create wheel for manylinux py2
if: ${{ matrix.python-version == 'cp27-cp27m' || matrix.python-version == 'cp27-cp27mu' }}
# this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
# the action uses the image for manylinux2010 but can generate also a manylinux1 wheel
# change the tag of this image to change the image used
uses: RalfG/[email protected]_x86_64
# this action generates 2 wheels in dist/. linux and manylinux1
with:
# python-versions is the output of the previous step and is in the form <python tag>-<abi tag>. Eg cp27-cp27mu
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34"
# Create the wheel using --no-use-pep517 since locally we have pyproject
# This flag should be removed once sqlalchemy supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ steps.linux-py-version.outputs.python-version }}
architecture: ${{ matrix.architecture }}
- name: Check created wheel
# check that the wheel is compatible with the current installation.
# If it is then does:
# - install the created wheel without using the pypi index
# - check the c extension
# - runs the tests
run: |
pip install 'packaging>=20.4'
if python .github/workflows/scripts/can_install.py "${{ matrix.python-version }}"
then
pip install greenlet "importlib-metadata;python_version<'3.8'"
pip install -f dist --no-index sqlalchemy
python -c 'from sqlalchemy.util import has_compiled_ext; assert has_compiled_ext()'
pip install pytest pytest-xdist ${{ matrix.extra-requires }}
pytest -n2 -q test --nomemory --notimingintensive
else
echo Not compatible. Skipping install.
fi
- name: Upload wheels to release
# upload the generated wheels to the github release
uses: AButler/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
files: 'dist/*manylinux*'
- name: Set up Python for twine
# twine on py2 is very old and is no longer updated, so we change to python 3.8 before upload
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Publish wheel
# the action https://github.com/marketplace/actions/pypi-publish runs only on linux and we cannot specify
# additional options
# We upload both manylinux1 and manylinux2010 wheels. pip will download the appropriate one according to the system.
# manylinux1 is an older format and is now not very used since many environments can use manylinux2010
# currently (April 2020) manylinux2014 is still wip, so we do not generate it.
env:
TWINE_USERNAME: __token__
# replace TWINE_PASSWORD with token for real pypi
# TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: |
pip install -U twine
twine upload --skip-existing dist/*manylinux*
make-wheel-linux-arm64:
name: ${{ matrix.python-version }}-arm64-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
python-version:
# the versions are <python tag>-<abi tag> as specified in PEP 425.
- cp36-cp36m
- cp37-cp37m
- cp38-cp38
- cp39-cp39
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get python version
id: linux-py-version
env:
py_tag: ${{ matrix.python-version }}
# the command `echo "::set-output ...` is used to create an step output that can be used in following steps
# this is from https://github.community/t5/GitHub-Actions/Using-the-output-of-run-inside-of-if-condition/td-p/33920
run: |
version="${py_tag: 2:1}.${py_tag: 3:1}"
echo $version
echo "::set-output name=python-version::$version"
- name: Remove tag_build from setup.cfg
# sqlalchemy has `tag_build` set to `dev` in setup.cfg. We need to remove it before creating the weel
# otherwise it gets tagged with `dev0`
shell: pwsh
# This is equivalent to the sed commands:
# `sed -i '/tag_build=dev/d' setup.cfg`
# `sed -i '/tag_build = dev/d' setup.cfg`
# `-replace` uses a regexp match
# alternative form: `(get-content setup.cfg) | foreach-object{$_ -replace "tag_build.=.dev",""} | set-content setup.cfg`
run: |
(cat setup.cfg) | %{$_ -replace "tag_build.?=.?dev",""} | set-content setup.cfg
- name: Set up emulation
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Create wheel for manylinux2014
# this step uses the image provided by pypa here https://github.com/pypa/manylinux to generate the wheels on linux
# the action uses the image for manylinux2014 but can generate also a manylinux1 wheel
# change the tag of this image to change the image used
uses: RalfG/[email protected]_aarch64
# this action generates 2 wheels in dist/. linux and manylinux2014
with:
# python-versions is the output of the previous step and is in the form <python tag>-<abi tag>. Eg cp37-cp37mu
python-versions: ${{ matrix.python-version }}
build-requirements: "setuptools>=44 wheel>=0.34"
# Create the wheel using --no-use-pep517 since locally we have pyproject
# This flag should be removed once sqlalchemy supports pep517
# `--no-deps` is used to only generate the wheel for the current library. Redundant in sqlalchemy since it has no dependencies
pip-wheel-args: "-w ./dist --no-use-pep517 -v --no-deps"
- name: Check created wheel
# check that the wheel is compatible with the current installation.
# - runs the tests
uses: docker://quay.io/pypa/manylinux2014_aarch64
with:
args: |
bash -c "
export PATH=/opt/python/${{ matrix.python-version }}/bin:$PATH &&
python --version &&
pip install greenlet \"importlib-metadata;python_version<'3.8'\" &&
pip install -f dist --no-index sqlalchemy &&
python -c 'from sqlalchemy.util import has_compiled_ext; assert has_compiled_ext()' &&
pip install pytest pytest-xdist ${{ matrix.extra-requires }} &&
pytest -n2 -q test --nomemory --notimingintensive"
- name: Upload wheels to release
# upload the generated wheels to the github release
uses: AButler/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
files: 'dist/*manylinux*'
- name: Set up Python for twine
# Setup python after creating the wheel, otherwise LD_LIBRARY_PATH gets set and it will break wheel generation
# twine on py2 is very old and is no longer updated, so we change to python 3.8 before upload
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Publish wheel
# the action https://github.com/marketplace/actions/pypi-publish runs only on linux and we cannot specify
# additional options
# We upload manylinux2014 arm64 wheels. pip will download the appropriate one according to the system.
env:
TWINE_USERNAME: __token__
# replace TWINE_PASSWORD with token for real pypi
# TWINE_PASSWORD: ${{ secrets.test_pypi_token }}
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: |
pip install -U twine
twine upload --skip-existing dist/*manylinux*