Skip to content

Commit f609187

Browse files
Decouple standalone binaries from Python: make pyo3 optional and fix build-binaries workflow
1 parent 4fc0df1 commit f609187

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/PyPI.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828
uses: PyO3/maturin-action@v1
2929
with:
3030
target: ${{ matrix.target }}
31-
args: --release --out dist --features extension-module
31+
# Maturin will use [tool.maturin.features = ["python"]] from pyproject.toml
32+
args: --release --out dist
3233
sccache: 'true'
3334
manylinux: auto
3435
- name: Upload wheels
@@ -63,6 +64,8 @@ jobs:
6364
target: aarch64-apple-darwin
6465
suffix: macos-aarch64
6566
binary_ext: ""
67+
env:
68+
PYO3_NO_PYTHON: 1 # Ensure pyo3-build-config doesn't look for Python
6669
steps:
6770
- uses: actions/checkout@v4
6871

@@ -161,4 +164,4 @@ jobs:
161164
uses: softprops/action-gh-release@v2
162165
with:
163166
files: assets/*
164-
generate_release_notes: true
167+
generate_release_notes: true

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ name = "fbtk-build"
2323
path = "src/bin/build.rs"
2424

2525
[dependencies]
26-
pyo3 = { version = "0.23", features = ["abi3-py38"] }
27-
numpy = "0.23"
26+
pyo3 = { version = "0.23", features = ["abi3-py38"], optional = true }
27+
numpy = { version = "0.23", optional = true }
2828
rayon = "1.10"
2929
anyhow = "1.0"
3030
serde = { version = "1.0", features = ["derive"] }
@@ -38,4 +38,5 @@ uff-relax = "1.0.0"
3838
glam = "0.31"
3939

4040
[features]
41+
python = ["pyo3", "numpy", "extension-module"]
4142
extension-module = ["pyo3/extension-module"]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ fbtk-build = "fbtk.cli:build"
2929

3030
[tool.maturin]
3131
module-name = "fbtk.fbtk"
32-
features = ["pyo3/abi3-py38"]
32+
features = ["python"]

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
pub mod core;
22
pub mod parsers;
3+
4+
#[cfg(feature = "python")]
35
pub mod python;
46

7+
#[cfg(feature = "python")]
58
use pyo3::prelude::*;
9+
#[cfg(feature = "python")]
610
use crate::python::{PyBuilder, PySystem, PyMolecule};
11+
#[cfg(feature = "python")]
712
use crate::python::functions::*;
813

14+
#[cfg(feature = "python")]
915
#[pymodule]
1016
fn fbtk(m: &Bound<'_, PyModule>) -> PyResult<()> {
1117
// Thread pool initialization

0 commit comments

Comments
 (0)