diff --git a/rust/fastsim-core/Cargo.toml b/rust/fastsim-core/Cargo.toml index 6de4075e..51d34798 100644 --- a/rust/fastsim-core/Cargo.toml +++ b/rust/fastsim-core/Cargo.toml @@ -59,7 +59,8 @@ full = [ "dep:argmin-math", "dep:curl", "dep:directories", - "dep:include_dir", "dep:polynomial", "dep:validator", + "resources", ] +resources = ["dep:include_dir"] diff --git a/rust/fastsim-core/fastsim-proc-macros/src/add_pyo3_api/mod.rs b/rust/fastsim-core/fastsim-proc-macros/src/add_pyo3_api/mod.rs index 26472417..ee679a59 100644 --- a/rust/fastsim-core/fastsim-proc-macros/src/add_pyo3_api/mod.rs +++ b/rust/fastsim-core/fastsim-proc-macros/src/add_pyo3_api/mod.rs @@ -213,7 +213,7 @@ pub fn add_pyo3_api(attr: TokenStream, item: TokenStream) -> TokenStream { /// /// * `filepath`: `str | pathlib.Path` - Filepath, relative to the top of the `resources` folder, from which to read the object /// - #[cfg(feature = "full")] + #[cfg(feature = "resources")] #[staticmethod] #[pyo3(name = "from_resource")] pub fn from_resource_py(filepath: &PyAny) -> anyhow::Result { diff --git a/rust/fastsim-core/src/lib.rs b/rust/fastsim-core/src/lib.rs index e6e6bd8d..6e47a2a1 100644 --- a/rust/fastsim-core/src/lib.rs +++ b/rust/fastsim-core/src/lib.rs @@ -53,3 +53,16 @@ pub mod vehicle_utils; pub use dev_proc_macros as proc_macros; #[cfg(not(feature = "dev-proc-macros"))] pub use fastsim_proc_macros as proc_macros; + +#[cfg_attr(feature = "pyo3", pyo3imports::pyfunction)] +pub fn enabled_features() -> Vec { + let mut enabled = Vec::new(); + + #[cfg(feature = "full")] + enabled.push("full".into()); + + #[cfg(feature = "resources")] + enabled.push("resources".into()); + + enabled +} diff --git a/rust/fastsim-core/src/resources.rs b/rust/fastsim-core/src/resources.rs index 9bdad25d..00fd59a6 100644 --- a/rust/fastsim-core/src/resources.rs +++ b/rust/fastsim-core/src/resources.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "full")] +#![cfg(feature = "resources")] use include_dir::{include_dir, Dir}; pub const RESOURCES_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/resources"); diff --git a/rust/fastsim-core/src/traits.rs b/rust/fastsim-core/src/traits.rs index c109415f..f08d31a6 100644 --- a/rust/fastsim-core/src/traits.rs +++ b/rust/fastsim-core/src/traits.rs @@ -15,7 +15,7 @@ pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { /// # Arguments: /// /// * `filepath` - Filepath, relative to the top of the `resources` folder, from which to read the object - #[cfg(feature = "full")] + #[cfg(feature = "resources")] fn from_resource>(filepath: P) -> anyhow::Result { let filepath = filepath.as_ref(); let extension = filepath diff --git a/rust/fastsim-py/src/lib.rs b/rust/fastsim-py/src/lib.rs index 4fa07a8e..0ba8ed5b 100644 --- a/rust/fastsim-py/src/lib.rs +++ b/rust/fastsim-py/src/lib.rs @@ -52,5 +52,7 @@ fn fastsimrust(py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(vehicle_utils::import_all_vehicles, m)?)?; m.add_function(wrap_pyfunction!(vehicle_utils::export_vehicle_to_file, m)?)?; + m.add_function(wrap_pyfunction!(enabled_features, m)?)?; + Ok(()) }