Skip to content

Commit 8748dac

Browse files
committed
Try matplotlib style
1 parent c17a0cb commit 8748dac

File tree

2 files changed

+188
-6
lines changed

2 files changed

+188
-6
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Build
2+
# Current draft based on
3+
# https://github.com/matplotlib/matplotlib/blob/main/.github/workflows/cibuildwheel.yml
4+
5+
# TODO: only run on published releases
6+
# on:
7+
# release:
8+
# types: [published]
9+
on: [push]
10+
11+
jobs:
12+
build_wheels:
13+
name: Build wheels on ${{ matrix.os }} for ${{ matrix.cibw_archs }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# - os: ubuntu-latest
20+
# cibw_archs: "x86_64"
21+
# - os: ubuntu-24.04-arm
22+
# cibw_archs: "aarch64"
23+
- os: windows-latest
24+
cibw_archs: "AMD64"
25+
- os: windows-11-arm
26+
cibw_archs: "ARM64"
27+
# - os: macos-13
28+
# cibw_archs: "x86_64"
29+
# - os: macos-14
30+
# cibw_archs: "arm64"
31+
env:
32+
# CIBW_BEFORE_BUILD: >-
33+
# rm -rf {package}/build
34+
CIBW_BEFORE_BUILD_WINDOWS: >-
35+
pip install delvewheel
36+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
37+
delvewheel repair -w {dest_dir} {wheel}
38+
# TODO: switch to building based on locked src
39+
# and use tests-min-locked here
40+
CIBW_TEST_EXTRAS: >-
41+
tests-min
42+
CIBW_TEST_COMMAND: >-
43+
pytest {project}/tests
44+
# # On Windows, we explicitly request MSVC compilers (as GitHub Action runners have
45+
# # MinGW on PATH that would be picked otherwise), switch to a static build for
46+
# # runtimes, but use dynamic linking for `VCRUNTIME140.dll`, `VCRUNTIME140_1.dll`,
47+
# # and the UCRT. This avoids requiring specific versions of `MSVCP140.dll`, while
48+
# # keeping shared state with the rest of the Python process/extensions.
49+
# CIBW_CONFIG_SETTINGS_WINDOWS: >-
50+
# setup-args="--vsenv"
51+
# setup-args="-Db_vscrt=mt"
52+
# setup-args="-Dcpp_link_args=['ucrt.lib','vcruntime.lib','/nodefaultlib:libucrt.lib','/nodefaultlib:libvcruntime.lib']"
53+
# CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
54+
# CIBW_SKIP: "*-musllinux_aarch64"
55+
# CIBW_TEST_COMMAND: >-
56+
# python {package}/ci/check_version_number.py
57+
# MACOSX_DEPLOYMENT_TARGET: "10.12"
58+
59+
steps:
60+
- uses: actions/checkout@v5
61+
62+
- name: Build wheels for CPython 3.12
63+
uses: pypa/cibuildwheel@v3.1.4 # matplotlib had v3.1.3
64+
with:
65+
package-dir: .
66+
output-dir: wheelhouse
67+
config-file: "{package}/pyproject.toml"
68+
env:
69+
CIBW_BUILD: "cp312-*"
70+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
71+
72+
# - name: Setup Python
73+
# if: ${{ startsWith(matrix.os, 'windows') }}
74+
# uses: actions/setup-python@v5
75+
# with:
76+
# python-version: '3.x'
77+
#
78+
# # Maybe not necessary, source:
79+
# # https://dvdhrm.github.io/2021/04/21/meson-msvc-github-actions/
80+
# # and
81+
# # https://github.com/numpy/numpy/blob/71eebaf8513dfd6ed40b0c689702d81e3f6f2527/.github/workflows/wheels.yml#L123
82+
# - name: Setup MSVC developer shell (32-bit)
83+
# if: ${{ matrix.os == 'windows-2022' }}
84+
# uses: bus1/cabuild/action/msdevshell@v1
85+
# with:
86+
# architecture: x64
87+
#
88+
# - name: Install Fortran compiler
89+
# # When building from source, ensure we have a Fortran compiler
90+
# if: ${{ startsWith(matrix.os, 'macos') }}
91+
# uses: fortran-lang/setup-fortran@v1
92+
# id: setup-fortran
93+
# with:
94+
# # TODO: figure out whether we need/want to use other compilers too
95+
# compiler: "gcc"
96+
# version: "13"
97+
#
98+
# - name: Set macOS-13 specific flags
99+
# if: matrix.os == 'macos-13'
100+
# run: |
101+
# echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> "$GITHUB_ENV"
102+
#
103+
# - name: Set macOS-14 specific flags
104+
# if: matrix.os == 'macos-14'
105+
# run: |
106+
# echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> "$GITHUB_ENV"
107+
#
108+
# - name: Build wheels
109+
# uses: pypa/cibuildwheel@v3.1.4
110+
# # env:
111+
# # CIBW_SOME_OPTION: value
112+
# # ...
113+
# with:
114+
# package-dir: .
115+
# output-dir: wheelhouse
116+
# config-file: "{package}/pyproject.toml"
117+
118+
- uses: actions/upload-artifact@v4
119+
with:
120+
name: cibw-wheels-${{ matrix.os }}-${{ matrix.cibw_archs }}
121+
path: ./wheelhouse/*.whl
122+
if-no-files-found: error
123+
124+
# make-sdist:
125+
# name: Make source distribution
126+
# runs-on: "ubuntu-latest"
127+
#
128+
# steps:
129+
# - name: Check out repository
130+
# uses: actions/checkout@v4
131+
# with:
132+
# fetch-depth: 0
133+
#
134+
# - uses: ./.github/actions/setup
135+
# with:
136+
# python-version: ${{ matrix.python-version }}
137+
# uv-dependency-install-flags: "--all-extras --group dev"
138+
#
139+
# - name: Create source distribution
140+
# run: uv build --sdist
141+
#
142+
# - name: Upload the source distribution artefact
143+
# uses: actions/upload-artifact@v4
144+
# with:
145+
# name: cibw-sdist
146+
# path: dist/*.tar.gz
147+
148+
deploy-pypi:
149+
# TODO: turn back on
150+
# needs: [ build-wheels, make-sdist ]
151+
needs: [build-wheels]
152+
# Having an environment for deployment is strongly recommend by PyPI
153+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/#github-actions
154+
# You can comment this line out if you don't want it.
155+
# # TODO: turn back on when we only run this on main
156+
# environment: deploy
157+
# permissions:
158+
# # this permission is mandatory for trusted publishing with PyPI
159+
# id-token: write
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Download artefacts
163+
uses: actions/download-artifact@v5
164+
with:
165+
pattern: cibw-*
166+
path: dist
167+
merge-multiple: true
168+
- name: Publish to PyPI
169+
run: |
170+
ls dist
171+
# uv publish

pyproject.toml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,31 @@ all-dev = [
123123
[build-system]
124124
build-backend = "mesonpy"
125125
requires = [
126-
"meson-python>=0.15.0",
127-
"numpy",
126+
"meson-python>=0.15.0",
127+
# "numpy",
128+
"numpy>=1.26.0; python_version < '3.13'",
129+
"numpy>=2.1.0; python_version >= '3.13'",
128130
]
129131

130132
# https://mesonbuild.com/meson-python/how-to-guides/meson-args.html
131133
[tool.meson-python.args]
132134
setup = [
133-
'--default-library=static',
134-
'-Dpyprojectwheelbuild=enabled',
135-
]
135+
'--default-library=static',
136+
'-Dpyprojectwheelbuild=enabled',
137+
]
136138
install = [
137-
'--skip-subprojects',
139+
'--skip-subprojects',
138140
]
139141

142+
# See: https://github.com/matplotlib/matplotlib/blob/1ddb1eccac8cfc25dee47bc538dc5913384b253f/pyproject.toml#L89C1-L95C23
143+
# FIXME: Remove this override once dependencies are available on PyPI.
144+
[[tool.cibuildwheel.overrides]]
145+
select = "*-win_arm64"
146+
before-test = """\
147+
pip install --pre \
148+
--index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple \
149+
numpy"""
150+
140151
[tool.coverage.run]
141152
source = [
142153
"src",

0 commit comments

Comments
 (0)