From cac102c634d84a9f7d9e8285a981d12dec9d043c Mon Sep 17 00:00:00 2001 From: Arnold Loubriat Date: Tue, 30 Sep 2025 00:23:55 +0200 Subject: [PATCH 1/2] Update to pyo 0.23 --- Cargo.lock | 461 ++++++++++----------------------- Cargo.toml | 10 +- examples/pygame/hello_world.py | 1 - pyproject.toml | 1 + src/common.rs | 119 +++++---- src/lib.rs | 27 +- src/macos.rs | 14 +- src/unix.rs | 2 +- src/windows.rs | 37 ++- 9 files changed, 256 insertions(+), 416 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb4c08f..adb9ae2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "accesskit" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3d3b8f9bae46a948369bc4a03e815d4ed6d616bd00de4051133a5019dc31c5a" +checksum = "becf0eb5215b6ecb0a739c31c21bd83c4f326524c9b46b7e882d77559b60a529" dependencies = [ "pyo3", ] @@ -24,9 +24,9 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c5dd55e6e94949498698daf4d48fb5659e824d7abec0d394089656ceaf99d4f" +checksum = "ce9928251cd5651ae983a77aeaa528471eed47cf705885e0b03249b72fe4e8e1" dependencies = [ "accesskit", "accesskit_consumer", @@ -38,9 +38,9 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47983a1084940ba9a39c077a8c63e55c619388be5476ac04c804cfbd1e63459" +checksum = "d0bf66a7bf0b7ea4fd7742d50b64782a88f99217cf246b3f93b4162528dde520" dependencies = [ "accesskit", "hashbrown", @@ -49,9 +49,9 @@ dependencies = [ [[package]] name = "accesskit_macos" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7329821f3bd1101e03a7d2e03bd339e3ac0dc64c70b4c9f9ae1949e3ba8dece1" +checksum = "09e230718177753b4e4ad9e1d9f6cfc2f4921212d4c1c480b253f526babb258d" dependencies = [ "accesskit", "accesskit_consumer", @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.13.1" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcee751cc20d88678c33edaf9c07e8b693cd02819fe89053776f5313492273f5" +checksum = "2ef06642e9f02f1708ad55e1eaeb8ad6956c22917699c4f313afa4f8f1b5e664" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -81,9 +81,9 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24fcd5d23d70670992b823e735e859374d694a3d12bfd8dd32bd3bd8bedb5d81" +checksum = "65178f3df98a51e4238e584fcb255cb1a4f9111820848eeddd37663be40a625f" dependencies = [ "accesskit", "accesskit_consumer", @@ -138,17 +138,6 @@ dependencies = [ "slab", ] -[[package]] -name = "async-fs" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" -dependencies = [ - "async-lock", - "blocking", - "futures-lite", -] - [[package]] name = "async-io" version = "2.4.0" @@ -252,9 +241,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "atspi" -version = "0.22.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be534b16650e35237bb1ed189ba2aab86ce65e88cc84c66f4935ba38575cecbf" +checksum = "c83247582e7508838caf5f316c00791eee0e15c0bf743e6880585b867e16815c" dependencies = [ "atspi-common", "atspi-connection", @@ -263,9 +252,9 @@ dependencies = [ [[package]] name = "atspi-common" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1909ed2dc01d0a17505d89311d192518507e8a056a48148e3598fef5e7bb6ba7" +checksum = "33dfc05e7cdf90988a197803bf24f5788f94f7c94a69efa95683e8ffe76cfdfb" dependencies = [ "enumflags2", "serde", @@ -279,9 +268,9 @@ dependencies = [ [[package]] name = "atspi-connection" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "430c5960624a4baaa511c9c0fcc2218e3b58f5dbcc47e6190cafee344b873333" +checksum = "4193d51303d8332304056ae0004714256b46b6635a5c556109b319c0d3784938" dependencies = [ "atspi-common", "atspi-proxies", @@ -291,14 +280,13 @@ dependencies = [ [[package]] name = "atspi-proxies" -version = "0.6.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e6c5de3e524cf967569722446bcd458d5032348554d9a17d7d72b041ab7496" +checksum = "d2eebcb9e7e76f26d0bcfd6f0295e1cd1e6f33bedbc5698a971db8dc43d7751c" dependencies = [ "atspi-common", "serde", "zbus", - "zvariant", ] [[package]] @@ -307,27 +295,12 @@ 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 = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "block2" version = "0.5.0" @@ -371,15 +344,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - [[package]] name = "crossbeam-utils" version = "0.8.15" @@ -389,26 +353,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "endi" version = "1.1.0" @@ -520,9 +464,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" dependencies = [ "fastrand", "futures-core", @@ -542,12 +486,6 @@ dependencies = [ "syn 2.0.92", ] -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - [[package]] name = "futures-task" version = "0.3.31" @@ -561,37 +499,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", - "futures-io", "futures-macro", - "futures-sink", "futures-task", - "memchr", "pin-project-lite", "pin-utils", "slab", ] -[[package]] -name = "generic-array" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "hashbrown" version = "0.15.2" @@ -603,9 +517,9 @@ dependencies = [ [[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" @@ -652,9 +566,9 @@ checksum = "e1be380c410bf0595e94992a648ea89db4dd3f3354ba54af206fd2a68cf5ac8e" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" [[package]] name = "linux-raw-sys" @@ -662,16 +576,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[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 = "memchr" version = "2.5.0" @@ -689,11 +593,11 @@ dependencies = [ [[package]] name = "nix" -version = "0.29.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "cfg_aliases", "libc", @@ -777,29 +681,6 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" -[[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 0.48.1", -] - [[package]] name = "paste" version = "1.0.12" @@ -845,10 +726,10 @@ dependencies = [ ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "portable-atomic" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "proc-macro-crate" @@ -870,16 +751,17 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82ad98ce1991c9c70c3464ba4187337b9c45fcbbb060d46dca15f0c075e14e2" +checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872" dependencies = [ "cfg-if", "indoc", "inventory", "libc", "memoffset", - "parking_lot", + "once_cell", + "portable-atomic", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -888,9 +770,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5503d0b3aee2c7a8dbb389cd87cd9649f675d4c7f60ca33699a3e3859d81a891" +checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb" dependencies = [ "once_cell", "target-lexicon", @@ -898,9 +780,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a79e8d80486a00d11c0dcb27cd2aa17c022cc95c677b461f01797226ba8f41" +checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d" dependencies = [ "libc", "pyo3-build-config", @@ -908,9 +790,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4b0dc7eaa578604fab11c8c7ff8934c71249c61d4def8e272c76ed879f03d4" +checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -920,21 +802,22 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.1" +version = "0.23.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816a4f709e29ddab2e3cdfe94600d554c5556cad0ddfeea95c47b580c3247fa4" +checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028" dependencies = [ "heck", "proc-macro2", + "pyo3-build-config", "quote", "syn 2.0.92", ] [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" dependencies = [ "memchr", "serde", @@ -949,64 +832,19 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "rustix" version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys 0.59.0", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - [[package]] name = "serde" version = "1.0.217" @@ -1038,17 +876,6 @@ dependencies = [ "syn 2.0.92", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1067,12 +894,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - [[package]] name = "static_assertions" version = "1.1.0" @@ -1103,9 +924,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 = "tempfile" @@ -1117,7 +938,7 @@ dependencies = [ "fastrand", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1154,7 +975,7 @@ checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.6.20", ] [[package]] @@ -1188,12 +1009,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - [[package]] name = "uds_windows" version = "1.1.0" @@ -1217,18 +1032,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "winapi" version = "0.3.9" @@ -1296,6 +1099,12 @@ dependencies = [ "syn 2.0.92", ] +[[package]] +name = "windows-link" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" + [[package]] name = "windows-result" version = "0.2.0" @@ -1315,15 +1124,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.59.0" @@ -1334,18 +1134,12 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.48.1" +name = "windows-sys" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows-targets 0.53.4", ] [[package]] @@ -1357,7 +1151,7 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", @@ -1365,10 +1159,21 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" +name = "windows-targets" +version = "0.53.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] [[package]] name = "windows_aarch64_gnullvm" @@ -1377,10 +1182,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" +name = "windows_aarch64_gnullvm" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" @@ -1389,10 +1194,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] -name = "windows_i686_gnu" -version = "0.48.0" +name = "windows_aarch64_msvc" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" @@ -1400,6 +1205,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" @@ -1407,10 +1218,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] -name = "windows_i686_msvc" -version = "0.48.0" +name = "windows_i686_gnullvm" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" [[package]] name = "windows_i686_msvc" @@ -1419,10 +1230,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" +name = "windows_i686_msvc" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" @@ -1431,10 +1242,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" +name = "windows_x86_64_gnu" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" [[package]] name = "windows_x86_64_gnullvm" @@ -1443,10 +1254,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" +name = "windows_x86_64_gnullvm" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" [[package]] name = "windows_x86_64_msvc" @@ -1454,6 +1265,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" version = "0.6.20" @@ -1464,24 +1281,22 @@ dependencies = [ ] [[package]] -name = "xdg-home" -version = "1.3.0" +name = "winnow" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" dependencies = [ - "libc", - "windows-sys 0.59.0", + "memchr", ] [[package]] name = "zbus" -version = "4.4.0" +version = "5.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" +checksum = "2d07e46d035fb8e375b2ce63ba4e4ff90a7f73cf2ffb0138b29e1158d2eaadf7" dependencies = [ "async-broadcast", "async-executor", - "async-fs", "async-io", "async-lock", "async-process", @@ -1492,20 +1307,16 @@ dependencies = [ "enumflags2", "event-listener 5.3.1", "futures-core", - "futures-sink", - "futures-util", + "futures-lite", "hex", "nix", "ordered-stream", - "rand", "serde", "serde_repr", - "sha1", - "static_assertions", "tracing", "uds_windows", - "windows-sys 0.52.0", - "xdg-home", + "windows-sys 0.60.2", + "winnow 0.7.13", "zbus_macros", "zbus_names", "zvariant", @@ -1513,9 +1324,9 @@ dependencies = [ [[package]] name = "zbus-lockstep" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca2c5dceb099bddaade154055c926bb8ae507a18756ba1d8963fd7b51d8ed1d" +checksum = "29e96e38ded30eeab90b6ba88cb888d70aef4e7489b6cd212c5e5b5ec38045b6" dependencies = [ "zbus_xml", "zvariant", @@ -1523,9 +1334,9 @@ dependencies = [ [[package]] name = "zbus-lockstep-macros" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709ab20fc57cb22af85be7b360239563209258430bccf38d8b979c5a2ae3ecce" +checksum = "dc6821851fa840b708b4cbbaf6241868cabc85a2dc22f426361b0292bfc0b836" dependencies = [ "proc-macro2", "quote", @@ -1537,33 +1348,36 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "4.4.0" +version = "5.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" +checksum = "57e797a9c847ed3ccc5b6254e8bcce056494b375b511b3d6edcec0aeb4defaca" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.92", + "zbus_names", + "zvariant", "zvariant_utils", ] [[package]] name = "zbus_names" -version = "3.0.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" +checksum = "7be68e64bf6ce8db94f63e72f0c7eb9a60d733f7e0499e628dfab0f84d6bcb97" dependencies = [ "serde", "static_assertions", + "winnow 0.7.13", "zvariant", ] [[package]] name = "zbus_xml" -version = "4.0.0" +version = "5.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3f374552b954f6abb4bd6ce979e6c9b38fb9d0cd7cc68a7d796e70c9f3a233" +checksum = "589e9a02bfafb9754bb2340a9e3b38f389772684c63d9637e76b1870377bec29" dependencies = [ "quick-xml", "serde", @@ -1574,22 +1388,23 @@ dependencies = [ [[package]] name = "zvariant" -version = "4.2.0" +version = "5.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" +checksum = "999dd3be73c52b1fccd109a4a81e4fcd20fab1d3599c8121b38d04e1419498db" dependencies = [ "endi", "enumflags2", "serde", - "static_assertions", + "winnow 0.7.13", "zvariant_derive", + "zvariant_utils", ] [[package]] name = "zvariant_derive" -version = "4.2.0" +version = "5.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" +checksum = "6643fd0b26a46d226bd90d3f07c1b5321fe9bb7f04673cb37ac6d6883885b68e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1600,11 +1415,13 @@ dependencies = [ [[package]] name = "zvariant_utils" -version = "2.1.0" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" +checksum = "c6949d142f89f6916deca2232cf26a8afacf2b9fdc35ce766105e104478be599" dependencies = [ "proc-macro2", "quote", + "serde", "syn 2.0.92", + "winnow 0.7.13", ] diff --git a/Cargo.toml b/Cargo.toml index e5b00c3..df87281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,17 +18,17 @@ doc = false extension-module = ["pyo3/extension-module"] [dependencies] -accesskit = { version = "0.17.1", features = ["pyo3"] } -pyo3 = { version = "0.20", features = ["abi3-py38", "multiple-pymethods"] } +accesskit = { version = "0.18.0", features = ["pyo3"] } +pyo3 = { version = "0.23", features = ["abi3-py38", "multiple-pymethods"] } [target.'cfg(target_os = "windows")'.dependencies] -accesskit_windows = { version = "0.24.1" } +accesskit_windows = { version = "0.25.0" } [target.'cfg(target_os = "macos")'.dependencies] -accesskit_macos = { version = "0.18.1" } +accesskit_macos = { version = "0.19.0" } [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -accesskit_unix = { version = "0.13.1" } +accesskit_unix = { version = "0.14.0" } [profile.release] lto = true diff --git a/examples/pygame/hello_world.py b/examples/pygame/hello_world.py index 7db2348..fdf6b2d 100644 --- a/examples/pygame/hello_world.py +++ b/examples/pygame/hello_world.py @@ -91,7 +91,6 @@ def build_initial_tree(self): button_2 = build_button(BUTTON_2_ID, "Button 2") result = accesskit.TreeUpdate(self.focus) tree = accesskit.Tree(WINDOW_ID) - tree.app_name = "Hello world" result.tree = tree result.nodes.append((WINDOW_ID, root)) result.nodes.append((BUTTON_1_ID, button_1)) diff --git a/pyproject.toml b/pyproject.toml index 7bb3fc3..9da7cf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Topic :: Software Development :: User Interfaces" ] +dynamic = ["version"] [project.urls] Homepage = "https://github.com/AccessKit/accesskit-python" diff --git a/src/common.rs b/src/common.rs index 388a0ec..48bf9c0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -4,7 +4,11 @@ // the LICENSE-MIT file), at your option. use crate::{Point, Rect}; -use pyo3::{prelude::*, types::PyList}; +use pyo3::{ + prelude::*, + types::{PyList, PyTuple}, + IntoPyObjectExt, +}; #[derive(Clone)] #[pyclass(module = "accesskit")] @@ -151,7 +155,6 @@ impl From for TextPosition { } } -#[derive(Clone)] #[pyclass(get_all, set_all, module = "accesskit")] pub struct TextSelection { pub anchor: Py, @@ -178,15 +181,20 @@ impl From<&accesskit::TextSelection> for TextSelection { impl From for accesskit::TextSelection { fn from(selection: TextSelection) -> Self { Python::with_gil(|py| accesskit::TextSelection { - anchor: selection.anchor.as_ref(py).borrow().0, - focus: selection.focus.as_ref(py).borrow().0, + anchor: selection.anchor.bind(py).borrow().0, + focus: selection.focus.bind(py).borrow().0, }) } } -impl From for Box { - fn from(selection: TextSelection) -> Self { - Box::new(selection.into()) +impl From<&TextSelection> for Box { + fn from(selection: &TextSelection) -> Self { + Python::with_gil(|py| { + Box::new(accesskit::TextSelection { + anchor: selection.anchor.borrow(py).0, + focus: selection.focus.borrow(py).0, + }) + }) } } @@ -293,14 +301,14 @@ macro_rules! vec_property_methods { $(#[pymethods] impl Node { #[getter] - pub fn $getter(&self, py: Python) -> Py { - let values = self.inner().$getter().iter().cloned().map(<$py_item_type>::from).map(|i| i.into_py(py)); - PyList::new(py, values).into() + pub fn $getter(&self, py: Python) -> PyResult> { + let values = self.inner().$getter().iter().cloned().map(<$py_item_type>::from); + Ok(PyList::new(py, values)?.unbind()) } - pub fn $setter(&mut self, values: &PyList) { + pub fn $setter(&mut self, values: &Bound<'_, PyList>) { let values = values .iter() - .map(PyAny::extract::<$py_item_type>) + .map(|item| item.extract::<$py_item_type>()) .filter_map(PyResult::ok) .map(<$accesskit_item_type>::from) .collect::>(); @@ -540,7 +548,7 @@ unique_enum_property_methods! { property_methods! { (transform, option_getter, Option, set_transform, simple_setter, crate::Affine, clear_transform), (bounds, option_getter, Option, set_bounds, converting_setter, crate::Rect, clear_bounds), - (text_selection, option_getter, Option, set_text_selection, simple_setter, TextSelection, clear_text_selection) + (text_selection, option_getter, Option, set_text_selection, simple_setter, &TextSelection, clear_text_selection) } vec_property_methods! { @@ -551,7 +559,6 @@ vec_property_methods! { #[pyclass(module = "accesskit", get_all, set_all)] pub struct Tree { pub root: NodeId, - pub app_name: Option, pub toolkit_name: Option, pub toolkit_version: Option, } @@ -562,7 +569,6 @@ impl Tree { pub fn new(root: NodeId) -> Self { Self { root, - app_name: None, toolkit_name: None, toolkit_version: None, } @@ -573,14 +579,12 @@ impl From for accesskit::Tree { fn from(tree: Tree) -> Self { Self { root: tree.root.into(), - app_name: tree.app_name, toolkit_name: tree.toolkit_name, toolkit_version: tree.toolkit_version, } } } -#[derive(Clone)] #[pyclass(module = "accesskit", get_all, set_all)] pub struct TreeUpdate { pub nodes: Py, @@ -600,22 +604,21 @@ impl TreeUpdate { } } -impl From for accesskit::TreeUpdate { - fn from(update: TreeUpdate) -> Self { +impl From<&TreeUpdate> for accesskit::TreeUpdate { + fn from(update: &TreeUpdate) -> Self { Python::with_gil(|py| Self { nodes: update .nodes - .as_ref(py) + .bind(py) .iter() - .map(PyAny::extract::<(NodeId, Node)>) + .map(|n| n.extract::<(NodeId, Node)>()) .filter_map(Result::ok) .map(|(id, node)| (id.into(), node.into())) .collect(), - tree: update.tree.map(|tree| { - let tree = tree.as_ref(py).borrow(); + tree: update.tree.as_ref().map(|tree| { + let tree = tree.bind(py).borrow(); accesskit::Tree { root: tree.root.into(), - app_name: tree.app_name.clone(), toolkit_name: tree.toolkit_name.clone(), toolkit_version: tree.toolkit_version.clone(), } @@ -625,8 +628,8 @@ impl From for accesskit::TreeUpdate { } } -#[derive(Clone)] -#[pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE")] +#[derive(PartialEq)] +#[pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE", eq, eq_int)] pub enum ActionDataKind { CustomAction, Value, @@ -641,7 +644,7 @@ pub enum ActionDataKind { pub struct ActionRequest { pub action: accesskit::Action, pub target: NodeId, - pub data: Option<(ActionDataKind, Py)>, + pub data: Option>, } impl From for ActionRequest { @@ -649,30 +652,38 @@ impl From for ActionRequest { Python::with_gil(|py| Self { action: request.action, target: request.target.into(), - data: request.data.map(|data| match data { - accesskit::ActionData::CustomAction(action) => { - (ActionDataKind::CustomAction, action.into_py(py)) + data: request.data.map(|data| { + match data { + accesskit::ActionData::CustomAction(action) => ( + ActionDataKind::CustomAction, + action.into_py_any(py).unwrap(), + ), + accesskit::ActionData::Value(value) => { + (ActionDataKind::Value, value.into_py_any(py).unwrap()) + } + accesskit::ActionData::NumericValue(value) => { + (ActionDataKind::NumericValue, value.into_py_any(py).unwrap()) + } + accesskit::ActionData::ScrollTargetRect(rect) => ( + ActionDataKind::ScrollTargetRect, + Rect::from(rect).into_py_any(py).unwrap(), + ), + accesskit::ActionData::ScrollToPoint(point) => ( + ActionDataKind::ScrollToPoint, + Point::from(point).into_py_any(py).unwrap(), + ), + accesskit::ActionData::SetScrollOffset(point) => ( + ActionDataKind::SetScrollOffset, + Point::from(point).into_py_any(py).unwrap(), + ), + accesskit::ActionData::SetTextSelection(selection) => ( + ActionDataKind::SetTextSelection, + TextSelection::from(&selection).into_py_any(py).unwrap(), + ), } - accesskit::ActionData::Value(value) => (ActionDataKind::Value, value.into_py(py)), - accesskit::ActionData::NumericValue(value) => { - (ActionDataKind::NumericValue, value.into_py(py)) - } - accesskit::ActionData::ScrollTargetRect(rect) => ( - ActionDataKind::ScrollTargetRect, - Rect::from(rect).into_py(py), - ), - accesskit::ActionData::ScrollToPoint(point) => ( - ActionDataKind::ScrollToPoint, - Point::from(point).into_py(py), - ), - accesskit::ActionData::SetScrollOffset(point) => ( - ActionDataKind::SetScrollOffset, - Point::from(point).into_py(py), - ), - accesskit::ActionData::SetTextSelection(selection) => ( - ActionDataKind::SetTextSelection, - TextSelection::from(&selection).into_py(py), - ), + .into_pyobject(py) + .unwrap() + .unbind() }), }) } @@ -690,9 +701,9 @@ impl accesskit::ActivationHandler for LocalPythonActivationHandler<'_> { fn request_initial_tree(&mut self) -> Option { let result = self.handler.call0(self.py).unwrap(); result - .extract::>(self.py) + .extract::>>(self.py) .unwrap() - .map(Into::into) + .map(|tree| (&*tree).into()) } } @@ -703,9 +714,9 @@ impl accesskit::ActivationHandler for PythonActivationHandler { Python::with_gil(|py| { let result = self.0.call0(py).unwrap(); result - .extract::>(py) + .extract::>>(py) .unwrap() - .map(Into::into) + .map(|tree| (&*tree).into()) }) } } diff --git a/src/lib.rs b/src/lib.rs index 1ab48df..a2fa83b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,9 +3,6 @@ // the LICENSE-APACHE file) or the MIT license (found in // the LICENSE-MIT file), at your option. -// TODO: Remove this exception once we update pyo3. -#![allow(non_local_definitions)] - mod common; mod geometry; @@ -29,7 +26,7 @@ pub use common::*; pub use geometry::*; #[pymodule] -fn accesskit(py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn accesskit(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::<::accesskit::Role>()?; m.add_class::<::accesskit::Action>()?; m.add_class::<::accesskit::Orientation>()?; @@ -57,15 +54,15 @@ fn accesskit(py: Python<'_>, m: &PyModule) -> PyResult<()> { #[cfg(target_os = "macos")] { - let macos_module = PyModule::new(py, "macos")?; + let macos_module = PyModule::new(m.py(), "macos")?; macos_module.add_class::()?; macos_module.add_class::()?; macos_module.add_class::()?; macos_module.add_function(wrap_pyfunction!( macos::add_focus_forwarder_to_window_class, - macos_module + &macos_module )?)?; - m.add_submodule(macos_module)?; + m.add_submodule(&macos_module)?; } #[cfg(any( target_os = "linux", @@ -75,17 +72,17 @@ fn accesskit(py: Python<'_>, m: &PyModule) -> PyResult<()> { target_os = "openbsd", ))] { - let unix_module = PyModule::new(py, "unix")?; + let unix_module = PyModule::new(m.py(), "unix")?; unix_module.add_class::()?; - m.add_submodule(unix_module)?; + m.add_submodule(&unix_module)?; } #[cfg(target_os = "windows")] { - let windows_module = PyModule::new(py, "windows")?; + let windows_module = PyModule::new(m.py(), "windows")?; windows_module.add_class::()?; windows_module.add_class::()?; windows_module.add_class::()?; - m.add_submodule(windows_module)?; + m.add_submodule(&windows_module)?; } Ok(()) @@ -94,10 +91,10 @@ fn accesskit(py: Python<'_>, m: &PyModule) -> PyResult<()> { // The following exception is needed because this function is only used // in the bindings for some platform adapters. #[allow(dead_code)] -fn to_void_ptr(value: &PyAny) -> *mut c_void { - if let Ok(value) = value.extract::<&PyCapsule>() { - return value.pointer(); +fn to_void_ptr(value: &Bound<'_, PyAny>) -> *mut c_void { + if let Ok(capsule) = value.downcast::() { + return capsule.pointer(); } - let value = value.getattr("value").unwrap_or(value); + let value = value.getattr("value").unwrap_or(value.clone()); value.extract::().unwrap() as *mut _ } diff --git a/src/macos.rs b/src/macos.rs index c01d48c..7647113 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -42,7 +42,11 @@ impl Adapter { /// /// `view` must be a valid, unreleased pointer to an `NSView`. #[new] - pub unsafe fn new(view: &PyAny, is_view_focused: bool, action_handler: Py) -> Self { + pub unsafe fn new( + view: &Bound<'_, PyAny>, + is_view_focused: bool, + action_handler: Py, + ) -> Self { Self(accesskit_macos::Adapter::new( to_void_ptr(view), is_view_focused, @@ -59,7 +63,7 @@ impl Adapter { self.0 .update_if_active(|| { let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() + (&*update.extract::>(py).unwrap()).into() }) .map(Into::into) } @@ -128,7 +132,7 @@ impl SubclassingAdapter { /// `view` must be a valid, unreleased pointer to an `NSView`. #[new] pub unsafe fn new( - view: &PyAny, + view: &Bound<'_, PyAny>, activation_handler: Py, action_handler: Py, ) -> Self { @@ -154,7 +158,7 @@ impl SubclassingAdapter { /// a content view. #[staticmethod] pub unsafe fn for_window( - window: &PyAny, + window: &Bound<'_, PyAny>, activation_handler: Py, action_handler: Py, ) -> Self { @@ -174,7 +178,7 @@ impl SubclassingAdapter { self.0 .update_if_active(|| { let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() + (&*update.extract::>(py).unwrap()).into() }) .map(Into::into) } diff --git a/src/unix.rs b/src/unix.rs index c0f9237..e00a01b 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -36,7 +36,7 @@ impl Adapter { pub fn update_if_active(&mut self, py: Python<'_>, update_factory: Py) { self.0.update_if_active(|| { let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() + (&*update.extract::>(py).unwrap()).into() }); } diff --git a/src/windows.rs b/src/windows.rs index 3a104af..4d95997 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -3,27 +3,30 @@ // the LICENSE-APACHE file) or the MIT license (found in // the LICENSE-MIT file), at your option. +use accesskit_windows::{HWND, LPARAM, WPARAM}; +use pyo3::prelude::*; +use std::sync::{Arc, Mutex}; + use crate::{ to_void_ptr, LocalPythonActivationHandler, PythonActionHandler, PythonActivationHandler, TreeUpdate, }; -use accesskit_windows::{HWND, LPARAM, WPARAM}; -use pyo3::prelude::*; #[pyclass(module = "accesskit.windows")] -pub struct QueuedEvents(Option); +pub struct QueuedEvents(Option>>); #[pymethods] impl QueuedEvents { pub fn raise_events(&mut self) { - let events = self.0.take().unwrap(); + let events = Arc::into_inner(self.0.take().unwrap()).unwrap(); + let events = events.into_inner().unwrap(); events.raise(); } } impl From for QueuedEvents { fn from(events: accesskit_windows::QueuedEvents) -> Self { - Self(Some(events)) + Self(Some(Arc::new(Mutex::new(events)))) } } @@ -37,7 +40,11 @@ impl Adapter { /// The action handler may or may not be called on the thread that owns /// the window. #[new] - pub fn new(hwnd: &PyAny, is_window_focused: bool, action_handler: Py) -> Self { + pub fn new( + hwnd: &Bound<'_, PyAny>, + is_window_focused: bool, + action_handler: Py, + ) -> Self { Self(accesskit_windows::Adapter::new( HWND(to_void_ptr(hwnd)), is_window_focused, @@ -54,7 +61,7 @@ impl Adapter { self.0 .update_if_active(|| { let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() + (&*update.extract::>(py).unwrap()).into() }) .map(Into::into) } @@ -67,8 +74,8 @@ impl Adapter { pub fn handle_wm_getobject( &mut self, py: Python<'_>, - wparam: &PyAny, - lparam: &PyAny, + wparam: &Bound<'_, PyAny>, + lparam: &Bound<'_, PyAny>, activation_handler: Py, ) -> Option { let mut activation_handler = LocalPythonActivationHandler { @@ -97,7 +104,11 @@ impl SubclassingAdapter { /// The action handler may or may not be called on the thread that owns /// the window. #[new] - pub fn new(hwnd: &PyAny, activation_handler: Py, action_handler: Py) -> Self { + pub fn new( + hwnd: &Bound<'_, PyAny>, + activation_handler: Py, + action_handler: Py, + ) -> Self { Self(accesskit_windows::SubclassingAdapter::new( HWND(to_void_ptr(hwnd)), PythonActivationHandler(activation_handler), @@ -114,13 +125,13 @@ impl SubclassingAdapter { self.0 .update_if_active(|| { let update = update_factory.call0(py).unwrap(); - update.extract::(py).unwrap().into() + (&*update.extract::>(py).unwrap()).into() }) .map(Into::into) } } -fn cast<'a, D: FromPyObject<'a>>(value: &'a PyAny) -> D { - let value = value.getattr("value").unwrap_or(value); +fn cast<'a, D: FromPyObject<'a>>(value: &'a Bound) -> D { + let value = value.getattr("value").unwrap_or(value.clone()); value.extract().unwrap() } From 73e040d48a1069feb4704985f00702d5e38c61f2 Mon Sep 17 00:00:00 2001 From: Arnold Loubriat Date: Tue, 30 Sep 2025 00:41:43 +0200 Subject: [PATCH 2/2] Update to pyo 0.24 --- Cargo.lock | 154 +++++++++++++++++++++++++++++--------------------- Cargo.toml | 10 ++-- src/common.rs | 33 ++++++++--- src/lib.rs | 2 + 4 files changed, 122 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adb9ae2..b152e45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "accesskit" -version = "0.18.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "becf0eb5215b6ecb0a739c31c21bd83c4f326524c9b46b7e882d77559b60a529" +checksum = "9c0690ad6e6f9597b8439bd3c95e8c6df5cd043afd950c6d68f3b37df641e27c" dependencies = [ "pyo3", ] @@ -24,9 +24,9 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" -version = "0.11.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce9928251cd5651ae983a77aeaa528471eed47cf705885e0b03249b72fe4e8e1" +checksum = "8fb511e093896d3cae0efba40322087dff59ea322308a3e6edf70f28d22f2607" dependencies = [ "accesskit", "accesskit_consumer", @@ -38,20 +38,19 @@ dependencies = [ [[package]] name = "accesskit_consumer" -version = "0.27.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0bf66a7bf0b7ea4fd7742d50b64782a88f99217cf246b3f93b4162528dde520" +checksum = "ec27574c1baeb7747c802a194566b46b602461e81dc4957949580ea8da695038" dependencies = [ "accesskit", "hashbrown", - "immutable-chunkmap", ] [[package]] name = "accesskit_macos" -version = "0.19.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09e230718177753b4e4ad9e1d9f6cfc2f4921212d4c1c480b253f526babb258d" +checksum = "bf962bfd305aed21133d06128ab3f4a6412031a5b8505534d55af869788af272" dependencies = [ "accesskit", "accesskit_consumer", @@ -63,9 +62,9 @@ dependencies = [ [[package]] name = "accesskit_unix" -version = "0.14.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ef06642e9f02f1708ad55e1eaeb8ad6956c22917699c4f313afa4f8f1b5e664" +checksum = "2abbfb16144cca5bb2ea6acad5865b7c1e70d4fa171ceba1a52ea8e78a7515f4" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -81,25 +80,18 @@ dependencies = [ [[package]] name = "accesskit_windows" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65178f3df98a51e4238e584fcb255cb1a4f9111820848eeddd37663be40a625f" +checksum = "e4cd727229c389e32c1a78fe9f74dc62d7c9fb6eac98cfa1a17efde254fb2d98" dependencies = [ "accesskit", "accesskit_consumer", "hashbrown", - "paste", "static_assertions", "windows", "windows-core", ] -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - [[package]] name = "async-broadcast" version = "0.7.2" @@ -533,15 +525,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "immutable-chunkmap" -version = "2.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f97096f508d54f8f8ab8957862eee2ccd628847b6217af1a335e1c44dee578" -dependencies = [ - "arrayvec", -] - [[package]] name = "indexmap" version = "2.7.0" @@ -681,12 +664,6 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" -[[package]] -name = "paste" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -751,9 +728,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.5" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872" +checksum = "e5203598f366b11a02b13aa20cab591229ff0a89fd121a308a5df751d5fc9219" dependencies = [ "cfg-if", "indoc", @@ -770,9 +747,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.5" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb" +checksum = "99636d423fa2ca130fa5acde3059308006d46f98caac629418e53f7ebb1e9999" dependencies = [ "once_cell", "target-lexicon", @@ -780,9 +757,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.5" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d" +checksum = "78f9cf92ba9c409279bc3305b5409d90db2d2c22392d443a87df3a1adad59e33" dependencies = [ "libc", "pyo3-build-config", @@ -790,9 +767,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.5" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da" +checksum = "0b999cb1a6ce21f9a6b147dcf1be9ffedf02e0043aec74dc390f3007047cecd9" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -802,9 +779,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.5" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028" +checksum = "822ece1c7e1012745607d5cf0bcb2874769f0f7cb34c4cde03b9358eb9ef911a" dependencies = [ "heck", "proc-macro2", @@ -924,9 +901,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.16" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" [[package]] name = "tempfile" @@ -1056,32 +1033,55 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.58.0" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ "windows-core", - "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.58.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", + "windows-link 0.1.3", "windows-result", "windows-strings", - "windows-targets 0.52.6", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core", + "windows-link 0.1.3", + "windows-threading", ] [[package]] name = "windows-implement" -version = "0.58.0" +version = "0.60.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" dependencies = [ "proc-macro2", "quote", @@ -1090,15 +1090,21 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.58.0" +version = "0.59.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" dependencies = [ "proc-macro2", "quote", "syn 2.0.92", ] +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + [[package]] name = "windows-link" version = "0.2.0" @@ -1106,22 +1112,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" [[package]] -name = "windows-result" +name = "windows-numerics" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-targets 0.52.6", + "windows-core", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", ] [[package]] name = "windows-strings" -version = "0.1.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-result", - "windows-targets 0.52.6", + "windows-link 0.1.3", ] [[package]] @@ -1164,7 +1179,7 @@ version = "0.53.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" dependencies = [ - "windows-link", + "windows-link 0.2.0", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -1175,6 +1190,15 @@ dependencies = [ "windows_x86_64_msvc 0.53.0", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" diff --git a/Cargo.toml b/Cargo.toml index df87281..7404f9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,17 +18,17 @@ doc = false extension-module = ["pyo3/extension-module"] [dependencies] -accesskit = { version = "0.18.0", features = ["pyo3"] } -pyo3 = { version = "0.23", features = ["abi3-py38", "multiple-pymethods"] } +accesskit = { version = "0.21.0", features = ["pyo3"] } +pyo3 = { version = "0.24", features = ["abi3-py38", "multiple-pymethods"] } [target.'cfg(target_os = "windows")'.dependencies] -accesskit_windows = { version = "0.25.0" } +accesskit_windows = { version = "0.29.0" } [target.'cfg(target_os = "macos")'.dependencies] -accesskit_macos = { version = "0.19.0" } +accesskit_macos = { version = "0.22.0" } [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -accesskit_unix = { version = "0.14.0" } +accesskit_unix = { version = "0.17.0" } [profile.release] lto = true diff --git a/src/common.rs b/src/common.rs index 48bf9c0..b12cb35 100644 --- a/src/common.rs +++ b/src/common.rs @@ -3,13 +3,14 @@ // the LICENSE-APACHE file) or the MIT license (found in // the LICENSE-MIT file), at your option. -use crate::{Point, Rect}; use pyo3::{ prelude::*, types::{PyList, PyTuple}, IntoPyObjectExt, }; +use crate::Point; + #[derive(Clone)] #[pyclass(module = "accesskit")] pub struct Node(accesskit::Node); @@ -63,6 +64,22 @@ impl Node { pub fn clear_actions(&mut self) { self.inner_mut().clear_actions() } + + pub fn child_supports_action(&self, action: accesskit::Action) -> bool { + self.inner().child_supports_action(action) + } + + pub fn add_child_action(&mut self, action: accesskit::Action) { + self.inner_mut().add_child_action(action) + } + + pub fn remove_child_action(&mut self, action: accesskit::Action) { + self.inner_mut().remove_child_action(action) + } + + pub fn clear_child_actions(&mut self) { + self.inner_mut().clear_child_actions(); + } } pub type NodeId = u64; @@ -412,7 +429,6 @@ macro_rules! unique_enum_property_methods { flag_methods! { (is_hidden, set_hidden, clear_hidden), - (is_linked, set_linked, clear_linked), (is_multiselectable, set_multiselectable, clear_multiselectable), (is_required, set_required, clear_required), (is_visited, set_visited, clear_visited), @@ -634,7 +650,8 @@ pub enum ActionDataKind { CustomAction, Value, NumericValue, - ScrollTargetRect, + ScrollUnit, + ScrollHint, ScrollToPoint, SetScrollOffset, SetTextSelection, @@ -664,10 +681,12 @@ impl From for ActionRequest { accesskit::ActionData::NumericValue(value) => { (ActionDataKind::NumericValue, value.into_py_any(py).unwrap()) } - accesskit::ActionData::ScrollTargetRect(rect) => ( - ActionDataKind::ScrollTargetRect, - Rect::from(rect).into_py_any(py).unwrap(), - ), + accesskit::ActionData::ScrollUnit(unit) => { + (ActionDataKind::ScrollUnit, unit.into_py_any(py).unwrap()) + } + accesskit::ActionData::ScrollHint(hint) => { + (ActionDataKind::ScrollHint, hint.into_py_any(py).unwrap()) + } accesskit::ActionData::ScrollToPoint(point) => ( ActionDataKind::ScrollToPoint, Point::from(point).into_py_any(py).unwrap(), diff --git a/src/lib.rs b/src/lib.rs index a2fa83b..7e75108 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,8 @@ fn accesskit(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::<::accesskit::TextAlign>()?; m.add_class::<::accesskit::VerticalOffset>()?; m.add_class::<::accesskit::TextDecoration>()?; + m.add_class::<::accesskit::ScrollUnit>()?; + m.add_class::<::accesskit::ScrollHint>()?; m.add_class::()?; m.add_class::()?; m.add_class::()?;