From 087339803847e96cf2ba0edb0709623a5527433b Mon Sep 17 00:00:00 2001 From: Matthew Broadway Date: Sun, 17 Nov 2024 17:02:10 +0000 Subject: [PATCH] upgrade pyo3 --- tests/README.md | 1 + .../file_importer_helpers/my_script_1.rs | 2 +- .../file_importer_helpers/my_script_2.rs | 4 +- .../file_importer_helpers/my_script_3.rs | 2 +- .../packages/my_rust_module.rs | 2 +- .../file_importer_helpers/reload_template.rs | 20 +-- .../blank-project/Cargo.lock | 159 +++--------------- .../blank-project/Cargo.toml | 2 +- 8 files changed, 38 insertions(+), 154 deletions(-) diff --git a/tests/README.md b/tests/README.md index 363ad32..5633c8d 100644 --- a/tests/README.md +++ b/tests/README.md @@ -39,6 +39,7 @@ To update maturin: test crates and update `uniffi-bindgen` in `requirements.txt` to match. - check that no crates have been added to `test-crates` that should be excluded from the import hook tests. If so, add them to `IGNORED_TEST_CRATES` in `common.py` +- upgrade the test packages in `test_import_hook/*_helpers` - update the version check in the import hook to ensure it allows using the new version - run the tests to ensure everything still works diff --git a/tests/test_import_hook/file_importer_helpers/my_script_1.rs b/tests/test_import_hook/file_importer_helpers/my_script_1.rs index a802118..c426d7c 100644 --- a/tests/test_import_hook/file_importer_helpers/my_script_1.rs +++ b/tests/test_import_hook/file_importer_helpers/my_script_1.rs @@ -5,6 +5,6 @@ fn get_num() -> usize { 10 } #[pymodule] fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_wrapped(wrap_pyfunction!(get_num))?; + m.add_function(wrap_pyfunction!(get_num, m)?)?; Ok(()) } diff --git a/tests/test_import_hook/file_importer_helpers/my_script_2.rs b/tests/test_import_hook/file_importer_helpers/my_script_2.rs index 9ce2b30..f87e88d 100644 --- a/tests/test_import_hook/file_importer_helpers/my_script_2.rs +++ b/tests/test_import_hook/file_importer_helpers/my_script_2.rs @@ -8,7 +8,7 @@ fn get_other_num() -> usize { 100 } #[pymodule] fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_wrapped(wrap_pyfunction!(get_num))?; - m.add_wrapped(wrap_pyfunction!(get_other_num))?; + m.add_function(wrap_pyfunction!(get_num, m)?)?; + m.add_function(wrap_pyfunction!(get_other_num, m)?)?; Ok(()) } diff --git a/tests/test_import_hook/file_importer_helpers/my_script_3.rs b/tests/test_import_hook/file_importer_helpers/my_script_3.rs index 58decfb..b58dd62 100644 --- a/tests/test_import_hook/file_importer_helpers/my_script_3.rs +++ b/tests/test_import_hook/file_importer_helpers/my_script_3.rs @@ -11,6 +11,6 @@ fn get_num() -> usize { #[pymodule] fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_wrapped(wrap_pyfunction!(get_num))?; + m.add_function(wrap_pyfunction!(get_num, m)?)?; Ok(()) } diff --git a/tests/test_import_hook/file_importer_helpers/packages/my_rust_module.rs b/tests/test_import_hook/file_importer_helpers/packages/my_rust_module.rs index 712990d..a2261a6 100644 --- a/tests/test_import_hook/file_importer_helpers/packages/my_rust_module.rs +++ b/tests/test_import_hook/file_importer_helpers/packages/my_rust_module.rs @@ -7,6 +7,6 @@ pub fn do_something(a: usize, b: usize) -> PyResult { #[pymodule] pub fn my_rust_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_wrapped(wrap_pyfunction!(do_something))?; + m.add_function(wrap_pyfunction!(do_something, m)?)?; Ok(()) } diff --git a/tests/test_import_hook/file_importer_helpers/reload_template.rs b/tests/test_import_hook/file_importer_helpers/reload_template.rs index 8b119b9..2f3bb05 100644 --- a/tests/test_import_hook/file_importer_helpers/reload_template.rs +++ b/tests/test_import_hook/file_importer_helpers/reload_template.rs @@ -40,7 +40,7 @@ impl Integer { } fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { - let logging = PyModule::import_bound(py, "logging")?; + let logging = PyModule::import(py, "logging")?; let message = format!( "comparing Integer instances {} and {}", self.name, other.name @@ -66,7 +66,7 @@ impl PicklableInteger { } fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { - let logging = PyModule::import_bound(py, "logging")?; + let logging = PyModule::import(py, "logging")?; let message = format!( "comparing PicklableInteger instances {} and {}", self.name, other.name @@ -89,35 +89,35 @@ fn get_str() -> String { } fn register_child_module(py: Python<'_>, parent_module: &Bound<'_, PyModule>) -> PyResult<()> { - let child_module = PyModule::new_bound(py, "child")?; - child_module.add_wrapped(wrap_pyfunction!(get_str))?; + let child_module = PyModule::new(py, "child")?; + child_module.add_function(wrap_pyfunction!(get_str, &child_module)?)?; parent_module.add_submodule(&child_module)?; Ok(()) } #[pymodule] fn my_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_wrapped(wrap_pyfunction!(get_num))?; - m.add_wrapped(wrap_pyfunction!(get_global_num))?; - m.add_wrapped(wrap_pyfunction!(set_global_num))?; + m.add_function(wrap_pyfunction!(get_num, m)?)?; + m.add_function(wrap_pyfunction!(get_global_num, m)?)?; + m.add_function(wrap_pyfunction!(set_global_num, m)?)?; m.add_class::()?; m.add_class::()?; register_child_module(py, m)?; - let data = PyDict::new_bound(py); + let data = PyDict::new(py); data.set_item("foo", 123)?; m.add("data", data)?; if !m.hasattr("data_init_once")? { - let data = PyDict::new_bound(py); + let data = PyDict::new(py); data.set_item("foo", 123)?; m.add("data_init_once", data)?; } m.add("data_str", "foo")?; - let logging = PyModule::import_bound(py, "logging")?; + let logging = PyModule::new(py, "logging")?; logging .getattr("info")? .call1(("my_module extension module initialised",))?; diff --git a/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.lock b/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.lock index 21e8eaa..1d9c1e1 100644 --- a/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.lock +++ b/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.lock @@ -8,12 +8,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "blank-project" version = "0.1.0" @@ -29,9 +23,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[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 = "indoc" @@ -45,16 +39,6 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -70,29 +54,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[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.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "portable-atomic" version = "1.6.0" @@ -101,24 +62,24 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.21.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -128,9 +89,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09" dependencies = [ "once_cell", "target-lexicon", @@ -138,9 +99,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75" dependencies = [ "libc", "pyo3-build-config", @@ -148,9 +109,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -160,9 +121,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8" dependencies = [ "heck", "proc-macro2", @@ -173,39 +134,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - [[package]] name = "syn" -version = "2.0.32" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -214,9 +154,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "unicode-ident" @@ -229,60 +169,3 @@ name = "unindent" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.toml b/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.toml index 97a17cc..9d583bd 100644 --- a/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.toml +++ b/tests/test_import_hook/project_importer_helpers/blank-project/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" description = "" [dependencies] -pyo3 = { version = "0.21.2", features = ["extension-module"] } +pyo3 = { version = "0.23.1", features = ["extension-module"] } [lib] crate-type = ["cdylib"]