diff --git a/Cargo.lock b/Cargo.lock index 1b75ac625..097ee160c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4095,15 +4095,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" -dependencies = [ - "autocfg", -] - [[package]] name = "mimalloc" version = "0.1.43" @@ -4911,69 +4902,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "pyo3" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" -dependencies = [ - "cfg-if 1.0.0", - "indoc", - "libc", - "memoffset", - "parking_lot", - "portable-atomic", - "pyo3-build-config", - "pyo3-ffi", - "pyo3-macros", - "unindent", -] - -[[package]] -name = "pyo3-build-config" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" -dependencies = [ - "once_cell", - "target-lexicon", -] - -[[package]] -name = "pyo3-ffi" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" -dependencies = [ - "libc", - "pyo3-build-config", -] - -[[package]] -name = "pyo3-macros" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" -dependencies = [ - "proc-macro2", - "pyo3-macros-backend", - "quote", - "syn 2.0.60", -] - -[[package]] -name = "pyo3-macros-backend" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" -dependencies = [ - "heck 0.4.1", - "proc-macro2", - "pyo3-build-config", - "quote", - "syn 2.0.60", -] - [[package]] name = "quote" version = "1.0.37" @@ -5901,12 +5829,6 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" -[[package]] -name = "target-lexicon" -version = "0.12.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" - [[package]] name = "tempfile" version = "3.12.0" @@ -6395,12 +6317,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" -[[package]] -name = "unindent" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" - [[package]] name = "universal-hash" version = "0.5.1" @@ -6985,7 +6901,7 @@ dependencies = [ "bs58", "cfg-if 1.0.0", "chrono", - "dirs 5.0.1 5.0.1", + "dirs 5.0.1", "faster-hex", "futures", "getrandom 0.2.15", @@ -7379,6 +7295,7 @@ dependencies = [ name = "x-python" version = "0.15.1" dependencies = [ + "cfg-if 1.0.0", "chrono", "csv", "dirs 4.0.0", @@ -7399,30 +7316,6 @@ dependencies = [ "serde", ] -[[package]] -name = "x-python" -version = "0.14.1" -dependencies = [ - "chrono", - "csv", - "dirs 4.0.0", - "itertools 0.11.0", - "kaspa-addresses", - "kaspa-bip32", - "kaspa-consensus", - "kaspa-consensus-core", - "kaspa-database", - "kaspa-hashes", - "kaspa-math", - "kaspa-txscript", - "kaspa-utxoindex", - "kaspa-wallet-core", - "kaspa-wallet-keys", - "kaspad", - "pyo3", - "serde", -] - [[package]] name = "xml-rs" version = "0.8.22" diff --git a/x-python/.cargo/config.toml b/x-python/.cargo/config.toml new file mode 100644 index 000000000..59c989e69 --- /dev/null +++ b/x-python/.cargo/config.toml @@ -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", +] \ No newline at end of file diff --git a/x-python/Cargo.toml b/x-python/Cargo.toml index 1e849bd53..95d2bba78 100644 --- a/x-python/Cargo.toml +++ b/x-python/Cargo.toml @@ -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 = [] \ No newline at end of file +py-sdk = ["pyo3"] \ No newline at end of file diff --git a/x-python/src/lib.rs b/x-python/src/lib.rs index ac3eb4b0d..f7bbc0603 100644 --- a/x-python/src/lib.rs +++ b/x-python/src/lib.rs @@ -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::()?; + use pyo3::prelude::*; - Ok(()) + #[pymodule] + fn kaspadbr(_py: Python<'_>, m: &PyModule) -> PyResult<()> { + m.add_class::()?; + + Ok(()) + } + } } \ No newline at end of file