Skip to content

Commit 0974499

Browse files
authored
Add Windows and Mac wheelbuilding (#39)
1 parent 87d3b9b commit 0974499

File tree

3 files changed

+114
-11
lines changed

3 files changed

+114
-11
lines changed

.github/workflows/release-python.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Python Wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build-wheels:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [macos-latest, windows-2019, ubuntu-latest]
11+
name: Build CPython ${{ matrix.python-version }}-${{ matrix.os }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: pypa/cibuildwheel@v2.3.1
15+
env:
16+
CIBW_ARCHS_MACOS: x86_64 universal2
17+
CIBW_TEST_SKIP: '*universal2:arm64'
18+
CIBW_BUILD: "cp36-macosx_x86_64 cp38-macosx_universal2 cp36-win* cp36-manylinux_{x86_64,i686}"
19+
- uses: actions/upload-artifact@v2
20+
with:
21+
name: python_bsonjs-3.6-${{ matrix.os }}-wheel
22+
path: ./wheelhouse/*.whl
23+
if-no-files-found: error
24+
test-non-linux-wheels:
25+
needs: build-wheels
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
matrix:
29+
os: [macos-latest, windows-2019]
30+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
31+
name: Test CPython ${{ matrix.python-version }}-${{ matrix.os }}
32+
steps:
33+
- name: Setup Python
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Download a previously created wheel
38+
uses: actions/download-artifact@v2
39+
with:
40+
name: python_bsonjs-3.6-${{ matrix.os }}-wheel
41+
- name: Test wheel
42+
shell: bash
43+
run: |
44+
python -m pip install -U pip
45+
python -m pip install --no-index --find-links=./ python_bsonjs
46+
python -m pip list | grep python-bsonjs
47+
python -c "from bsonjs import dumps"
48+
# Linux
49+
test-manylinux-wheels:
50+
runs-on: ${{ matrix.os }}
51+
needs: build-wheels
52+
strategy:
53+
matrix:
54+
os: [ubuntu-latest]
55+
container: ['manylinux2014_i686', 'manylinux2014_x86_64']
56+
python-version: ['cp36-cp36m', 'cp37-cp37m', 'cp38-cp38',
57+
'cp39-cp39', 'cp310-cp310']
58+
name: Test CPython ${{ matrix.python-version }}-${{ matrix.container }}
59+
steps:
60+
- name: Download a previously created wheel
61+
uses: actions/download-artifact@v2
62+
with:
63+
name: python_bsonjs-3.6-${{ matrix.os }}-wheel
64+
- name: Test wheel
65+
run: |
66+
docker run --rm --volume `pwd`:/python quay.io/pypa/${{ matrix.container }} /bin/bash -c "/opt/python/${{ matrix.python-version }}/bin/python -m pip install -U pip && /opt/python/${{ matrix.python-version }}/bin/python -m pip install --find-links=/python/ --no-index python_bsonjs && /opt/python/${{ matrix.python-version }}/bin/python -m pip list | grep python-bsonjs && /opt/python/${{ matrix.python-version }}/bin/python -c 'from bsonjs import dumps'"
67+
make_sdist:
68+
name: Make SDist
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v2
72+
- name: Build SDist
73+
run: python setup.py sdist --dist-dir=dist --formats=gztar
74+
- uses: actions/upload-artifact@v2
75+
with:
76+
name: "sdist"
77+
path: dist/*.tar.gz
78+
collect-wheels:
79+
runs-on: ubuntu-latest
80+
needs: [build-wheels, make_sdist]
81+
name: Download Wheels
82+
steps:
83+
- name: Download all workflow run artifacts
84+
uses: actions/download-artifact@v2
85+
- name: Flatten directory
86+
run: |
87+
find . -mindepth 2 -type f -exec mv {} . \;
88+
find . -type d -empty -delete
89+
- uses: actions/upload-artifact@v2
90+
with:
91+
name: all-dist
92+
path: "./*"

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [ubuntu-18.04, windows-2019]
11+
os: [macos-latest, ubuntu-18.04, windows-2019]
1212
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1313

1414
steps:

build-wheels.sh

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,35 @@ BSONJS_SOURCE_DIRECTORY="$1"
1010
cd "$BSONJS_SOURCE_DIRECTORY"
1111

1212
ls -la
13+
if [ -z "$PYTHON_BINARY" ]; then
14+
PYTHON_BINARY="python"
15+
fi
16+
17+
$PYTHON_BINARY --version
1318

19+
if [ ! "$(uname)" == "Linux" ]; then
20+
$PYTHON_BINARY -m pip install wheel
21+
fi
1422
# Build limited abi3 wheel.
15-
/opt/python/cp36-cp36m/bin/python setup.py bdist_wheel
23+
$PYTHON_BINARY setup.py bdist_wheel
1624
# https://github.com/pypa/manylinux/issues/49
1725
rm -rf build
1826

19-
# Audit wheels and write manylinux tag.
20-
for whl in dist/*.whl; do
21-
# Skip already built manylinux wheels.
22-
if [[ "$whl" != *"manylinux"* ]]; then
23-
auditwheel repair $whl -w dist
24-
rm $whl
25-
fi
26-
done
27+
# Audit wheels and write multilinux1 tag
28+
# Only if on linux
29+
if [ "$(uname)" == "Linux" ]; then
30+
for whl in dist/*.whl; do
31+
# Skip already built manylinux wheels.
32+
if [[ "$whl" != *"manylinux"* ]]; then
33+
auditwheel repair $whl -w dist
34+
rm $whl
35+
fi
36+
done
37+
fi
2738

2839
# Install packages and test.
2940
for PYBIN in /opt/python/*/bin; do
30-
if [[ ! "${PYBIN}" =~ (36|37|38|39|310) ]]; then
41+
if [[ ! "${PYBIN}" =~ (36|37|38|39|310) || "${PYBIN}" =~ (pypy) ]]; then
3142
continue
3243
fi
3344
"${PYBIN}/pip" install python-bsonjs --no-index -f dist

0 commit comments

Comments
 (0)