Skip to content

Commit 7081923

Browse files
reaperhulkalex
andauthored
refactor wheel builder to use workflows and download/build separately (#5412)
* refactor wheel builder to use workflows and download/build separately * Update .github/workflows/wheel-builder.yml Co-authored-by: Alex Gaynor <[email protected]> Co-authored-by: Alex Gaynor <[email protected]>
1 parent ad17c03 commit 7081923

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

.github/workflows/wheel-builder.yml

+35-33
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Wheel Builder
22
on:
3-
repository_dispatch:
4-
types: [wheel-builder]
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
required: true
57

68
jobs:
79
manylinux:
@@ -15,21 +17,21 @@ jobs:
1517
CONTAINER: "pyca/cryptography-manylinux1:x86_64"
1618
- NAME: manylinux2010_x86_64
1719
CONTAINER: "pyca/cryptography-manylinux2010:x86_64"
18-
name: "Python ${{ matrix.PYTHON }} for ${{ matrix.MANYLINUX.NAME }}"
20+
name: "${{ matrix.PYTHON }} for ${{ matrix.MANYLINUX.NAME }}"
1921
steps:
2022
- run: /opt/python/${{ matrix.PYTHON }}/bin/python -m virtualenv .venv
21-
- name: Downgrade pip, can't remember why
22-
run: .venv/bin/pip install -U pip==10.0.1
2323
- name: Install Python dependencies
24-
run: .venv/bin/pip install cffi six ipaddress "enum34; python_version < '3'"
24+
run: .venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
25+
- run: .venv/bin/pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir tmpwheelhouse
2526
- run: |
2627
REGEX="cp3([0-9])*"
2728
if [[ "${{ matrix.PYTHON }}" =~ $REGEX ]]; then
28-
PY_LIMITED_API="--build-option --py-limited-api=cp3${BASH_REMATCH[1]}"
29+
PY_LIMITED_API="--py-limited-api=cp3${BASH_REMATCH[1]}"
2930
fi
31+
cd cryptography*
3032
LDFLAGS="-L/opt/pyca/cryptography/openssl/lib" \
3133
CFLAGS="-I/opt/pyca/cryptography/openssl/include -Wl,--exclude-libs,ALL" \
32-
.venv/bin/pip wheel cryptography==${{ github.event.client_payload.BUILD_VERSION }} --no-binary cryptography --no-deps --wheel-dir=tmpwheelhouse $PY_LIMITED_API
34+
../.venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/cryptography*.whl ../tmpwheelhouse
3335
- run: auditwheel repair --plat ${{ matrix.MANYLINUX.NAME }} tmpwheelhouse/cryptograph*.whl -w wheelhouse/
3436
- run: unzip wheelhouse/*.whl -d execstack.check
3537
- run: |
@@ -40,16 +42,14 @@ jobs:
4042
else
4143
exit 0
4244
fi
43-
- name: Upgrade pip again so we can actually use manylinux2010
44-
run: .venv/bin/pip install -U pip
4545
- run: .venv/bin/pip install cryptography --no-index -f wheelhouse/
4646
- run: |
4747
.venv/bin/python -c "from cryptography.hazmat.backends.openssl.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
4848
- run: mkdir cryptography-wheelhouse
4949
- run: mv wheelhouse/cryptography*.whl cryptography-wheelhouse/
5050
- uses: actions/upload-artifact@v1
5151
with:
52-
name: "cryptography-${{ github.event.client_payload.BUILD_VERSION }}-${{ matrix.MANYLINUX.NAME }}-${{ matrix.PYTHON }}"
52+
name: "cryptography-${{ github.event.inputs.version }}-${{ matrix.MANYLINUX.NAME }}-${{ matrix.PYTHON }}"
5353
path: cryptography-wheelhouse/
5454

5555
macos:
@@ -65,7 +65,7 @@ jobs:
6565
ABI_VERSION: '3.5'
6666
DOWNLOAD_URL: 'https://www.python.org/ftp/python/3.8.2/python-3.8.2-macosx10.9.pkg'
6767
BIN_PATH: '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3'
68-
name: "Python ${{ matrix.PYTHON.VERSION }} for ABI ${{ matrix.PYTHON.ABI_VERSION }} on macOS"
68+
name: "${{ matrix.PYTHON.VERSION }} ABI ${{ matrix.PYTHON.ABI_VERSION }} macOS"
6969
steps:
7070
- uses: actions/checkout@master
7171
- run: |
@@ -81,24 +81,20 @@ jobs:
8181
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8282

8383
- run: ${{ matrix.PYTHON.BIN_PATH }} -m virtualenv venv
84-
# Downgrade pip, I can't remember why
85-
- run: venv/bin/pip install -U pip==10.0.1
86-
- run: venv/bin/pip install -U wheel
87-
- run: venv/bin/pip install cffi six ipaddress "enum34; python_version < '3'"
88-
84+
- run: venv/bin/pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
85+
- run: venv/bin/pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir wheelhouse
8986
- name: Build the wheel
9087
run: |
9188
REGEX="3\.([0-9])*"
92-
if [[ "$PYTHON_VERSION" =~ $REGEX ]]; then
93-
PY_LIMITED_API="--build-option --py-limited-api=cp3${BASH_REMATCH[1]}"
89+
if [[ "${{ matrix.PYTHON.ABI_VERSION }}" =~ $REGEX ]]; then
90+
PY_LIMITED_API="--py-limited-api=cp3${BASH_REMATCH[1]}"
9491
fi
9592
93+
cd cryptography*
9694
CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS="1" \
9795
LDFLAGS="${HOME}/openssl-macos/lib/libcrypto.a ${HOME}/openssl-macos/lib/libssl.a" \
9896
CFLAGS="-I${HOME}/openssl-macos/include -mmacosx-version-min=10.10 -march=core2" \
99-
venv/bin/pip wheel cryptography==${{ github.event.client_payload.BUILD_VERSION }} --wheel-dir=wheelhouse --no-binary cryptography --no-deps $PY_LIMITED_API
100-
env:
101-
PYTHON_VERSION: ${{ matrix.PYTHON.ABI_VERSION }}
97+
../venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/cryptography*.whl ../wheelhouse
10298
- run: venv/bin/pip install -f wheelhouse --no-index cryptography
10399
- run: |
104100
venv/bin/python -c "from cryptography.hazmat.backends.openssl.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
@@ -107,7 +103,7 @@ jobs:
107103
- run: mv wheelhouse/cryptography*.whl cryptography-wheelhouse/
108104
- uses: actions/upload-artifact@v1
109105
with:
110-
name: "cryptography-${{ github.event.client_payload.BUILD_VERSION }}-macOS-${{ matrix.PYTHON.ABI_VERSION }}"
106+
name: "cryptography-${{ github.event.inputs.version }}-macOS-${{ matrix.PYTHON.ABI_VERSION }}"
111107
path: cryptography-wheelhouse/
112108

113109
windows:
@@ -118,16 +114,17 @@ jobs:
118114
- {ARCH: 'x86', WINDOWS: 'win32'}
119115
- {ARCH: 'x64', WINDOWS: 'win64'}
120116
PYTHON:
121-
- {VERSION: "2.7", TOXENV: "py27", MSVC_VERSION: "2010"}
122-
- {VERSION: "3.5", TOXENV: "py35", MSVC_VERSION: "2019"}
123-
- {VERSION: "3.6", TOXENV: "py36", MSVC_VERSION: "2019"}
124-
- {VERSION: "3.7", TOXENV: "py37", MSVC_VERSION: "2019"}
125-
- {VERSION: "3.8", TOXENV: "py38", MSVC_VERSION: "2019"}
126-
name: "Python ${{ matrix.PYTHON.VERSION }} on ${{ matrix.WINDOWS.WINDOWS }}"
117+
- {VERSION: "2.7", MSVC_VERSION: "2010"}
118+
- {VERSION: "3.5", MSVC_VERSION: "2019"}
119+
- {VERSION: "3.6", MSVC_VERSION: "2019"}
120+
- {VERSION: "3.7", MSVC_VERSION: "2019"}
121+
- {VERSION: "3.8", MSVC_VERSION: "2019"}
122+
- {VERSION: "3.8", MSVC_VERSION: "2019", "USE_ABI3": "true", "ABI_VERSION": "cp36"}
123+
name: "${{ matrix.PYTHON.VERSION }} ${{ matrix.WINDOWS.WINDOWS }} ${{ matrix.PYTHON.ABI_VERSION }}"
127124
steps:
128125
- uses: actions/checkout@master
129126
- name: Setup python
130-
uses: actions/setup-python@v1
127+
uses: actions/setup-python@v2
131128
with:
132129
python-version: ${{ matrix.PYTHON.VERSION }}
133130
architecture: ${{ matrix.WINDOWS.ARCH }}
@@ -147,8 +144,13 @@ jobs:
147144
env:
148145
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149146

150-
- run: pip install cffi six ipaddress "enum34; python_version < '3'"
151-
- run: pip wheel cryptography==${{ github.event.client_payload.BUILD_VERSION }} --wheel-dir=wheelhouse --no-binary cryptography
147+
- run: python -m pip install -U pip wheel cffi six ipaddress "enum34; python_version < '3'"
148+
- run: pip download cryptography==${{ github.event.inputs.version }} --no-deps --no-binary cryptography && tar zxvf cryptography*.tar.gz && mkdir wheelhouse
149+
shell: bash
150+
- run: cd cryptography* && python setup.py bdist_wheel && mv dist/cryptography*.whl ../wheelhouse
151+
if: matrix.PYTHON.USE_ABI3 != 'true'
152+
- run: cd cryptography* && python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/cryptography*.whl ../wheelhouse
153+
if: matrix.PYTHON.USE_ABI3 == 'true'
152154
- run: pip install -f wheelhouse --no-index cryptography
153155
- name: Print the OpenSSL we built and linked against
154156
run: |
@@ -158,5 +160,5 @@ jobs:
158160
- run: move wheelhouse\cryptography*.whl cryptography-wheelhouse\
159161
- uses: actions/upload-artifact@v1
160162
with:
161-
name: "cryptography-${{ github.event.client_payload.BUILD_VERSION }}-${{ matrix.WINDOWS.WINDOWS }}-${{ matrix.PYTHON.VERSION }}"
163+
name: "cryptography-${{ github.event.inputs.version }}-${{ matrix.WINDOWS.WINDOWS }}-${{ matrix.PYTHON.VERSION }}-${{ matrix.PYTHON.ABI_VERSION}}"
162164
path: cryptography-wheelhouse\

release.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,14 @@ def build_github_actions_wheels(token, version):
8383
session = requests.Session()
8484

8585
response = session.post(
86-
"https://api.github.com/repos/pyca/cryptography/dispatches",
86+
"https://api.github.com/repos/pyca/cryptography/actions/workflows/"
87+
"wheel-builder.yml/dispatches",
8788
headers={
8889
"Content-Type": "application/json",
89-
"Accept": "application/vnd.github.everest-preview+json",
90+
"Accept": "application/vnd.github.v3+json",
9091
"Authorization": "token {}".format(token),
9192
},
92-
data=json.dumps(
93-
{
94-
"event_type": "wheel-builder",
95-
"client_payload": {"BUILD_VERSION": version},
96-
}
97-
),
93+
data=json.dumps({"ref": "master", "inputs": {"version": version}}),
9894
)
9995
response.raise_for_status()
10096

@@ -103,7 +99,7 @@ def build_github_actions_wheels(token, version):
10399
response = session.get(
104100
(
105101
"https://api.github.com/repos/pyca/cryptography/actions/workflows/"
106-
"wheel-builder.yml/runs?event=repository_dispatch"
102+
"wheel-builder.yml/runs?event=workflow_dispatch"
107103
),
108104
headers={
109105
"Content-Type": "application/json",

0 commit comments

Comments
 (0)