Skip to content

Commit

Permalink
cfg_if
Browse files Browse the repository at this point in the history
  • Loading branch information
smartgoo committed Sep 14, 2024
1 parent 6d84f6d commit be1b916
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 119 deletions.
111 changes: 2 additions & 109 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions x-python/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
5 changes: 3 additions & 2 deletions x-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ kaspa-wallet-core.workspace = true
kaspa-wallet-keys.workspace = true
kaspad.workspace = true

cfg-if.workspace = true
chrono = "0.4"
csv = "1.2"
dirs = "4.0"
itertools.workspace = true
serde.workspace = true
pyo3 = { version = "0.20.0", features = ["extension-module"] }
pyo3 = { optional = true, version = "0.20.0", features = ["extension-module"] }

[features]
py-sdk = []
py-sdk = ["pyo3"]
22 changes: 14 additions & 8 deletions x-python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
mod converters;
mod core;
mod stores;
use cfg_if::cfg_if;

use pyo3::prelude::*;
cfg_if! {
if #[cfg(feature = "py-sdk")] {
mod converters;
mod core;
mod stores;

#[pymodule]
fn kaspadbr(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<core::db_reader::DBReader>()?;
use pyo3::prelude::*;

Ok(())
#[pymodule]
fn kaspadbr(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<core::db_reader::DBReader>()?;

Ok(())
}
}
}

0 comments on commit be1b916

Please sign in to comment.