diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml index 8ea148e..21fa072 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build_wheels.yml @@ -21,6 +21,7 @@ jobs: 3.10 3.11 3.12 + 3.13 - name: Setup Nuget.exe uses: nuget/setup-nuget@v1 with: diff --git a/Cargo.lock b/Cargo.lock index a360a90..199f16b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -237,9 +237,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -321,16 +321,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" -[[package]] -name = "lock_api" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.21" @@ -409,29 +399,6 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys 0.36.1", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -452,24 +419,23 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.20.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a" dependencies = [ - "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -479,9 +445,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598" dependencies = [ "once_cell", "target-lexicon", @@ -489,9 +455,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c" dependencies = [ "libc", "pyo3-build-config", @@ -499,27 +465,27 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.48", + "syn 2.0.106", ] [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc" dependencies = [ "heck", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.48", + "syn 2.0.106", ] [[package]] @@ -531,15 +497,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "regex" version = "1.10.3" @@ -614,12 +571,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "sharded-slab" version = "0.1.4" @@ -635,12 +586,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - [[package]] name = "strsim" version = "0.10.0" @@ -660,9 +605,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" dependencies = [ "proc-macro2", "quote", @@ -671,9 +616,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.4" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "termcolor" @@ -701,7 +646,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.106", ] [[package]] @@ -833,19 +778,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -906,12 +838,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - [[package]] name = "windows_aarch64_msvc" version = "0.42.1" @@ -924,12 +850,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - [[package]] name = "windows_i686_gnu" version = "0.42.1" @@ -942,12 +862,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - [[package]] name = "windows_i686_msvc" version = "0.42.1" @@ -960,12 +874,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - [[package]] name = "windows_x86_64_gnu" version = "0.42.1" @@ -990,12 +898,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "windows_x86_64_msvc" version = "0.42.1" diff --git a/yari-py/Cargo.toml b/yari-py/Cargo.toml index e2b4b8d..1fb1c6e 100644 --- a/yari-py/Cargo.toml +++ b/yari-py/Cargo.toml @@ -11,5 +11,5 @@ name = "yari" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.20.3", features = ["extension-module"] } +pyo3 = { version = "0.25.1", features = ["extension-module"] } yari-sys = { path = "../yari-sys" } diff --git a/yari-py/pyproject.toml b/yari-py/pyproject.toml index 714b68d..2450896 100644 --- a/yari-py/pyproject.toml +++ b/yari-py/pyproject.toml @@ -5,6 +5,7 @@ build-backend = "maturin" [project] name = "yari-py" requires-python = ">=3.7" +dynamic = ["version"] classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", diff --git a/yari-py/src/lib.rs b/yari-py/src/lib.rs index 875626b..0931b18 100644 --- a/yari-py/src/lib.rs +++ b/yari-py/src/lib.rs @@ -3,6 +3,7 @@ use pyo3::exceptions::PyException; use pyo3::prelude::*; use pyo3::types::PyDict; use pyo3::types::PyString; +use pyo3::Bound; use std::collections::HashMap; use std::path::PathBuf; use std::str::FromStr; @@ -27,19 +28,19 @@ struct Context { /// Same applies to structures and dictionaries. fn yr_value_to_py_object(py: Python<'_>, yr_value: &YrValue) -> PyObject { match yr_value { - YrValue::Integer(i) => i.into_py(py), - YrValue::Float(f) => f.into_py(py), - YrValue::String(s) => s.as_ref().into_py(py), + YrValue::Integer(i) => i.into_pyobject(py).unwrap().into_any().unbind(), + YrValue::Float(f) => f.into_pyobject(py).unwrap().into_any().unbind(), + YrValue::String(s) => s.as_ref().into_pyobject(py).unwrap().into_any().unbind(), YrValue::Dictionary(d) => d .iter() .map(|(k, v)| (k, yr_value_to_py_object(py, v))) .collect::>() - .into_py(py), + .into_pyobject(py).unwrap().into_any().unbind(), YrValue::Array(a) => a .iter() .map(|val| yr_value_to_py_object(py, val)) .collect::>() - .into_py(py), + .into_pyobject(py).unwrap().into_any().unbind(), YrValue::Structure(s) => s .as_ref() .map(|map| { @@ -47,7 +48,7 @@ fn yr_value_to_py_object(py: Python<'_>, yr_value: &YrValue) -> PyObject { .map(|(k, v)| (k, yr_value_to_py_object(py, v))) .collect::>() }) - .into_py(py), + .into_pyobject(py).unwrap().into_any().unbind(), } } @@ -59,26 +60,27 @@ impl Context { /// any module data. `sample` and `rule` are expected to be valid paths. `module_data` is a /// python dictionary where key is a module name and data is a path to a file. #[new] + #[pyo3(signature = (sample=None, rule_string=None, rule_path=None, module_data=None))] fn new( - sample: Option<&PyString>, - rule_string: Option<&PyString>, - rule_path: Option<&PyString>, - module_data: Option<&PyDict>, + sample: Option>, + rule_string: Option>, + rule_path: Option>, + module_data: Option>, ) -> PyResult { let mut builder = ContextBuilder::default(); if let Some(sample) = sample { - builder = builder.with_sample(Some(sample.to_string())); + builder = builder.with_sample(Some(sample.to_str()?.to_owned())); } // Use either `rule_string` or `rule_path`. Invalid configuration of arguments raises // exception. match (rule_string, rule_path) { (Some(rule_string), None) => { - builder = builder.with_rule_string(Some(rule_string.to_string())) + builder = builder.with_rule_string(Some(rule_string.to_str()?.to_owned())) } (None, Some(rule_path)) => { - builder = builder.with_rule_file(Some(rule_path.to_string())) + builder = builder.with_rule_file(Some(rule_path.to_str()?.to_owned())) } (Some(_), Some(_)) => { return Err(YariError::new_err( @@ -91,7 +93,7 @@ impl Context { // Add the module data if let Some(module_data) = module_data { - for (module, data) in module_data { + for (module, data) in module_data.iter() { if let (Ok(module), Ok(data)) = (module.downcast::(), data.downcast::()) { @@ -132,10 +134,10 @@ impl Context { } #[pymodule] -fn yari(py: Python, m: &PyModule) -> PyResult<()> { +fn yari(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; - m.add("YariError", py.get_type::())?; + m.add("YariError", m.py().get_type::())?; m.add("LICENSES", yari_sys::LICENSES)?;