From 9fe53ff54942f809aceae1e56712aacda2efdd2f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 3 Nov 2020 15:31:58 +1000 Subject: [PATCH] switch to the stable Python ABI Should allow the library to be imported in both Python 3.8+3.9. --- cargo/Cargo.lock | 9 ++---- cargo/crates.bzl | 30 +++++++++---------- cargo/remote/pyo3-0.12.3.BUILD.bazel | 2 ++ .../pyo3-derive-backend-0.12.3.BUILD.bazel | 2 +- cargo/remote/pyo3cls-0.12.3.BUILD.bazel | 2 +- cargo/update.py | 4 ++- pylib/rsbridge/Cargo.toml | 5 ++-- pylib/rsbridge/lib.rs | 2 +- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/cargo/Cargo.lock b/cargo/Cargo.lock index d66474ca0..0eb4c9af2 100644 --- a/cargo/Cargo.lock +++ b/cargo/Cargo.lock @@ -1495,8 +1495,7 @@ dependencies = [ [[package]] name = "pyo3" version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b90d637542bbf29b140fdd38fa308424073fd2cdf641a5680aed8020145e3c" +source = "git+https://github.com/PyO3/pyo3.git?rev=3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1#3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1" dependencies = [ "ctor", "indoc", @@ -1511,8 +1510,7 @@ dependencies = [ [[package]] name = "pyo3-derive-backend" version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee2c9fb095acb885ab7e85acc7c8e95da8c4bc7cc4b4ea64b566dfc8c91046a" +source = "git+https://github.com/PyO3/pyo3.git?rev=3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1#3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1" dependencies = [ "proc-macro2", "quote", @@ -1522,8 +1520,7 @@ dependencies = [ [[package]] name = "pyo3cls" version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f12fdd8a2f217d003c93f9819e3db1717b2e89530171edea4c0deadd90206f50" +source = "git+https://github.com/PyO3/pyo3.git?rev=3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1#3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1" dependencies = [ "pyo3-derive-backend", "quote", diff --git a/cargo/crates.bzl b/cargo/crates.bzl index 4fd8eab85..94590cb9b 100644 --- a/cargo/crates.bzl +++ b/cargo/crates.bzl @@ -1572,33 +1572,33 @@ def raze_fetch_remote_crates(): ) maybe( - http_archive, + new_git_repository, name = "raze__pyo3__0_12_3", - url = "https://crates.io/api/v1/crates/pyo3/0.12.3/download", - type = "tar.gz", - sha256 = "a9b90d637542bbf29b140fdd38fa308424073fd2cdf641a5680aed8020145e3c", - strip_prefix = "pyo3-0.12.3", + remote = "https://github.com/PyO3/pyo3.git", + shallow_since = "1603809036 +0900", + commit = "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1", build_file = Label("//cargo/remote:pyo3-0.12.3.BUILD.bazel"), + init_submodules = True, ) maybe( - http_archive, + new_git_repository, name = "raze__pyo3_derive_backend__0_12_3", - url = "https://crates.io/api/v1/crates/pyo3-derive-backend/0.12.3/download", - type = "tar.gz", - sha256 = "cee2c9fb095acb885ab7e85acc7c8e95da8c4bc7cc4b4ea64b566dfc8c91046a", - strip_prefix = "pyo3-derive-backend-0.12.3", + remote = "https://github.com/PyO3/pyo3.git", + shallow_since = "1603809036 +0900", + commit = "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1", build_file = Label("//cargo/remote:pyo3-derive-backend-0.12.3.BUILD.bazel"), + init_submodules = True, ) maybe( - http_archive, + new_git_repository, name = "raze__pyo3cls__0_12_3", - url = "https://crates.io/api/v1/crates/pyo3cls/0.12.3/download", - type = "tar.gz", - sha256 = "f12fdd8a2f217d003c93f9819e3db1717b2e89530171edea4c0deadd90206f50", - strip_prefix = "pyo3cls-0.12.3", + remote = "https://github.com/PyO3/pyo3.git", + shallow_since = "1603809036 +0900", + commit = "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1", build_file = Label("//cargo/remote:pyo3cls-0.12.3.BUILD.bazel"), + init_submodules = True, ) maybe( diff --git a/cargo/remote/pyo3-0.12.3.BUILD.bazel b/cargo/remote/pyo3-0.12.3.BUILD.bazel index a42aac6b8..1535f2eec 100644 --- a/cargo/remote/pyo3-0.12.3.BUILD.bazel +++ b/cargo/remote/pyo3-0.12.3.BUILD.bazel @@ -47,6 +47,7 @@ cargo_build_script( "--cap-lints=allow", ], crate_features = [ + "abi3", "ctor", "default", "extension-module", @@ -105,6 +106,7 @@ rust_library( "manual", ], crate_features = [ + "abi3", "ctor", "default", "extension-module", diff --git a/cargo/remote/pyo3-derive-backend-0.12.3.BUILD.bazel b/cargo/remote/pyo3-derive-backend-0.12.3.BUILD.bazel index a55282645..d3fd9de26 100644 --- a/cargo/remote/pyo3-derive-backend-0.12.3.BUILD.bazel +++ b/cargo/remote/pyo3-derive-backend-0.12.3.BUILD.bazel @@ -40,7 +40,7 @@ rust_library( "@raze__syn__1_0_48//:syn", ], srcs = glob(["**/*.rs"]), - crate_root = "src/lib.rs", + crate_root = "pyo3-derive-backend/src/lib.rs", edition = "2018", rustc_flags = [ "--cap-lints=allow", diff --git a/cargo/remote/pyo3cls-0.12.3.BUILD.bazel b/cargo/remote/pyo3cls-0.12.3.BUILD.bazel index a34fb662d..2bc1c09b1 100644 --- a/cargo/remote/pyo3cls-0.12.3.BUILD.bazel +++ b/cargo/remote/pyo3cls-0.12.3.BUILD.bazel @@ -40,7 +40,7 @@ rust_library( "@raze__syn__1_0_48//:syn", ], srcs = glob(["**/*.rs"]), - crate_root = "src/lib.rs", + crate_root = "pyo3cls/src/lib.rs", edition = "2018", rustc_flags = [ "--cap-lints=allow", diff --git a/cargo/update.py b/cargo/update.py index 4578b8d75..074ecba9f 100644 --- a/cargo/update.py +++ b/cargo/update.py @@ -3,7 +3,7 @@ # See README.md EXTRA_DEPS = [ - 'pyo3 = { version = "0.12.3", features = ["extension-module"] }' + 'pyo3 = { git = "https://github.com/PyO3/pyo3.git", rev = "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1", features = ["extension-module", "abi3"] }' ] # If you get a message like the following during a build: @@ -25,6 +25,8 @@ COMMITS_SHALLOW_SINCE = { "4ded4a98ef339da0b7babd4efee3fbe8adaf746b": "1598739849 -0700", # coarsetime "f9e2c86216f0f4803bc75404828318fc206dab29": "1594611111 +1000", + # pyo3 + "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1": "1603809036 +0900", } import os diff --git a/pylib/rsbridge/Cargo.toml b/pylib/rsbridge/Cargo.toml index 42469218a..5a8f64e7f 100644 --- a/pylib/rsbridge/Cargo.toml +++ b/pylib/rsbridge/Cargo.toml @@ -12,8 +12,9 @@ anki = { path = "../../rslib" } # WARNING: if changing the version number here, the version in ../../cargo/update.py # needs to be updated as well [dependencies.pyo3] -version = "0.12.0" -features = ["extension-module"] +git = "https://github.com/PyO3/pyo3.git" +rev = "3b3ba4e3abd57bc3b8f86444b3f61e6e2f4c5fc1" +features = ["extension-module", "abi3"] [lib] name = "rsbridge" diff --git a/pylib/rsbridge/lib.rs b/pylib/rsbridge/lib.rs index 2f5583079..afff8c7ac 100644 --- a/pylib/rsbridge/lib.rs +++ b/pylib/rsbridge/lib.rs @@ -11,7 +11,7 @@ use std::convert::TryFrom; // Regular backend ////////////////////////////////// -#[pyclass] +#[pyclass(module = "_rsbridge")] struct Backend { backend: RustBackend, }