Skip to content

Commit eab162f

Browse files
Build wheels using general workflow
1 parent b64a39a commit eab162f

5 files changed

Lines changed: 162 additions & 281 deletions

File tree

.github/workflows/docker/buildwheel.sh

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

.github/workflows/docker/shared.env

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

.github/workflows/wheels.yml

Lines changed: 22 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -1,254 +1,41 @@
1-
name: Binary wheels
1+
name: Publish Python release
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- test
8-
tags:
9-
- '*'
5+
branches: [test-publish]
106
release:
117
types: [published]
128

139
jobs:
14-
OSX:
15-
name: Build ${{ matrix.os }} - ${{ matrix.python }}
16-
runs-on: ${{ matrix.os }}
17-
strategy:
18-
matrix:
19-
os: [macos-15-intel, macos-14, macos-15, macos-26]
20-
python: [3.11, 3.12, 3.13, 3.14]
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v6.0.2
24-
with:
25-
submodules: true
26-
- name: Set up Python ${{ matrix.python }}
27-
uses: actions/setup-python@v6.1.0
28-
with:
29-
python-version: ${{ matrix.python }}
30-
- name: Install deps
31-
run: |
32-
brew install gsl
33-
python -m pip install --upgrade pip build
34-
- name: Build Wheel (arm64)
35-
if: matrix.os != 'macos-15-intel'
36-
run: |
37-
export PLAT="arm64"
38-
export _PYTHON_HOST_PLATFORM="macosx-11.0-arm64"
39-
export CFLAGS+=" -arch arm64"
40-
export CXXFLAGS+=" -arch arm64"
41-
export ARCHFLAGS=$OLDARCHFLAGS
42-
export ARCHFLAGS+=" -arch arm64"
43-
export CPPFLAGS+=" -arch arm64"
44-
export LDFLAGS+=" -arch arm64"
45-
python -m build --wheel
46-
- name: Build Wheel (x86_64)
47-
if: matrix.os == 'macos-15-intel'
48-
run: |
49-
export PLAT="x86_64"
50-
export _PYTHON_HOST_PLATFORM="macosx-11.0-x86_64"
51-
export CFLAGS+=" -arch x86_64"
52-
export CXXFLAGS+=" -arch x86_64"
53-
export ARCHFLAGS=$OLDARCHFLAGS
54-
export ARCHFLAGS+=" -arch x86_64"
55-
export CPPFLAGS+=" -arch x86_64"
56-
export LDFLAGS+=" -arch x86_64"
57-
python -m build --wheel
58-
- name: Delocate to bundle dynamic libs
59-
run: |
60-
python -m pip install delocate
61-
delocate-wheel -v dist/*.whl
62-
- name: Upload Wheels
63-
uses: actions/upload-artifact@v6.0.0
64-
with:
65-
name: osx-wheel-${{ matrix.os }}-${{ matrix.python }}
66-
path: dist
67-
68-
Windows:
69-
name: Build Windows - ${{ matrix.python }}
70-
runs-on: windows-latest
71-
strategy:
72-
matrix:
73-
python: [3.11, 3.12, 3.13, 3.14]
74-
arch: [x64]
75-
steps:
76-
- name: Checkout
77-
uses: actions/checkout@v6.0.2
78-
with:
79-
submodules: true
80-
- name: Set up Python ${{ matrix.python }}
81-
uses: actions/setup-python@v6.1.0
82-
with:
83-
python-version: ${{ matrix.python }}
84-
architecture: ${{ matrix.arch }}
85-
- name: Install GSL via vcpkg
86-
run: |
87-
vcpkg install gsl:${{ matrix.arch }}-windows
88-
shell: cmd
89-
- name: Install deps
90-
run: |
91-
python -m pip install --upgrade pip build delvewheel
92-
- name: Fix windows symlinks
93-
run: |
94-
if (Test-Path "lwt_interface") { Remove-Item -Recurse -Force "lwt_interface" }
95-
Copy-Item -Recurse "git-submodules/tskit/python/lwt_interface" "./lwt_interface"
96-
shell: powershell
97-
- name: Build Wheel
98-
run: |
99-
# The symlink fix above confuses setuptools_scm
100-
$tag = git describe --tags --exact-match HEAD 2>$null
101-
if ($tag) {
102-
$env:SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MSPRIME = $tag
103-
}
104-
python -m build --wheel
105-
- name: Bundle dynamic libs
106-
run: |
107-
$vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT
108-
if (-not $vcpkgRoot) { $vcpkgRoot = "C:\vcpkg" }
109-
$gslBinPath = Join-Path $vcpkgRoot "installed\x64-windows\bin"
110-
$env:PATH = "$gslBinPath;$env:PATH"
111-
delvewheel repair dist/*.whl -w dist/ --add-path "$gslBinPath"
112-
shell: powershell
113-
- name: Upload Wheels
114-
uses: actions/upload-artifact@v6.0.0
115-
with:
116-
name: win-wheel-${{ matrix.python }}
117-
path: dist
118-
119-
manylinux:
120-
runs-on: ubuntu-24.04
121-
steps:
122-
- name: Checkout
123-
uses: actions/checkout@v6.0.2
124-
with:
125-
submodules: true
126-
- name: Set up Python 3.11
127-
uses: actions/setup-python@v6.1.0
128-
with:
129-
python-version: "3.11"
130-
- name: Build sdist
131-
shell: bash
132-
run: |
133-
python -m pip install --upgrade pip build
134-
python -m build --sdist
135-
- name: Upload sdist
136-
uses: actions/upload-artifact@v6.0.0
137-
with:
138-
name: sdist
139-
path: dist
140-
- name: Build wheels in docker
141-
shell: bash
142-
run: |
143-
docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash .github/workflows/docker/buildwheel.sh
144-
145-
- name: Upload Wheels
146-
uses: actions/upload-artifact@v6.0.0
147-
with:
148-
name: linux-wheels
149-
path: dist/wheelhouse
150-
151-
OSX-test:
152-
name: Test ${{ matrix.os }} - ${{ matrix.python }}
153-
needs: ['OSX']
154-
runs-on: ${{ matrix.os }}
155-
strategy:
156-
matrix:
157-
os: [macos-15-intel, macos-14, macos-15, macos-26]
158-
python: [3.11, 3.12, 3.13, 3.14]
159-
steps:
160-
- name: Download wheels
161-
uses: actions/download-artifact@v7.0.0
162-
with:
163-
name: osx-wheel-${{ matrix.os }}-${{ matrix.python }}
164-
- name: Set up Python ${{ matrix.python }}
165-
uses: actions/setup-python@v6.1.0
166-
with:
167-
python-version: ${{ matrix.python }}
168-
- name: Install wheel and test
169-
run: |
170-
python -VV
171-
# Install the local wheel
172-
python -m pip install numpy newick>=1.3.0 tskit>=0.5.2 demes>=0.2
173-
python -m pip install msprime --no-index --only-binary msprime -f .
174-
python -c "import msprime"
175-
msp simulate 10 tmp.trees
176-
tskit info tmp.trees
177-
tskit provenances tmp.trees
10+
build-wheels:
11+
uses: tskit-dev/.github/.github/workflows/build-wheels.yml@main
12+
# with:
13+
# os-list: '["windows-2025"]' #, "ubuntu-24.04"]'
17814

179-
manylinux-test:
180-
runs-on: ubuntu-24.04
181-
needs: ['manylinux']
182-
strategy:
183-
matrix:
184-
python: [3.11, 3.12, 3.13, 3.14]
185-
steps:
186-
- name: Download wheels
187-
uses: actions/download-artifact@v7.0.0
188-
with:
189-
name: linux-wheels
190-
- name: Set up Python
191-
uses: actions/setup-python@v6.1.0
192-
with:
193-
python-version: ${{ matrix.python }}
194-
- name: Install wheel and test
195-
run: |
196-
python -VV
197-
# Install the local wheel
198-
python -m pip install numpy newick demes
199-
python -m pip install --no-dependencies msprime --no-index --only-binary msprime -f .
200-
python -m pip install tskit
201-
python -c "import msprime"
202-
msp simulate 10 tmp.trees
203-
tskit info tmp.trees
204-
tskit provenances tmp.trees
205-
206-
207-
Windows-test:
208-
runs-on: windows-latest
209-
needs: ['Windows']
210-
strategy:
211-
matrix:
212-
python: [3.11, 3.12, 3.13, 3.14]
213-
steps:
214-
- name: Download wheels
215-
uses: actions/download-artifact@v7.0.0
216-
with:
217-
name: win-wheel-${{ matrix.python }}
218-
- name: Set up Python ${{ matrix.python }}
219-
uses: actions/setup-python@v6.1.0
220-
with:
221-
python-version: ${{ matrix.python }}
222-
- name: Install wheel and test
223-
run: |
224-
python -VV
225-
python -m pip install numpy newick>=1.3.0 tskit>=0.5.2 demes>=0.2
226-
python -m pip install msprime --no-index --only-binary msprime -f .
227-
python -c "import msprime"
228-
msp simulate 10 tmp.trees
229-
tskit info tmp.trees
230-
tskit provenances tmp.trees
231-
232-
PyPI_Upload:
15+
publish:
23316
runs-on: ubuntu-24.04
23417
environment: release
235-
needs: ['OSX-test', 'manylinux-test', 'Windows-test']
18+
needs: [ 'build-wheels' ]
23619
permissions:
23720
id-token: write
23821
steps:
239-
- name: Download all
22+
- name: Download artifacts
24023
uses: actions/download-artifact@v7.0.0
241-
- name: Move to dist
242-
run: |
243-
mkdir dist
244-
cp */*.{whl,gz} dist/.
245-
# Windows wheels have different naming pattern
246-
if [ -d "win-wheel"* ]; then cp win-wheel*/*.whl dist/. || true; fi
24+
with:
25+
pattern: build-*
26+
path: dist
27+
merge-multiple: true
28+
29+
- name: Show artifacts
30+
run: ls -lah dist
31+
24732
- name: Publish distribution to Test PyPI
248-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
33+
if: github.event_name == 'push' && github.ref_name == 'test-publish'
24934
uses: pypa/gh-action-pypi-publish@v1.13.0
25035
with:
251-
repository_url: https://test.pypi.org/legacy/
252-
- name: Publish distribution to PRODUCTION PyPI
36+
repository-url: https://test.pypi.org/legacy/
37+
verbose: true
38+
39+
- name: Publish distribution to Production PyPI
25340
if: github.event_name == 'release'
25441
uses: pypa/gh-action-pypi-publish@v1.13.0

pyproject.toml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ include-package-data = true
6666

6767
[tool.setuptools_scm]
6868
write_to = "msprime/_version.py"
69+
local_scheme = "no-local-version"
6970

7071
[dependency-groups]
7172
test = [
@@ -105,6 +106,10 @@ lint = [
105106
"prek==0.3.3",
106107
]
107108

109+
wheels = [
110+
"cibuildwheel",
111+
]
112+
108113
dev = [
109114
{include-group = "docs"},
110115
{include-group = "lint"},
@@ -135,7 +140,6 @@ filterwarnings = [
135140
]
136141

137142
[tool.ruff]
138-
# Assume Python 3.11
139143
target-version = "py311"
140144

141145
line-length = 89
@@ -170,3 +174,29 @@ known-third-party = [
170174
"numpy",
171175
"pytest",
172176
]
177+
178+
[tool.cibuildwheel]
179+
build = ["cp311-*", "cp312-*", "cp313-*", "cp314-*"]
180+
build-frontend = "build"
181+
build-verbosity = 3
182+
test-command = [
183+
"python -c \"import msprime._msprime\"",
184+
"msp --help",
185+
]
186+
187+
[tool.cibuildwheel.linux]
188+
archs = ["x86_64"]
189+
before-all = ["yum -y install gsl-devel"]
190+
skip = ["*musllinux*"]
191+
192+
[tool.cibuildwheel.macos]
193+
archs = ["x86_64", "arm64"]
194+
before-all = ["brew install gsl"]
195+
# This is because of how GSL is built by homebrew.
196+
environment = { MACOSX_DEPLOYMENT_TARGET = "14.0" }
197+
198+
[tool.cibuildwheel.windows]
199+
archs = ["AMD64"]
200+
before-all = ["vcpkg install gsl:x64-windows"]
201+
before-build = "pip install delvewheel"
202+
repair-wheel-command = "delvewheel repair --add-path C:\\vcpkg\\installed\\x64-windows\\bin -w {dest_dir} {wheel}"

0 commit comments

Comments
 (0)