From 809bfbdc9da75bd8f369a0988fcdaab3d9c637f6 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Sun, 15 Oct 2023 11:06:23 -0400 Subject: [PATCH] Update pyo3 and numpy to 0.20.0 This commit updates PyO3 to the latest release 0.20.0 [1] and also moves rust-numpy to 0.20.0 [2] as well. The major change for rustworkx is official support for Python 3.12.0 final. We were previously using the 3.12 pre-release support in PyO3 to publish rustworkx for 3.12, but moving to the latest PyO3 officially supports the stable releases of 3.12. The are some small changes needed to adapt to API changes in PyO3, mostly around updates to the `PyDict.get_item()` api. [1] https://github.com/PyO3/pyo3/releases/tag/v0.20.0 [2] https://github.com/PyO3/rust-numpy/releases/tag/v0.20.0 --- Cargo.lock | 76 ++++++++++++++++++++++++-------------------------- Cargo.toml | 4 +-- src/digraph.rs | 18 ++++++++---- src/graph.rs | 16 +++++++---- 4 files changed, 61 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05ccca190..90a5de9ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,6 +137,12 @@ dependencies = [ "rayon", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.3.3" @@ -166,9 +172,9 @@ dependencies = [ [[package]] name = "indoc" -version = "1.0.9" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "itertools" @@ -196,15 +202,15 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "libc" -version = "0.2.148" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "lock_api" @@ -228,9 +234,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -341,9 +347,9 @@ dependencies = [ [[package]] name = "numpy" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "437213adf41bbccf4aeae535fbfcdad0f6fed241e1ae182ebe97fa1f3ce19389" +checksum = "bef41cbb417ea83b30525259e30ccef6af39b31c240bda578889494c5392d331" dependencies = [ "libc", "ndarray", @@ -411,18 +417,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" +checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b" dependencies = [ "cfg-if", "hashbrown 0.14.1", @@ -441,9 +447,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5" +checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5" dependencies = [ "once_cell", "target-lexicon", @@ -451,9 +457,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9" +checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b" dependencies = [ "libc", "pyo3-build-config", @@ -461,25 +467,26 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1" +checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 1.0.109", + "syn", ] [[package]] name = "pyo3-macros-backend" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536" +checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424" dependencies = [ + "heck", "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -663,7 +670,7 @@ checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn", ] [[package]] @@ -700,20 +707,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.37" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -734,9 +730,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unindent" -version = "0.1.11" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "version_check" diff --git a/Cargo.toml b/Cargo.toml index eed872da0..d8fba5163 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ fixedbitset = "0.4.2" hashbrown = { version = ">=0.13, <0.15", features = ["rayon"] } indexmap = { version = ">=1.9, <3", features = ["rayon"] } num-traits = "0.2" -numpy = "0.19.0" +numpy = "0.20.0" petgraph = "0.6.4" rand = "0.8" rand_pcg = "0.3" @@ -60,7 +60,7 @@ serde_json = "1.0" rustworkx-core = { path = "rustworkx-core", version = "=0.14.0" } [dependencies.pyo3] -version = "0.19.2" +version = "0.20.0" features = ["extension-module", "hashbrown", "num-bigint", "num-complex", "indexmap"] [dependencies.ndarray] diff --git a/src/digraph.rs b/src/digraph.rs index bf5395084..02de16885 100644 --- a/src/digraph.rs +++ b/src/digraph.rs @@ -332,27 +332,33 @@ impl PyDiGraph { fn __setstate__(&mut self, py: Python, state: PyObject) -> PyResult<()> { let dict_state = state.downcast::(py)?; - let nodes_lst = dict_state.get_item("nodes").unwrap().downcast::()?; - let edges_lst = dict_state.get_item("edges").unwrap().downcast::()?; + let nodes_lst = dict_state + .get_item("nodes")? + .unwrap() + .downcast::()?; + let edges_lst = dict_state + .get_item("edges")? + .unwrap() + .downcast::()?; self.graph = StablePyGraph::::new(); let dict_state = state.downcast::(py)?; self.multigraph = dict_state - .get_item("multigraph") + .get_item("multigraph")? .unwrap() .downcast::()? .extract()?; self.node_removed = dict_state - .get_item("nodes_removed") + .get_item("nodes_removed")? .unwrap() .downcast::()? .extract()?; - let attrs = match dict_state.get_item("attrs") { + let attrs = match dict_state.get_item("attrs")? { Some(attr) => attr.into(), None => py.None(), }; self.attrs = attrs; self.check_cycle = dict_state - .get_item("check_cycle") + .get_item("check_cycle")? .unwrap() .downcast::()? .extract()?; diff --git a/src/graph.rs b/src/graph.rs index 58d463813..45d8902a7 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -229,21 +229,27 @@ impl PyGraph { fn __setstate__(&mut self, py: Python, state: PyObject) -> PyResult<()> { let dict_state = state.downcast::(py)?; - let nodes_lst = dict_state.get_item("nodes").unwrap().downcast::()?; - let edges_lst = dict_state.get_item("edges").unwrap().downcast::()?; + let nodes_lst = dict_state + .get_item("nodes")? + .unwrap() + .downcast::()?; + let edges_lst = dict_state + .get_item("edges")? + .unwrap() + .downcast::()?; self.graph = StablePyGraph::::default(); self.multigraph = dict_state - .get_item("multigraph") + .get_item("multigraph")? .unwrap() .downcast::()? .extract()?; self.node_removed = dict_state - .get_item("nodes_removed") + .get_item("nodes_removed")? .unwrap() .downcast::()? .extract()?; - self.attrs = match dict_state.get_item("attrs") { + self.attrs = match dict_state.get_item("attrs")? { Some(attr) => attr.into(), None => py.None(), };