Skip to content

Commit 1483f73

Browse files
Parallel Wheel Builds (#1024)
* Fix import issue in tests * Parallelize wheel building and add muslinux support --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3962f54 commit 1483f73

File tree

2 files changed

+120
-27
lines changed

2 files changed

+120
-27
lines changed

.github/workflows/deploy-python.yml

Lines changed: 118 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,121 @@ on:
2020
- published
2121

2222
jobs:
23-
deploy-linux:
23+
build-linux-py3:
2424
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
wheel:
29+
- cp37-manylinux
30+
- cp37-musllinux
31+
- cp38-manylinux
32+
- cp38-musllinux
33+
- cp39-manylinux
34+
- cp39-musllinux
35+
- cp310-manylinux
36+
- cp310-musllinux
37+
- cp311-manylinux
38+
- cp311-musllinux
39+
- cp312-manylinux
40+
- cp312-musllinux
2541

2642
steps:
27-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
2844
with:
2945
persist-credentials: false
3046
fetch-depth: 0
3147

3248
- name: Setup QEMU
33-
uses: docker/setup-qemu-action@v1
49+
uses: docker/setup-qemu-action@v3
3450

51+
- name: Build Wheels
52+
uses: pypa/[email protected]
53+
env:
54+
CIBW_PLATFORM: linux
55+
CIBW_BUILD: "${{ matrix.wheel }}*"
56+
CIBW_ARCHS_LINUX: x86_64 aarch64
57+
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
58+
CIBW_TEST_REQUIRES: pytest
59+
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"
60+
61+
- name: Upload Artifacts
62+
uses: actions/[email protected]
63+
with:
64+
name: ${{ github.job }}-${{ matrix.wheel }}
65+
path: ./wheelhouse/*.whl
66+
retention-days: 1
67+
68+
build-linux-py2:
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- uses: actions/checkout@v4
73+
with:
74+
persist-credentials: false
75+
fetch-depth: 0
76+
77+
- name: Setup QEMU
78+
uses: docker/setup-qemu-action@v3
79+
80+
- name: Build Wheels
81+
uses: pypa/[email protected]
82+
env:
83+
CIBW_PLATFORM: linux
84+
CIBW_BUILD: cp27-manylinux_x86_64
85+
CIBW_ARCHS_LINUX: x86_64
86+
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
87+
CIBW_TEST_REQUIRES: pytest==4.6.11
88+
CIBW_TEST_COMMAND: "PYTHONPATH={project}/tests pytest {project}/tests/agent_unittests -vx"
89+
90+
- name: Upload Artifacts
91+
uses: actions/[email protected]
92+
with:
93+
name: ${{ github.job }}
94+
path: ./wheelhouse/*.whl
95+
retention-days: 1
96+
97+
build-sdist:
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v4
101+
with:
102+
persist-credentials: false
103+
fetch-depth: 0
104+
105+
- name: Install Dependencies
106+
run: |
107+
pip install -U pip
108+
pip install -U setuptools
109+
110+
- name: Build Source Package
111+
run: |
112+
python setup.py sdist
113+
114+
- name: Prepare MD5 Hash File
115+
run: |
116+
tarball="$(python setup.py --fullname).tar.gz"
117+
md5_file=${tarball}.md5
118+
openssl md5 -binary dist/${tarball} | xxd -p | tr -d '\n' > dist/${md5_file}
119+
120+
- name: Upload Artifacts
121+
uses: actions/[email protected]
122+
with:
123+
name: ${{ github.job }}-sdist
124+
path: |
125+
./dist/*.tar.gz
126+
./dist/*.tar.gz.md5
127+
retention-days: 1
128+
129+
deploy:
130+
runs-on: ubuntu-latest
131+
132+
needs:
133+
- build-linux-py3
134+
- build-linux-py2
135+
- build-sdist
136+
137+
steps:
35138
- uses: actions/setup-python@v2
36139
with:
37140
python-version: "3.x"
@@ -42,32 +145,22 @@ jobs:
42145
pip install -U pip
43146
pip install -U wheel setuptools twine
44147
45-
- name: Build Source Package
46-
run: python setup.py sdist
47-
48-
- name: Build Manylinux Wheels (Python 2)
49-
uses: pypa/[email protected]
50-
env:
51-
CIBW_PLATFORM: linux
52-
CIBW_BUILD: cp27-manylinux_x86_64
53-
CIBW_ARCHS: x86_64
54-
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/=vtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
148+
- name: Download Artifacts
149+
uses: actions/[email protected]
150+
with:
151+
path: ./artifacts/
55152

56-
- name: Build Manylinux Wheels (Python 3)
57-
uses: pypa/[email protected]
58-
env:
59-
CIBW_PLATFORM: linux
60-
CIBW_BUILD: cp37-manylinux* cp38-manylinux* cp39-manylinux* cp310-manylinux* cp311-manylinux*
61-
CIBW_ARCHS: x86_64 aarch64
62-
CIBW_ENVIRONMENT: "LD_LIBRARY_PATH=/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/usr/local/lib64:/usr/local/lib"
153+
- name: Unpack Artifacts
154+
run: |
155+
mkdir -p dist/
156+
mv artifacts/**/*{.whl,.tar.gz,.tar.gz.md5} dist/
63157
64158
- name: Upload Package to S3
65159
run: |
66160
tarball="$(python setup.py --fullname).tar.gz"
67-
md5_file=$(mktemp)
68-
openssl md5 -binary dist/$tarball | xxd -p | tr -d '\n' > $md5_file
69-
aws s3 cp $md5_file $S3_DST/${tarball}.md5
70-
aws s3 cp dist/$tarball $S3_DST/$tarball
161+
md5_file=${tarball}.md5
162+
aws s3 cp dist/${md5_file} $S3_DST/${md5_file}
163+
aws s3 cp dist/${tarball} $S3_DST/${tarball}
71164
env:
72165
S3_DST: s3://nr-downloads-main/python_agent/release
73166
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -76,7 +169,7 @@ jobs:
76169

77170
- name: Upload Package to PyPI
78171
run: |
79-
twine upload --non-interactive dist/*.tar.gz wheelhouse/*-manylinux*.whl
172+
twine upload --non-interactive dist/*.tar.gz dist/*.whl
80173
env:
81174
TWINE_USERNAME: __token__
82175
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

tests/agent_unittests/test_package_version_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import warnings
1717

1818
import pytest
19-
import six
2019
from testing_support.validators.validate_function_called import validate_function_called
2120

2221
from newrelic.common.package_version_utils import (
@@ -26,6 +25,7 @@
2625
get_package_version,
2726
get_package_version_tuple,
2827
)
28+
from newrelic.packages import six
2929

3030
# Notes:
3131
# importlib.metadata was a provisional addition to the std library in PY38 and PY39
@@ -143,7 +143,7 @@ def test_deprecation_warning_suppression(monkeypatch, recwarn):
143143
monkeypatch.setattr(pytest, "__getattr__", _getattr_deprecation_warning, raising=False)
144144

145145
assert get_package_version("pytest") == "3.2.1"
146-
146+
147147
assert not recwarn.list, "Warnings not suppressed."
148148

149149

0 commit comments

Comments
 (0)