Skip to content

Commit

Permalink
Disable compilation of bindings with test feature
Browse files Browse the repository at this point in the history
The bindings module does not play nicely with
cargo test. Fortunatley, it's functionality
is tested with pytest, and the module is not
required when testing the core module.

The test suite can now be ran with:
`cargo test --features "test"`

Workaround for: PyO3/pyo3#340 which allows for doctests.
Source of workaround: rust-lang/rust#45599
  • Loading branch information
Gustav Gränsbo committed Dec 30, 2020
1 parent e1f116d commit 041d239
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ crate-type = ["rlib", "cdylib"]
csv = "1.1"
pyo3 = {version = "0.12.4", features = ["extension-module"]}

[features]
test = []

[package.metadata.maturin]
requires-python = ">=3.7"
requires-dist = ["importlib_metadata==3.3.0;python_version<\"3.8\""]
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
pub mod bindings;
pub mod core;

// Don't create bindings when running with test feature.
// Workaround for https://github.com/PyO3/pyo3/issues/340 which allows for doctests.
// Source of workaround: https://github.com/rust-lang/rust/issues/45599
#[cfg(not(feature = "test"))]
pub mod bindings;

0 comments on commit 041d239

Please sign in to comment.