Skip to content

Commit

Permalink
Merge branch 'feature/full-feature-for-dependency-reduction' of githu…
Browse files Browse the repository at this point in the history
…b.com:NREL/fastsim into feature/full-feature-for-dependency-reduction
  • Loading branch information
calbaker committed Jan 29, 2024
2 parents a409478 + 3e86c64 commit 777843b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rust/fastsim-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ full = [
"dep:argmin-math",
"dep:curl",
"dep:directories",
"dep:include_dir",
"dep:polynomial",
"dep:validator",
"resources",
]
resources = ["dep:include_dir"]
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
Expand Down
13 changes: 13 additions & 0 deletions rust/fastsim-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
let mut enabled = Vec::new();

#[cfg(feature = "full")]
enabled.push("full".into());

#[cfg(feature = "resources")]
enabled.push("resources".into());

enabled
}
2 changes: 1 addition & 1 deletion rust/fastsim-core/src/resources.rs
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion rust/fastsim-core/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: AsRef<Path>>(filepath: P) -> anyhow::Result<Self> {
let filepath = filepath.as_ref();
let extension = filepath
Expand Down
2 changes: 2 additions & 0 deletions rust/fastsim-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 777843b

Please sign in to comment.