Skip to content

Commit d93454f

Browse files
authored
Merge pull request #53 from CovertLab/numpy2
Update Build Toolchain
2 parents fabb713 + 5fc79db commit d93454f

39 files changed

Lines changed: 244 additions & 125 deletions

.github/workflows/release.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
push:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
# Build the wheels for Linux, Windows and macOS for Python 3.9 and newer
11+
build_wheels:
12+
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
# Ensure that a wheel builder finishes even if another fails
16+
fail-fast: false
17+
matrix:
18+
include:
19+
# Window 64 bit
20+
- os: windows-latest
21+
python: 39
22+
platform_id: win_amd64
23+
- os: windows-latest
24+
python: 310
25+
platform_id: win_amd64
26+
- os: windows-latest
27+
python: 311
28+
platform_id: win_amd64
29+
- os: windows-latest
30+
python: 312
31+
platform_id: win_amd64
32+
- os: windows-latest
33+
python: 313
34+
platform_id: win_amd64
35+
- os: windows-latest
36+
python: 313t
37+
platform_id: win_amd64
38+
free_threaded_support: True
39+
40+
# Linux 64 bit manylinux2014
41+
- os: ubuntu-latest
42+
python: 39
43+
platform_id: manylinux_x86_64
44+
- os: ubuntu-latest
45+
python: 310
46+
platform_id: manylinux_x86_64
47+
- os: ubuntu-latest
48+
python: 311
49+
platform_id: manylinux_x86_64
50+
- os: ubuntu-latest
51+
python: 312
52+
platform_id: manylinux_x86_64
53+
- os: ubuntu-latest
54+
python: 313
55+
platform_id: manylinux_x86_64
56+
- os: ubuntu-latest
57+
python: 313t
58+
platform_id: manylinux_x86_64
59+
free_threaded_support: True
60+
61+
# MacOS x86_64
62+
- os: macos-13
63+
python: 39
64+
platform_id: macosx_x86_64
65+
- os: macos-13
66+
python: 310
67+
platform_id: macosx_x86_64
68+
- os: macos-13
69+
python: 311
70+
platform_id: macosx_x86_64
71+
- os: macos-13
72+
python: 312
73+
platform_id: macosx_x86_64
74+
- os: macos-13
75+
python: 313
76+
platform_id: macosx_x86_64
77+
- os: macos-13
78+
python: 313t
79+
platform_id: macosx_x86_64
80+
free_threaded_support: True
81+
82+
# MacOS arm64
83+
- os: macos-14
84+
python: 39
85+
platform_id: macosx_arm64
86+
- os: macos-14
87+
python: 310
88+
platform_id: macosx_arm64
89+
- os: macos-14
90+
python: 311
91+
platform_id: macosx_arm64
92+
- os: macos-14
93+
python: 312
94+
platform_id: macosx_arm64
95+
- os: macos-14
96+
python: 313
97+
platform_id: macosx_arm64
98+
- os: macos-14
99+
python: 313t
100+
platform_id: macosx_arm64
101+
free_threaded_support: True
102+
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- name: Build wheels
107+
env:
108+
CIBW_FREE_THREADED_SUPPORT: ${{ matrix.free_threaded_support }}
109+
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
110+
CIBW_TEST_REQUIRES: pytest psutil
111+
CIBW_TEST_COMMAND: pytest -v {project}/test
112+
CIBW_ENVIRONMENT: USE_CYTHON=1
113+
uses: pypa/cibuildwheel@v2.22.0
114+
115+
- uses: actions/upload-artifact@v4
116+
with:
117+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
118+
path: ./wheelhouse/*.whl
119+
120+
build_sdist:
121+
name: Build source distribution
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- name: Build sdist
127+
run: pipx run build --sdist
128+
129+
- uses: actions/upload-artifact@v4
130+
with:
131+
name: cibw-sdist
132+
path: dist/*.tar.gz
133+
134+
upload_pypi:
135+
needs: [build_wheels, build_sdist]
136+
runs-on: ubuntu-latest
137+
environment:
138+
name: pypi
139+
url: https://pypi.org/p/stochastic-arrow
140+
permissions:
141+
id-token: write
142+
if: github.event_name == 'release' && github.event.action == 'published'
143+
steps:
144+
- uses: actions/download-artifact@v4
145+
with:
146+
# unpacks all CIBW artifacts into dist/
147+
pattern: cibw-*
148+
path: dist
149+
merge-multiple: true
150+
151+
- uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ profile
1010
/.idea/
1111
/tmp/
1212

13-
stochastic_arrow/arrowhead.c
14-
stochastic_arrow/arrowhead.*.pyd
15-
stochastic_arrow/*.html
13+
src/stochastic_arrow/arrowhead.c
14+
src/stochastic_arrow/arrowhead.*.pyd
15+
src/stochastic_arrow/*.html
1616

1717
arrow.egg-info/
1818
stochastic_arrow.egg-info/

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
include stochastic_arrow/obsidian.h
2-
include stochastic_arrow/mersenne.h
1+
include src/stochastic_arrow/obsidian.h
2+
include src/stochastic_arrow/mersenne.h

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
.DEFAULT_GOAL := compile
33

44
clean:
5-
### Files for older versions of stochastic_arrow are in arrow folder
5+
### Files for older versions of stochastic_arrow are in arrow or stochastic_arrow folder
66
rm -rf arrow/arrowhead*.so arrow/arrowhead.c arrow/arrowhead.html
77
rm -rf stochastic_arrow/arrowhead*.so stochastic_arrow/arrowhead.c stochastic_arrow/arrowhead.html build/ dist/ MANIFEST .pytest_cache/ stochastic_arrow.egg-info/
8+
### Newer versions of stochastic_arrow are in src/stochastic_arrow folder
9+
rm -rf src/stochastic_arrow/arrowhead*.so src/stochastic_arrow/arrowhead.c src/stochastic_arrow/arrowhead.html src/stochastic_arrow.egg-info/
810
find . -name "*.pyc" -delete
911
find . -name "__pycache__" -delete
1012

1113
compile:
12-
USE_CYTHON=1 python setup.py build_ext --inplace
14+
USE_CYTHON=1 python -m pip install -e .
15+
16+
test: clean compile
17+
pytest test
1318

1419
dist:
15-
### bdist_wheel is disabled on linux since the distribution machinery doesn't
16-
### yet have a way to specify compatible linux distros.
17-
USE_CYTHON=1 python setup.py sdist # bdist_wheel
20+
USE_CYTHON=1 python -m build --sdist

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,37 +91,53 @@ from stochastic_arrow import reenact_events
9191
history = reenact_events(stoichiometric_matrix, result['events'], state)
9292
```
9393

94-
## Testing
95-
96-
`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/). To test it:
94+
## Building
9795

9896
> make clean compile
99-
> pytest
97+
98+
This builds the extension package and installs it in editable mode.
10099

101100
**NOTE:** `make compile` without an explicit `clean` might not fully build the extension.
102101

103-
There are more command line features in test_arrow:
102+
## Testing
103+
104+
`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/).
105+
To run the main tests, in the source tree:
104106

105-
> python -m stochastic_arrow.test.test_arrow --complexation
107+
> make test
106108

107-
> python -m stochastic_arrow.test.test_arrow --plot
109+
or
108110

109-
> python -m stochastic_arrow.test.test_arrow --obsidian
111+
> pytest
110112

111-
> python -m stochastic_arrow.test.test_arrow --memory
113+
There are additional command line features in test_arrow:
112114

113-
> python -m stochastic_arrow.test.test_arrow --time
115+
> python -m test.test_arrow --help
116+
> python -m test.test_arrow --complexation
117+
> python -m test.test_arrow --complexation --runs 3
118+
> python -m test.test_arrow --obsidian
119+
> python -m test.test_arrow --memory
120+
> python -m test.test_arrow --time
121+
> python -m test.test_arrow --pickle
122+
> python -m test.test_arrow --test-fail-flagella
123+
> python -m test.test_arrow --test-fail-stdout
124+
> python -m test.test_hang
114125

115-
More examples:
126+
This test requires installing a version of matplotlib that's compatible with the installed numpy:
116127

117-
> python -m stochastic_arrow.test.test_hang
128+
> python -m test.test_arrow --plot
118129

119-
> pytest -m stochastic_arrow/test/test_arrow.py
130+
More examples:
120131

121132
> pytest -k flagella
122133

123134
## Changelog
124135

136+
### Version 1.1.0
137+
* Update build toolchain and automatically build/publish wheels for all
138+
major platforms and recent Python versions.
139+
* Build wheels with Numpy 2+ support
140+
125141
### Version 1.0.0
126142

127143
* Rename module to `stochastic_arrow` to avoid name conflict (Issue #51). **All users must update their import statements to use `stochastic_arrow` instead of `arrow`.**

optional_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
matplotlib==2.2.3
1+
matplotlib

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "cython==3.1.0a1; python_version=='3.13'", "cython; python_version!='3.13'", "numpy"]
3+
build-backend = "setuptools.build_meta"

release.sh

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

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
pip
44
setuptools
5+
build
56

67
Cython>=0.29.34
78
numpy

0 commit comments

Comments
 (0)