Skip to content

Commit 1728a51

Browse files
authored
Consolidate rust and python libraries (#17)
# Python ## 2.4.0 2025-06-13 ### Changed * Merge with rust library * Update type hints for symmetric bindings * Synchronize rust and python library versions # Rust ## 2.4.0 2025-06-13 ### Changed * Merge library with python bindings by adding `python` feature gate in front of bindings module * Synchronize rust and python library versions * Update license to MIT only for compatibility with combined Python library * Update release workflow to use cargo-semver-checks action directly
1 parent e1f7d43 commit 1728a51

30 files changed

+7655
-928
lines changed

.github/workflows/actions.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# maturin generate-ci github
55
#
6-
name: CI
6+
name: release_python
77

88
on:
99
push:
@@ -15,6 +15,10 @@ permissions:
1515
contents: read
1616

1717
jobs:
18+
19+
test:
20+
uses: ./.github/workflows/test_python.yml
21+
1822
linux:
1923
runs-on: ${{ matrix.platform.runner }}
2024
strategy:
@@ -42,7 +46,7 @@ jobs:
4246
uses: PyO3/maturin-action@v1
4347
with:
4448
target: ${{ matrix.platform.target }}
45-
args: --release --out dist --find-interpreter
49+
args: --release --out dist --find-interpreter --features=python
4650
sccache: 'true'
4751
manylinux: auto
4852
- name: Upload wheels
@@ -74,7 +78,7 @@ jobs:
7478
uses: PyO3/maturin-action@v1
7579
with:
7680
target: ${{ matrix.platform.target }}
77-
args: --release --out dist --find-interpreter
81+
args: --release --out dist --find-interpreter --features=python
7882
sccache: 'true'
7983
manylinux: musllinux_1_2
8084
- name: Upload wheels
@@ -103,7 +107,7 @@ jobs:
103107
uses: PyO3/maturin-action@v1
104108
with:
105109
target: ${{ matrix.platform.target }}
106-
args: --release --out dist --find-interpreter
110+
args: --release --out dist --find-interpreter --features=python
107111
sccache: 'true'
108112
- name: Upload wheels
109113
uses: actions/upload-artifact@v4
@@ -130,7 +134,7 @@ jobs:
130134
uses: PyO3/maturin-action@v1
131135
with:
132136
target: ${{ matrix.platform.target }}
133-
args: --release --out dist --find-interpreter
137+
args: --release --out dist --find-interpreter --features=python
134138
sccache: 'true'
135139
- name: Upload wheels
136140
uses: actions/upload-artifact@v4
@@ -157,7 +161,7 @@ jobs:
157161
name: Release
158162
runs-on: ubuntu-latest
159163
#if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160-
needs: [linux, musllinux, windows, macos, sdist]
164+
needs: [linux, musllinux, windows, macos, sdist, test]
161165
permissions:
162166
# Use to sign the release artifacts
163167
id-token: write

.github/workflows/release_rust.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: release_rust
2+
3+
permissions:
4+
pull-requests: write
5+
contents: write
6+
7+
on:
8+
push:
9+
branches:
10+
- release
11+
12+
jobs:
13+
14+
test:
15+
uses: ./.github/workflows/test_rust.yml
16+
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
needs: [test]
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Check semver
25+
uses: obi1kenobi/cargo-semver-checks-action@v2
26+
- name: Publish
27+
env:
28+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
29+
run: cargo publish

.github/workflows/test_python.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: test_python
5+
6+
on:
7+
# push: [] # Save time on actions
8+
pull_request: []
9+
workflow_dispatch:
10+
tag: "Manual Run"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-22.04
15+
timeout-minutes: 15
16+
strategy:
17+
matrix:
18+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
19+
20+
steps:
21+
22+
- uses: actions/checkout@v4
23+
24+
- name: Install Rust toolchain
25+
uses: dtolnay/rust-toolchain@stable
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Test
33+
run: |
34+
# Install with dev deps
35+
uv venv
36+
source .venv/bin/activate
37+
38+
uv pip install maturin
39+
# uv run --locked maturin develop --features=python
40+
uv pip install .[dev]
41+
42+
# Python lint, test, and coverage
43+
uv run --locked ruff check ./cfsem
44+
uv run --locked pyright ./cfsem --pythonversion 3.11
45+
uv run --locked coverage run --source=./cfsem -m pytest ./test/
46+
uv run --locked coverage report
47+
48+
# Build docs
49+
sh build_docs.sh

.github/workflows/test_rust.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: test_rust
2+
3+
on:
4+
pull_request:
5+
branches: [ "*" ]
6+
push:
7+
branches: [ "main", "develop", "release" ]
8+
workflow_call:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install Rust toolchain
21+
uses: dtolnay/rust-toolchain@stable
22+
- name: Format
23+
run: cargo fmt --check --verbose
24+
- name: Lint
25+
run: cargo clippy
26+
- name: Build
27+
run: cargo build --verbose
28+
- name: Run tests
29+
run: cargo test --verbose

CHANGELOG.md renamed to CHANGELOG_PYTHON.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 2.4.0 2025-06-13
4+
5+
### Changed
6+
7+
* Merge with rust library
8+
* Update type hints for symmetric bindings
9+
* Synchronize rust and python library versions
10+
311
## 2.3.1 2025-03-19
412

513
### Changed

CHANGELOG_RUST.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Changelog
2+
3+
## 2.4.0 2025-06-13
4+
5+
### Changed
6+
7+
* Merge library with python bindings by adding `python` feature gate in front of bindings module
8+
* Synchronize rust and python library versions
9+
* Update license to MIT only for compatibility with combined Python library
10+
* Update release workflow to use cargo-semver-checks action directly
11+
12+
## 2.0.0 2025-02-03
13+
14+
### Added
15+
16+
* Add libm dep for reproducible trig functions
17+
* Rust std/core defers to libc or other platform-dependent math libraries for trig functions, which can cause platform-dependent results
18+
* libm is a pure rust implementation of most functions from MUSL libm, and is platform-independent to the extent that the processor's implementation of floating point math conforms to IEEE-754
19+
* Add scalar calculations of vector potential, magnetic field, and poloidal flux of a circular filament extracted from vector loop
20+
* Scalar calculations now used as the inner function in the vector loops
21+
* This produces no performance regression, and some improvements in a few cases, while improving readability by separating physics from array handling
22+
* Add `mutual_inductance_circular_to_linear` family of functions for calculating mutual inductance between circular filaments and piecewise-linear paths
23+
* Add `flux_density_circular_filament_cartesian` family of functions for calculating B-field from circular filaments to points in cartesian coordinates
24+
* Add `cartesian_to_cylindrical` and `cylindrical_to_cartesian` conversion functions
25+
* Add `decompose_filament` function for converting the start and end points of a filament to the midpoint and length vector
26+
* Add `body_force_density_linear_filament` and `body_force_density_circular_filament_cartesian` families of functions for calculating JxB force density
27+
* Add `mesh_filament` module and `mesh_edge_inductance` function for calculating full inductance matrix over a collection of disjoint segments
28+
* Same throughput perf as linear filament inductance for a given input geometry, but allocates for the full NxM output matrix
29+
* doc(hidden) for now, as the API is likely to change in the near future to avoid reallocating input data
30+
* Add `point_source` module with dipole field
31+
* Add (internal) `testing` module with array-handling utilities for tests
32+
* Add (internal) macros for checking slice lengths
33+
34+
### Changed
35+
36+
* Use `Slice::fill(0.0)` instead of manually zeroing output arrays
37+
* Use macro for checking array lengths to reduce repeated code
38+
* !Consolidate function signatures of circular filament calcs to reduce number of args and group args by physical association
39+
40+
# Changelog
41+
42+
## 1.1.0 2024-08-20
43+
44+
### Added
45+
46+
* Add vector potential calcs for linear and circular filaments w/ parallel variants
47+
* Add parallel variants of circular filament flux and flux density calcs
48+
* Add tests of serial and parallel variants to make sure they produce the same result
49+
* Add tests of equivalence between flux/inductance, flux density, and vector potential calcs
50+
51+
### Changed
52+
53+
* Move Biot-Savart calcs to linear filament module and rename appropriately
54+
* Leave use-as references to prevent breaking change to API
55+
* Eliminate small allocations from parallel variant of Biot-Savart to reduce overhead when running with a large number of cores
56+
* 40%-100% speedup for small numbers of observation points
57+
* Defensively zero-out output slices
58+
* Convert some `#[inline(always)]` directives to plain `#[inline]`
59+
60+
## 1.0.0 2024-07-09
61+
62+
### Added
63+
64+
* Initial release

0 commit comments

Comments
 (0)