Skip to content

Commit f671cb4

Browse files
authored
Use cibuildwheel to build wheels (#70)
The cibuildwheel infra seems to be mature enough, so use it for the wheel-building step instead of the homegrown setup. This gives us 32-bit and ARM wheels for free. Fixes: #44 Fixes: #63
1 parent 189b959 commit f671cb4

File tree

5 files changed

+59
-100
lines changed

5 files changed

+59
-100
lines changed

.github/workflows/build-manylinux-wheels.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
mkdir -p dist/
3636
echo "${VERSION}" > dist/VERSION
3737
38-
- uses: actions/upload-artifact@v1
38+
- uses: actions/upload-artifact@v2
3939
with:
4040
name: dist
4141
path: dist/
@@ -50,80 +50,61 @@ jobs:
5050
fetch-depth: 50
5151
submodules: true
5252

53-
- name: Set up Python 3.7
54-
uses: actions/setup-python@v2
55-
with:
56-
python-version: 3.7
53+
- uses: actions/setup-python@v2
5754

5855
- name: Build source distribution
5956
run: |
60-
pip install -U setuptools wheel pip
57+
python -m pip install -U setuptools wheel pip
6158
python setup.py sdist
6259
63-
- uses: actions/upload-artifact@v1
60+
- uses: actions/upload-artifact@v2
6461
with:
6562
name: dist
66-
path: dist/
63+
path: dist/*.tar.*
6764

6865
build-wheels:
6966
needs: validate-release-request
7067
runs-on: ${{ matrix.os }}
7168
strategy:
7269
matrix:
73-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
74-
os: [ubuntu-16.04, macos-latest, windows-latest]
75-
exclude:
76-
# Python 3.5 is unable to properly
77-
# find the recent VS tooling
78-
# https://bugs.python.org/issue30389
79-
- os: windows-latest
80-
python-version: 3.5
70+
os: [ubuntu-latest, macos-latest, windows-latest]
71+
cibw_arch: [auto]
72+
include:
73+
- os: ubuntu-latest
74+
cibw_arch: aarch64
75+
- os: macos-latest
76+
cibw_arch: universal2
8177

8278
steps:
8379
- uses: actions/checkout@v2
8480
with:
8581
fetch-depth: 50
8682
submodules: true
8783

88-
- name: Set up Python ${{ matrix.python-version }}
89-
uses: actions/setup-python@v2
84+
- name: Set up QEMU
85+
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
86+
uses: docker/setup-qemu-action@v1
9087
with:
91-
python-version: ${{ matrix.python-version }}
92-
93-
- name: Install Python Deps
94-
run: |
95-
python -m pip install --upgrade setuptools pip wheel
88+
platforms: arm64
9689

97-
- name: Test
98-
run: |
99-
make debug && make test
100-
101-
- name: Build Wheels (linux)
102-
if: startsWith(matrix.os, 'ubuntu')
103-
uses: docker://quay.io/pypa/manylinux1_x86_64
90+
- uses: pypa/[email protected]
10491
env:
105-
PYTHON_VERSION: ${{ matrix.python-version }}
106-
with:
107-
entrypoint: /github/workspace/.github/workflows/build-manylinux-wheels.sh
108-
109-
- name: Build Wheels (non-linux)
110-
if: "!startsWith(matrix.os, 'ubuntu')"
111-
run: |
112-
make clean
113-
python setup.py bdist_wheel
114-
115-
- name: Test Wheels
116-
shell: bash
117-
if: |
118-
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
119-
run: |
120-
pip install --pre immutables -f "file:///${GITHUB_WORKSPACE}/dist"
121-
make -C "${GITHUB_WORKSPACE}" testinstalled
122-
123-
- uses: actions/upload-artifact@v1
92+
CIBW_BUILD_VERBOSITY: 1
93+
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-*"
94+
CIBW_ARCHS: ${{ matrix.cibw_arch }}
95+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux1_x86_64
96+
CIBW_MANYLINUX_I686_IMAGE: quay.io/pypa/manylinux1_i686
97+
CIBW_SKIP: "pp*"
98+
CIBW_TEST_EXTRAS: "test"
99+
CIBW_TEST_COMMAND: "cd .. && python {project}/tests/__init__.py"
100+
CIBW_TEST_COMMAND_WINDOWS: "cd .. && python {project}\\tests\\__init__.py"
101+
CIBW_TEST_SKIP: "*universal2:arm64"
102+
CIBW_ENVIRONMENT: "IMMU_SKIP_MYPY_TESTS=1"
103+
104+
- uses: actions/upload-artifact@v2
124105
with:
125106
name: dist
126-
path: dist/
107+
path: wheelhouse/*.whl
127108

128109
publish:
129110
needs: [build-sdist, build-wheels]
@@ -135,7 +116,7 @@ jobs:
135116
fetch-depth: 5
136117
submodules: false
137118

138-
- uses: actions/download-artifact@v1
119+
- uses: actions/download-artifact@v2
139120
with:
140121
name: dist
141122
path: dist/

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
- name: Set up Python ${{ matrix.python-version }}
4444
uses: actions/setup-python@v2
4545
if: steps.release.outputs.version == 0
46+
env:
47+
PIP_DISABLE_PIP_VERSION_CHECK: 1
4648
with:
4749
python-version: ${{ matrix.python-version }}
4850
architecture: ${{ matrix.arch }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ __pycache__/
2121
/.coverage
2222
/.mypy_cache
2323
/.venv*
24+
/wheelhouse

tests/test_mypy.py

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
import os
2-
import mypy.test.testcmdline
3-
from mypy.test.helpers import normalize_error_messages
42

5-
6-
# I'm upset. There's no other way to deal with the little 'defined here'
7-
# notes that mypy emits when passing an unexpected keyword argument
8-
# and at no other time.
9-
def renormalize_error_messages(messages):
10-
messages = [x for x in messages if not x.endswith(' defined here')]
11-
return normalize_error_messages(messages)
12-
13-
14-
mypy.test.testcmdline.normalize_error_messages = renormalize_error_messages
15-
16-
17-
this_file_dir = os.path.dirname(os.path.realpath(__file__))
18-
test_data_prefix = os.path.join(this_file_dir, 'test-data')
19-
20-
21-
class ImmuMypyTest(mypy.test.testcmdline.PythonCmdlineSuite):
22-
data_prefix = test_data_prefix
23-
files = ['check-immu.test']
3+
try:
4+
import mypy.test.testcmdline
5+
from mypy.test.helpers import normalize_error_messages
6+
except (ImportError, AssertionError):
7+
if os.environ.get('IMMU_SKIP_MYPY_TESTS'):
8+
pass
9+
else:
10+
raise
11+
else:
12+
# I'm upset. There's no other way to deal with the little 'defined here'
13+
# notes that mypy emits when passing an unexpected keyword argument
14+
# and at no other time.
15+
def renormalize_error_messages(messages):
16+
messages = [x for x in messages if not x.endswith(' defined here')]
17+
return normalize_error_messages(messages)
18+
19+
mypy.test.testcmdline.normalize_error_messages = renormalize_error_messages
20+
21+
this_file_dir = os.path.dirname(os.path.realpath(__file__))
22+
test_data_prefix = os.path.join(this_file_dir, 'test-data')
23+
24+
class ImmuMypyTest(mypy.test.testcmdline.PythonCmdlineSuite):
25+
data_prefix = test_data_prefix
26+
files = ['check-immu.test']

0 commit comments

Comments
 (0)