Skip to content

Commit fc3eb74

Browse files
committed
chore: publication-ready package (README, CI, pre-commit, types, license)
2 parents 2b6fe79 + ca4ffb3 commit fc3eb74

15 files changed

Lines changed: 605 additions & 155 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
pull_request:
10+
11+
jobs:
12+
python-tests:
13+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
- macos-latest
21+
- windows-latest
22+
python-version:
23+
- "3.10"
24+
- "3.11"
25+
- "3.12"
26+
- "3.13"
27+
- "3.14"
28+
29+
steps:
30+
- name: Check out repository
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
38+
- name: Set up Rust
39+
uses: dtolnay/rust-toolchain@stable
40+
41+
- name: Cache Rust artifacts
42+
uses: Swatinem/rust-cache@v2
43+
44+
- name: Install test dependencies
45+
run: |
46+
python -m pip install --upgrade pip
47+
python -m pip install maturin pytest scipy
48+
49+
- name: Build extension in editable mode
50+
run: maturin develop
51+
52+
- name: Run test suite
53+
run: pytest -x -v
54+
55+
rust-checks:
56+
name: Rust checks
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Check out repository
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Rust
64+
uses: dtolnay/rust-toolchain@stable
65+
with:
66+
components: clippy, rustfmt
67+
68+
- name: Cache Rust artifacts
69+
uses: Swatinem/rust-cache@v2
70+
71+
- name: Run cargo tests
72+
run: cargo test --all-targets
73+
74+
- name: Run clippy
75+
run: cargo clippy --all-targets -- -D warnings
76+
77+
build-wheels:
78+
name: Build wheels on ${{ matrix.os }}
79+
if: startsWith(github.ref, 'refs/tags/v')
80+
runs-on: ${{ matrix.os }}
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
os:
85+
- ubuntu-latest
86+
- macos-latest
87+
- windows-latest
88+
89+
steps:
90+
- name: Check out repository
91+
uses: actions/checkout@v4
92+
93+
- name: Set up Python
94+
uses: actions/setup-python@v5
95+
with:
96+
python-version: "3.10"
97+
98+
- name: Build wheels
99+
uses: PyO3/maturin-action@v1
100+
with:
101+
command: build
102+
args: --release --out dist
103+
manylinux: auto
104+
sccache: "true"
105+
106+
- name: Upload wheel artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: wheels-${{ matrix.os }}
110+
path: dist
111+
112+
build-sdist:
113+
name: Build source distribution
114+
if: startsWith(github.ref, 'refs/tags/v')
115+
runs-on: ubuntu-latest
116+
117+
steps:
118+
- name: Check out repository
119+
uses: actions/checkout@v4
120+
121+
- name: Build sdist
122+
uses: PyO3/maturin-action@v1
123+
with:
124+
command: sdist
125+
args: --out dist
126+
127+
- name: Upload source distribution
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: sdist
131+
path: dist
132+
133+
publish:
134+
name: Publish to PyPI
135+
if: startsWith(github.ref, 'refs/tags/v')
136+
runs-on: ubuntu-latest
137+
needs:
138+
- build-wheels
139+
- build-sdist
140+
permissions:
141+
contents: read
142+
id-token: write
143+
144+
steps:
145+
- name: Download built artifacts
146+
uses: actions/download-artifact@v4
147+
with:
148+
path: dist
149+
merge-multiple: true
150+
151+
- name: Publish distributions
152+
uses: pypa/gh-action-pypi-publish@release/v1
153+
with:
154+
packages-dir: dist

‎.gitignore‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
target/
1+
.claude/
2+
.mypy_cache/
23
.venv
3-
*.so
4-
*.dylib
4+
/target/
55
__pycache__/
6-
.claude/
6+
*.dylib
7+
*.egg-info/
8+
*.pyc
9+
*.pyd
10+
*.so
11+
dist/

‎.pre-commit-config.yaml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-toml
9+
- id: check-merge-conflict
10+
- id: check-added-large-files
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.11.0
13+
hooks:
14+
- id: ruff
15+
args: [--fix, --unsafe-fixes]
16+
- id: ruff-format
17+
- repo: https://github.com/pre-commit/mirrors-mypy
18+
rev: v1.14.0
19+
hooks:
20+
- id: mypy
21+
additional_dependencies: [numpy]
22+
args: [--strict]
23+
- repo: local
24+
hooks:
25+
- id: cargo-fmt
26+
name: cargo fmt
27+
entry: cargo fmt --check
28+
language: system
29+
types: [rust]
30+
pass_filenames: false
31+
- id: cargo-clippy
32+
name: cargo clippy
33+
entry: cargo clippy -- -D warnings
34+
language: system
35+
types: [rust]
36+
pass_filenames: false

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"]
1717
criterion = "0.5"
1818

1919
[dependencies]
20-
pyo3 = { version = "0.23", features = ["extension-module", "abi3-py311"] }
20+
pyo3 = { version = "0.23", features = ["extension-module", "abi3-py310"] }
2121
numpy = "0.23"
2222
nalgebra = "0.33"
2323
thiserror = "2"

‎LICENSE‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) python-adaptive contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)