Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Build and upload to PyPI

on:
push:
release:
types:
- published

jobs:
# Build the wheels for Linux, Windows and macOS for Python 3.9 and newer
build_wheels:
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}
runs-on: ${{ matrix.os }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
include:
# Window 64 bit
- os: windows-latest
python: 39
platform_id: win_amd64
- os: windows-latest
python: 310
platform_id: win_amd64
- os: windows-latest
python: 311
platform_id: win_amd64
- os: windows-latest
python: 312
platform_id: win_amd64
- os: windows-latest
python: 313
platform_id: win_amd64
- os: windows-latest
python: 313t
platform_id: win_amd64
free_threaded_support: True

# Linux 64 bit manylinux2014
- os: ubuntu-latest
python: 39
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 310
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 311
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 312
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 313
platform_id: manylinux_x86_64
- os: ubuntu-latest
python: 313t
platform_id: manylinux_x86_64
free_threaded_support: True

# MacOS x86_64
- os: macos-13
python: 39
platform_id: macosx_x86_64
- os: macos-13
python: 310
platform_id: macosx_x86_64
- os: macos-13
python: 311
platform_id: macosx_x86_64
- os: macos-13
python: 312
platform_id: macosx_x86_64
- os: macos-13
python: 313
platform_id: macosx_x86_64
- os: macos-13
python: 313t
platform_id: macosx_x86_64
free_threaded_support: True

# MacOS arm64
- os: macos-14
python: 39
platform_id: macosx_arm64
- os: macos-14
python: 310
platform_id: macosx_arm64
- os: macos-14
python: 311
platform_id: macosx_arm64
- os: macos-14
python: 312
platform_id: macosx_arm64
- os: macos-14
python: 313
platform_id: macosx_arm64
- os: macos-14
python: 313t
platform_id: macosx_arm64
free_threaded_support: True

steps:
- uses: actions/checkout@v4

- name: Build wheels
env:
CIBW_FREE_THREADED_SUPPORT: ${{ matrix.free_threaded_support }}
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_TEST_REQUIRES: pytest psutil
CIBW_TEST_COMMAND: pytest -v {project}/test
CIBW_ENVIRONMENT: USE_CYTHON=1
uses: pypa/cibuildwheel@v2.22.0

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/stochastic-arrow
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ profile
/.idea/
/tmp/

stochastic_arrow/arrowhead.c
stochastic_arrow/arrowhead.*.pyd
stochastic_arrow/*.html
src/stochastic_arrow/arrowhead.c
src/stochastic_arrow/arrowhead.*.pyd
src/stochastic_arrow/*.html

arrow.egg-info/
stochastic_arrow.egg-info/
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include stochastic_arrow/obsidian.h
include stochastic_arrow/mersenne.h
include src/stochastic_arrow/obsidian.h
include src/stochastic_arrow/mersenne.h
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
.DEFAULT_GOAL := compile

clean:
### Files for older versions of stochastic_arrow are in arrow folder
### Files for older versions of stochastic_arrow are in arrow or stochastic_arrow folder
rm -rf arrow/arrowhead*.so arrow/arrowhead.c arrow/arrowhead.html
rm -rf stochastic_arrow/arrowhead*.so stochastic_arrow/arrowhead.c stochastic_arrow/arrowhead.html build/ dist/ MANIFEST .pytest_cache/ stochastic_arrow.egg-info/
### Newer versions of stochastic_arrow are in src/stochastic_arrow folder
rm -rf src/stochastic_arrow/arrowhead*.so src/stochastic_arrow/arrowhead.c src/stochastic_arrow/arrowhead.html src/stochastic_arrow.egg-info/
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete

compile:
USE_CYTHON=1 python setup.py build_ext --inplace
USE_CYTHON=1 python -m pip install -e .

test: clean compile
pytest test

dist:
### bdist_wheel is disabled on linux since the distribution machinery doesn't
### yet have a way to specify compatible linux distros.
USE_CYTHON=1 python setup.py sdist # bdist_wheel
USE_CYTHON=1 python -m build --sdist
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,53 @@ from stochastic_arrow import reenact_events
history = reenact_events(stoichiometric_matrix, result['events'], state)
```

## Testing

`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/). To test it:
## Building

> make clean compile
> pytest

This builds the extension package and installs it in editable mode.

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

There are more command line features in test_arrow:
## Testing

`stochastic_arrow` uses [pytest](https://docs.pytest.org/en/latest/).
To run the main tests, in the source tree:

> python -m stochastic_arrow.test.test_arrow --complexation
> make test

> python -m stochastic_arrow.test.test_arrow --plot
or

> python -m stochastic_arrow.test.test_arrow --obsidian
> pytest

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

> python -m stochastic_arrow.test.test_arrow --time
> python -m test.test_arrow --help
> python -m test.test_arrow --complexation
> python -m test.test_arrow --complexation --runs 3
> python -m test.test_arrow --obsidian
> python -m test.test_arrow --memory
> python -m test.test_arrow --time
> python -m test.test_arrow --pickle
> python -m test.test_arrow --test-fail-flagella
> python -m test.test_arrow --test-fail-stdout
> python -m test.test_hang

More examples:
This test requires installing a version of matplotlib that's compatible with the installed numpy:

> python -m stochastic_arrow.test.test_hang
> python -m test.test_arrow --plot

> pytest -m stochastic_arrow/test/test_arrow.py
More examples:

> pytest -k flagella

## Changelog

### Version 1.1.0
* Update build toolchain and automatically build/publish wheels for all
major platforms and recent Python versions.
* Build wheels with Numpy 2+ support

### Version 1.0.0

* 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`.**
Expand Down
2 changes: 1 addition & 1 deletion optional_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
matplotlib==2.2.3
matplotlib
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "cython==3.1.0a1; python_version=='3.13'", "cython; python_version!='3.13'", "numpy"]
build-backend = "setuptools.build_meta"
50 changes: 0 additions & 50 deletions release.sh

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pip
setuptools
build

Cython>=0.29.34
numpy
Expand Down
Loading
Loading