-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cryptography 42 and rust #1261
Cryptography 42 and rust #1261
Conversation
This allows compiling Rust modules depending on pyo3 >= 0.16.4, provided that module specifies a abi3-py* compatibility feature and that the Rust compiler and toolchains are installed in the build machine
They include modules which are locate into the cargo home and libs located under the rustup toolchains dir, which are outside of the source directory of valid_dirs
setuptools_rust/build.py", line 470, in get_dylib_ext_path host_arch = host_platform.rsplit("-", 1)[1] IndexError: list index out of range Closes chaquo#1141
Cryptography 42.0.8 can now be built provided that the Rust compiler and toolchains are installed into the build machine. Note: legacy ciphers are disabled to prevent load-time crash as if the CRYPTOGRAPHY_OPENSSL_NO_LEGACY environment variable was set. https://cryptography.io/en/latest/openssl/#legacy-provider-in-openssl-3-x Closes chaquo#657
Thanks very much, I'll look at this as soon as I can. |
@emanuele-f thank you so much for your contributions! I've seen your email around here somewhere... any chance I can shoot you a direct message or Email somewhere? I could really use your help and we are happy to pay you if you could help us solve our current issues. Edit: |
Hi @Michu44 , which python version are you targetting? I only tested this with Python 3.10. After installing the rust toolchain and android targets as explained above, you should be able to build cryprography as any normal wheel, with the standard build-wheel.py invocation. Which errors do you get? My email is [email protected] but probably better to discuss here, as it would be beneficial for other people too. Also my intention is to allow anyone to build this without any issues |
Ps. building cryptography 43.0.1 for Python 3.10 from this PR branch requires minimal changes, just apply the following patch: diff --git a/server/pypi/packages/cryptography/meta.yaml b/server/pypi/packages/cryptography/meta.yaml
index 0d042e84..59e63fd0 100644
--- a/server/pypi/packages/cryptography/meta.yaml
+++ b/server/pypi/packages/cryptography/meta.yaml
@@ -1,6 +1,6 @@
package:
name: cryptography
- version: "42.0.8"
+ version: "43.0.1"
requirements:
build:
diff --git a/server/pypi/packages/cryptography/patches/pyo3_no_interpreter.patch b/server/pypi/packages/cryptography/patches/pyo3_no_interpreter.patch
index 3f03ced5..2d0b9d65 100644
--- a/server/pypi/packages/cryptography/patches/pyo3_no_interpreter.patch
+++ b/server/pypi/packages/cryptography/patches/pyo3_no_interpreter.patch
@@ -1,11 +1,11 @@
--- src-original/src/rust/Cargo.toml
+++ src/src/rust/Cargo.toml
-@@ -10,7 +10,7 @@
+@@ -17,7 +17,7 @@
[dependencies]
once_cell = "1"
cfg-if = "1"
--pyo3 = { version = "0.20", features = ["abi3"] }
-+pyo3 = { version = "0.20", features = ["abi3", "abi3-py310"] }
- asn1 = { version = "0.15.5", default-features = false }
+-pyo3 = { version = "0.22.2", features = ["abi3"] }
++pyo3 = { version = "0.22.2", features = ["abi3", "abi3-py310"] }
+ asn1 = { version = "0.16.2", default-features = false }
cryptography-cffi = { path = "cryptography-cffi" }
- cryptography-key-parsing = { path = "cryptography-key-parsing" }
+ cryptography-keepalive = { path = "cryptography-keepalive" } |
@emanuele-f Thank you so much for the patch. I'll try and build this using your current code base then. |
@emanuele-f I'm targeting either 3.10 or 3.11 as pyatv is working on both. |
I've now released |
Awesome, thanks @mhsmith ! |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
These comments would be more useful on the |
This adds support for building PyO3 modules like
cryptography
which depend onpyo3 >= 0.16.4
.Building rust modules requires installing the rust compiler android targets as follows:
Compared to #657, it's now possible to compile the cryptography module without issues because they migrated to PyO3 0.20, which removes the need to rebuild python, as sysconfig modules are not needed.
Moreover, since chaquopy updated the ndk to 26, this fixes
ld: error: unable to find library -lunwind
in recent Rust versions (see rust-lang/rust#103673), removing the constrain to use old Rust versions like 1.60; it's now possible to just use the latest stable Rust version. For example, it's now possible to compile the latestmitmproxy_rs
module which requires a recent Rust version (see https://github.com/emanuele-f/chaquopy/tree/mitmproxy-11/server/pypi/packages/mitmproxy-rs); a separate PR will be provided to include this module in the supported packages.Ps. double check if 4461dda breaks anything, as I can see that #1141 is still open even if the issue was identified.