gnu: python-cryptography: Switch to pyproject-build-system.

* gnu/packages/python-crypto.scm (python-cryptography)
[inputs]: Use ‘cargo-inputs’.
Remove python-wrapper.
[native-inputs]: Add rust, rust:cargo.
Add rust-sysroot when cross-compiling.
[arguments]: Remove #:cargo-inputs.
<#:phases>: Add ‘prepare-cargo-build-system’.
Remove phases provided by pyproject-build-system.
* gnu/packages/rust-crates.scm (lookup-cargo-inputs)[python-cryptography]: New
entry.

Change-Id: I22a0ad4c7093c1323e0f61fc50d4337abb6635e9
This commit is contained in:
Hilton Chain 2025-03-03 22:24:22 +08:00
parent 454c7a8ebf
commit ad275db594
No known key found for this signature in database
GPG key ID: ACC66D09CA528292
2 changed files with 118 additions and 40 deletions

View file

@ -75,6 +75,7 @@
#:use-module (gnu packages python-compression)
#:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages rust)
#:use-module (gnu packages rust-apps)
#:use-module (gnu packages swig)
#:use-module (gnu packages time)
@ -538,54 +539,50 @@ is used by the Requests library to verify HTTPS requests.")
(find-files "." "Cargo\\.lock$"))
(substitute* "pyproject.toml"
(("locked = true") "offline = true"))))))
(build-system cargo-build-system)
(build-system pyproject-build-system)
(arguments
(list
#:imported-modules `(,@%cargo-build-system-modules
,@%pyproject-build-system-modules)
#:modules '((guix build cargo-build-system)
((guix build pyproject-build-system) #:prefix py:)
#:modules '(((guix build cargo-build-system) #:prefix cargo:)
(guix build pyproject-build-system)
(guix build utils))
#:cargo-inputs
(list rust-asn1-0.20
rust-cc-1
rust-cfg-if-1
rust-foreign-types-0.3
rust-foreign-types-shared-0.1
rust-once-cell-1
rust-openssl-0.10
rust-openssl-sys-0.9
rust-pem-3
rust-pyo3-0.23
rust-self-cell-1)
#:install-source? #false
#:phases
#~(modify-phases %standard-phases
(replace 'build
(assoc-ref py:%standard-phases 'build))
(delete 'check)
(add-after 'install 'check
(lambda* (#:key tests? inputs outputs #:allow-other-keys)
(when tests?
(py:add-installed-pythonpath inputs outputs)
(invoke "python" "-m" "pytest" "tests"))))
(replace 'install
(assoc-ref py:%standard-phases 'install)))))
(add-after 'unpack 'prepare-cargo-build-system
(lambda args
(for-each
(lambda (phase)
(format #t "Running cargo phase: ~a~%" phase)
(apply (assoc-ref cargo:%standard-phases phase)
#:cargo-target #$(cargo-triplet)
args))
'(unpack-rust-crates
configure
check-for-pregenerated-files
patch-cargo-checksums)))))))
(native-inputs
(list python-certifi
python-cffi
python-click
python-cryptography-vectors
python-mypy
python-pretend
python-pytest
python-pytest-benchmark
python-pytest-cov
python-pytest-randomly
python-pytest-xdist
python-setuptools
python-wheel))
(inputs (list maturin openssl python-wrapper))
(append
(list python-certifi
python-cffi
python-click
python-cryptography-vectors
python-mypy
python-pretend
python-pytest
python-pytest-benchmark
python-pytest-cov
python-pytest-randomly
python-pytest-xdist
python-setuptools
python-wheel
rust
`(,rust "cargo"))
(or (and=> (%current-target-system)
(compose list make-rust-sysroot))
'())))
(inputs
(cons* maturin openssl (cargo-inputs 'python-cryptography)))
(propagated-inputs (list python-cffi))
(home-page "https://github.com/pyca/cryptography")
(synopsis "Cryptographic recipes and primitives for Python")