gnu: Add maturin.

* gnu/packages/rust-apps.scm (maturin): New variable.
* gnu/packages/patches/maturin-no-cross-compile.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
This commit is contained in:
Efraim Flashner 2023-08-06 10:22:00 +03:00
parent 3cb37724ff
commit c08da95dae
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351
3 changed files with 221 additions and 0 deletions

View file

@ -1596,6 +1596,7 @@ dist_patch_DATA = \
%D%/packages/patches/libmemcached-build-with-gcc7.patch \
%D%/packages/patches/libmhash-hmac-fix-uaf.patch \
%D%/packages/patches/libsigrokdecode-python3.9-fix.patch \
%D%/packages/patches/maturin-no-cross-compile.patch \
%D%/packages/patches/mecab-variable-param.patch \
%D%/packages/patches/memtest86+-build-reproducibly.patch \
%D%/packages/patches/mercurial-hg-extension-path.patch \

View file

@ -0,0 +1,55 @@
Remove dependencies on xwin and zig. We're not offering cross-compilation
options using these crates.
diff --git a/Cargo.toml b/Cargo.toml
index 6cbdca3..22ea5ef 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -76,16 +76,6 @@ version = "0.1.4"
[dependencies.cargo-options]
version = "0.6.0"
-[dependencies.cargo-xwin]
-version = "0.14.3"
-optional = true
-default-features = false
-
-[dependencies.cargo-zigbuild]
-version = "0.16.10"
-optional = true
-default-features = false
-
[dependencies.cargo_metadata]
version = "0.15.3"
@@ -310,8 +300,6 @@ version = "4.3.0"
[features]
cli-completion = ["dep:clap_complete_command"]
cross-compile = [
- "zig",
- "xwin",
]
default = [
"full",
@@ -330,7 +318,6 @@ log = ["tracing-subscriber"]
native-tls = [
"dep:native-tls",
"ureq?/native-tls",
- "cargo-xwin?/native-tls",
"dep:rustls-pemfile",
]
password-storage = [
@@ -340,7 +327,6 @@ password-storage = [
rustls = [
"dep:rustls",
"ureq?/tls",
- "cargo-xwin?/rustls-tls",
"dep:rustls-pemfile",
]
scaffolding = [
@@ -358,5 +344,3 @@ upload = [
"wild",
"dep:dirs",
]
-xwin = ["cargo-xwin"]
-zig = ["cargo-zigbuild"]

View file

@ -41,6 +41,7 @@
(define-module (gnu packages rust-apps)
#:use-module (guix build-system cargo)
#:use-module (guix build-system pyproject)
#:use-module (guix deprecation)
#:use-module (guix download)
#:use-module (guix gexp)
@ -74,6 +75,8 @@ (define-module (gnu packages rust-apps)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages rust)
#:use-module (gnu packages tls)
@ -734,6 +737,168 @@ (define-public i3status-rust
bar. It is also compatible with sway.")
(license license:gpl3)))
(define-public maturin
(package
(name "maturin")
(version "1.1.0")
(source (origin
(method url-fetch)
(uri (crate-uri "maturin" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
(base32
"0asdljd396kdsvnx9kbsr5s0x6w73b59kdpx732333dhm13qgn03"))
(patches (search-patches "maturin-no-cross-compile.patch"))))
(build-system cargo-build-system)
(arguments
`(#:modules ((guix build cargo-build-system)
((guix build pyproject-build-system) #:prefix py:)
(guix build utils))
#:imported-modules ((guix build cargo-build-system)
(guix build cargo-utils)
,@%pyproject-build-system-modules)
#:install-source? #f
#:cargo-test-flags
'("--release" "--"
;; Not all files are included.
"--skip=build_options::test::test_find_bridge_bin"
"--skip=build_options::test::test_find_bridge_cffi"
"--skip=build_options::test::test_find_bridge_pyo3"
"--skip=build_options::test::test_find_bridge_pyo3_abi3"
"--skip=build_options::test::test_find_bridge_pyo3_feature"
"--skip=metadata::test::test_implicit_readme"
"--skip=metadata::test::test_merge_metadata_from_pyproject_dynamic_license_test"
"--skip=metadata::test::test_merge_metadata_from_pyproject_toml"
"--skip=metadata::test::test_merge_metadata_from_pyproject_toml_with_customized_python_source_dir"
"--skip=pyproject_toml::tests::test_warn_missing_maturin_version")
#:cargo-inputs
(("rust-anyhow" ,rust-anyhow-1)
("rust-base64" ,rust-base64-0.21)
("rust-bytesize" ,rust-bytesize-1)
("rust-cargo-config2" ,rust-cargo-config2-0.1)
("rust-cargo-options" ,rust-cargo-options-0.6)
;("rust-cargo-xwin" ,rust-cargo-xwin-0.14)
;("rust-cargo-zigbuild" ,rust-cargo-zigbuild-0.16)
("rust-cargo-metadata" ,rust-cargo-metadata-0.15)
("rust-cbindgen" ,rust-cbindgen-0.24)
("rust-cc" ,rust-cc-1)
("rust-clap" ,rust-clap-4)
("rust-clap-complete-command" ,rust-clap-complete-command-0.5)
("rust-configparser" ,rust-configparser-3)
("rust-console" ,rust-console-0.15)
("rust-dialoguer" ,rust-dialoguer-0.10)
("rust-dirs" ,rust-dirs-5)
("rust-dunce" ,rust-dunce-1)
("rust-fat-macho" ,rust-fat-macho-0.4)
("rust-flate2" ,rust-flate2-1)
("rust-fs-err" ,rust-fs-err-2)
("rust-glob" ,rust-glob-0.3)
("rust-goblin" ,rust-goblin-0.6)
("rust-ignore" ,rust-ignore-0.4)
("rust-indexmap" ,rust-indexmap-1)
("rust-itertools" ,rust-itertools-0.10)
("rust-keyring" ,rust-keyring-2)
("rust-lddtree" ,rust-lddtree-0.3)
("rust-minijinja" ,rust-minijinja-0.34)
("rust-multipart" ,rust-multipart-0.18)
("rust-native-tls" ,rust-native-tls-0.2)
("rust-normpath" ,rust-normpath-1)
("rust-once-cell" ,rust-once-cell-1)
("rust-pep440-rs" ,rust-pep440-rs-0.3)
("rust-pep508-rs" ,rust-pep508-rs-0.2)
("rust-platform-info" ,rust-platform-info-2)
("rust-pyproject-toml" ,rust-pyproject-toml-0.6)
("rust-python-pkginfo" ,rust-python-pkginfo-0.5)
("rust-regex" ,rust-regex-1)
("rust-rustc-version" ,rust-rustc-version-0.4)
("rust-rustls" ,rust-rustls-0.20)
("rust-rustls-pemfile" ,rust-rustls-pemfile-1)
("rust-same-file" ,rust-same-file-1)
("rust-semver" ,rust-semver-1)
("rust-serde" ,rust-serde-1)
("rust-serde-json" ,rust-serde-json-1)
("rust-sha2" ,rust-sha2-0.10)
("rust-tar" ,rust-tar-0.4)
("rust-target-lexicon" ,rust-target-lexicon-0.12)
("rust-tempfile" ,rust-tempfile-3)
("rust-textwrap" ,rust-textwrap-0.16)
("rust-thiserror" ,rust-thiserror-1)
("rust-time" ,rust-time-0.3)
("rust-toml" ,rust-toml-0.7)
("rust-toml-edit" ,rust-toml-edit-0.19)
("rust-tracing" ,rust-tracing-0.1)
("rust-tracing-subscriber" ,rust-tracing-subscriber-0.3)
("rust-ureq" ,rust-ureq-2)
("rust-url" ,rust-url-2)
("rust-wild" ,rust-wild-2)
("rust-zip" ,rust-zip-0.6))
#:cargo-development-inputs
(("rust-indoc" ,rust-indoc-2)
("rust-pretty-assertions" ,rust-pretty-assertions-1)
("rust-rustversion" ,rust-rustversion-1)
("rust-time" ,rust-time-0.3)
("rust-trycmd" ,rust-trycmd-0.14)
("rust-which" ,rust-which-4))
#:phases
(modify-phases %standard-phases
(add-after 'build 'build-python-module
(lambda _
;; Match the features from the cargo-build-system and Cargo.toml.
(setenv "MATURIN_SETUP_ARGS" "--features=default")
((assoc-ref py:%standard-phases 'build))))
;; We can't use the pyproject install phase because maturin is a
;; binary, not a python script.
(add-after 'install 'install-python-module
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(wheel (car (find-files "dist" "\\.whl$")))
(site-dir (py:site-packages inputs outputs))
(pyversion
(string-append "python"
(py:python-version
(assoc-ref inputs "python-wrapper")))))
(invoke "python" "-m" "zipfile" "-e" wheel site-dir)
(mkdir-p (string-append out "/bin"))
(for-each delete-file
(find-files (string-append out "/lib/" pyversion)
"^maturin$")))))
(add-after 'install 'install-completions
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(share (string-append out "/share"))
(maturin (string-append out "/bin/maturin")))
;; TODO? fig, nushell, powershell
(mkdir-p (string-append share "/bash-completion/completions"))
(with-output-to-file
(string-append share "/bash-completion/completions/maturin")
(lambda _ (invoke maturin "completions" "bash")))
(mkdir-p (string-append share "/fish/vendor_completions.d"))
(with-output-to-file
(string-append share "/fish/vendor_completions.d/maturin.fish")
(lambda _ (invoke maturin "completions" "fish")))
(mkdir-p (string-append share "/zsh/site-functions"))
(with-output-to-file
(string-append share "/zsh/site-functions/_maturin")
(lambda _ (invoke maturin "completions" "zsh")))
(mkdir-p (string-append share "/elvish/lib"))
(with-output-to-file
(string-append share "/elvish/lib/maturin")
(lambda _ (invoke maturin "completions" "elvish")))))))))
(propagated-inputs
(list python-tomli))
(native-inputs
(list perl
python-wheel
python-wrapper
python-setuptools-rust))
(home-page "https://github.com/pyo3/maturin")
(synopsis "Build and publish crates and python packages")
(description
"Build and publish crates with @code{pyo3}, @code{rust-cpython} and
@code{cffi} bindings as well as rust binaries as python packages.")
(license (list license:expat license:asl2.0))))
(define-public ripgrep
(package
(name "ripgrep")