Skip to content

Commit d10bf5e

Browse files
authored
chore(build): cibuildwheel for package building (#49)
Swap build system to use `cibuildwheel`
1 parent 5b835f1 commit d10bf5e

File tree

2 files changed

+80
-45
lines changed

2 files changed

+80
-45
lines changed

.github/workflows/publish.yml

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,45 +57,61 @@ jobs:
5757
path: dist/*.whl
5858

5959
build-wheels-mypyc:
60-
name: MyPyC ${{ matrix.os }} py${{ matrix.python-version }}
60+
name: Build MyPyC wheels for all platforms
61+
runs-on: ubuntu-latest
6162
strategy:
62-
fail-fast: false
6363
matrix:
64-
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
6564
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
66-
exclude:
67-
- os: windows-latest
68-
python-version: "3.9"
69-
- os: macos-13
70-
python-version: "3.13"
71-
72-
runs-on: ${{ matrix.os }}
7365
steps:
7466
- name: Check out repository
7567
uses: actions/checkout@v4
7668

77-
- name: Install uv
78-
uses: astral-sh/setup-uv@v4
69+
- name: Set up QEMU
70+
uses: docker/setup-qemu-action@v3
71+
with:
72+
platforms: all
7973

80-
- name: Set up Python ${{ matrix.python-version }}
81-
run: uv python install ${{ matrix.python-version }}
74+
- name: Set up Python
75+
uses: actions/setup-python@v5
76+
with:
77+
python-version: "3.12"
8278

83-
- name: Install dependencies with mypyc extras
84-
run: uv sync --extra mypyc --group build
79+
- name: Install cibuildwheel
80+
run: python -m pip install cibuildwheel
8581

86-
- name: Build MyPyC wheel
87-
run: uv build --wheel
82+
- name: Build wheels with cibuildwheel
83+
run: python -m cibuildwheel --output-dir wheelhouse
8884
env:
85+
# Enable mypyc compilation
8986
HATCH_BUILD_HOOKS_ENABLE: "1"
9087
MYPYC_OPT_LEVEL: "3"
9188
MYPYC_DEBUG_LEVEL: "0"
9289
MYPYC_MULTI_FILE: "1"
9390

94-
- name: Upload mypyc wheel artifacts
91+
# Configure cibuildwheel
92+
CIBW_BUILD: "cp${{ matrix.python-version == '3.9' && '39' || matrix.python-version == '3.10' && '310' || matrix.python-version == '3.11' && '311' || matrix.python-version == '3.12' && '312' || matrix.python-version == '3.13' && '313' }}-*"
93+
CIBW_BUILD_VERBOSITY: 1
94+
95+
# Platform configuration - comprehensive coverage with QEMU emulation
96+
CIBW_ARCHS_LINUX: "x86_64 aarch64"
97+
CIBW_ARCHS_MACOS: "x86_64 arm64"
98+
CIBW_ARCHS_WINDOWS: "AMD64"
99+
100+
# Skip problematic combinations
101+
CIBW_SKIP: "cp39-win_arm64 *-musllinux*"
102+
103+
# Install dependencies using pip for broader compatibility
104+
CIBW_BEFORE_BUILD: "pip install hatch-mypyc hatchling"
105+
CIBW_ENVIRONMENT: "HATCH_BUILD_HOOKS_ENABLE=1 MYPYC_OPT_LEVEL=3 MYPYC_DEBUG_LEVEL=0 MYPYC_MULTI_FILE=1"
106+
107+
# Test the built wheels
108+
CIBW_TEST_COMMAND: "python -c \"import sqlspec; print('MyPyC wheel test passed')\""
109+
110+
- name: Upload wheel artifacts
95111
uses: actions/upload-artifact@v4
96112
with:
97-
name: wheels-mypyc-${{ matrix.os }}-py${{ matrix.python-version }}
98-
path: dist/*.whl
113+
name: wheels-mypyc-py${{ matrix.python-version }}
114+
path: wheelhouse/*.whl
99115

100116

101117
test-wheels:
@@ -127,7 +143,8 @@ jobs:
127143
- name: Download mypyc wheel artifacts
128144
uses: actions/download-artifact@v4
129145
with:
130-
name: wheels-mypyc-${{ matrix.os }}-py${{ matrix.python-version }}
146+
pattern: wheels-mypyc-*
147+
merge-multiple: true
131148
path: dist-mypyc/
132149

133150
- name: Test standard wheel installation

.github/workflows/test-build.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,63 @@ jobs:
6868
path: dist/*.whl
6969

7070
build-wheels-mypyc:
71-
name: MyPyC ${{ matrix.os }} py${{ matrix.python-version }}
71+
name: Build MyPyC wheels for all platforms
72+
runs-on: ubuntu-latest
7273
strategy:
73-
fail-fast: false
7474
matrix:
75-
os: ${{ github.event.inputs.test_matrix == 'full' && fromJSON('["ubuntu-latest", "windows-latest", "macos-latest", "macos-13"]') || fromJSON('["ubuntu-latest"]') }}
7675
python-version: ${{ github.event.inputs.test_matrix == 'full' && fromJSON('["3.9", "3.10", "3.11", "3.12", "3.13"]') || fromJSON('["3.12"]') }}
77-
exclude:
78-
- os: windows-latest
79-
python-version: "3.9"
80-
- os: macos-13
81-
python-version: "3.13"
82-
83-
runs-on: ${{ matrix.os }}
8476
steps:
8577
- name: Check out repository
8678
uses: actions/checkout@v4
8779

88-
- name: Install uv
89-
uses: astral-sh/setup-uv@v4
80+
- name: Set up QEMU
81+
if: github.event.inputs.test_matrix == 'full'
82+
uses: docker/setup-qemu-action@v3
83+
with:
84+
platforms: all
9085

91-
- name: Set up Python ${{ matrix.python-version }}
92-
run: uv python install ${{ matrix.python-version }}
86+
- name: Set up Python
87+
uses: actions/setup-python@v5
88+
with:
89+
python-version: "3.12"
9390

94-
- name: Install dependencies with mypyc extras
95-
run: uv sync --extra mypyc --group build
91+
- name: Install cibuildwheel
92+
run: python -m pip install cibuildwheel
9693

97-
- name: Build MyPyC wheel
98-
run: uv build --wheel
94+
- name: Build wheels with cibuildwheel
95+
run: python -m cibuildwheel --output-dir wheelhouse
9996
env:
97+
# Enable mypyc compilation
10098
HATCH_BUILD_HOOKS_ENABLE: "1"
10199
MYPYC_OPT_LEVEL: "3"
102100
MYPYC_DEBUG_LEVEL: "0"
103101
MYPYC_MULTI_FILE: "1"
104-
shell: bash
105102

106-
- name: Upload mypyc wheel artifacts
103+
# Configure cibuildwheel
104+
CIBW_BUILD: "cp${{ matrix.python-version == '3.9' && '39' || matrix.python-version == '3.10' && '310' || matrix.python-version == '3.11' && '311' || matrix.python-version == '3.12' && '312' || matrix.python-version == '3.13' && '313' }}-*"
105+
CIBW_BUILD_VERBOSITY: 1
106+
107+
# Platform configuration - conditional ARM64 support with QEMU
108+
CIBW_ARCHS_LINUX: ${{ github.event.inputs.test_matrix == 'full' && 'x86_64 aarch64' || 'x86_64' }}
109+
CIBW_ARCHS_MACOS: ${{ github.event.inputs.test_matrix == 'full' && 'x86_64 arm64' || 'x86_64' }}
110+
CIBW_ARCHS_WINDOWS: "AMD64"
111+
112+
# Skip problematic combinations
113+
CIBW_SKIP: "cp39-win_arm64 *-musllinux*"
114+
115+
# Install dependencies using pip for broader compatibility
116+
CIBW_BEFORE_BUILD: "pip install hatch-mypyc hatchling"
117+
CIBW_ENVIRONMENT: "HATCH_BUILD_HOOKS_ENABLE=1 MYPYC_OPT_LEVEL=3 MYPYC_DEBUG_LEVEL=0 MYPYC_MULTI_FILE=1"
118+
119+
# Test the built wheels
120+
CIBW_TEST_COMMAND: "python -c \"import sqlspec; print('MyPyC wheel test passed')\""
121+
122+
- name: Upload wheel artifacts
107123
uses: actions/upload-artifact@v4
108124
with:
109-
name: wheels-mypyc-${{ matrix.os }}-py${{ matrix.python-version }}
110-
path: dist/*.whl
125+
name: wheels-mypyc-py${{ matrix.python-version }}
126+
path: wheelhouse/*.whl
127+
111128

112129
test-wheels:
113130
name: Test ${{ matrix.os }} py${{ matrix.python-version }}
@@ -138,7 +155,8 @@ jobs:
138155
- name: Download mypyc wheel artifacts
139156
uses: actions/download-artifact@v4
140157
with:
141-
name: wheels-mypyc-${{ matrix.os }}-py${{ matrix.python-version }}
158+
pattern: wheels-mypyc-*
159+
merge-multiple: true
142160
path: dist-mypyc/
143161

144162
- name: Test standard wheel installation

0 commit comments

Comments
 (0)