From eefc107aaf6599f2778ccf27ee82d8acfdd3bbc0 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 24 Sep 2022 14:01:07 +0200 Subject: gnu: Add python-blake3. * gnu/packages/python-crypto.scm (python-blake3): New variable. --- gnu/packages/python-crypto.scm | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'gnu/packages') diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm index dc9079cd41..d8e52225c1 100644 --- a/gnu/packages/python-crypto.scm +++ b/gnu/packages/python-crypto.scm @@ -50,6 +50,7 @@ (define-module (gnu packages python-crypto) #:use-module (guix git-download) #:use-module (guix build-system cargo) #:use-module (guix build-system python) + #:use-module (guix utils) #:use-module (gnu packages) #:use-module (gnu packages check) #:use-module (gnu packages crates-io) @@ -394,6 +395,86 @@ (define-public python-keyrings.alt risk.") (license license:expat))) +(define-public python-blake3 + (package + (name "python-blake3") + (version "0.3.1") + (source + (origin + (method url-fetch) + (uri (pypi-uri "blake3" version)) + (sha256 + (base32 "1p6z6jfk8n1lshz4cp6dgz2i8zmqdxwr8d9m86ypp3m1kp70k5xk")))) + (build-system cargo-build-system) + (arguments + (list + #:phases + #~(modify-phases %standard-phases + (add-after 'install 'build-python-module + (lambda _ + ;; We don't use maturin. + (delete-file "pyproject.toml") + (call-with-output-file "pyproject.toml" + (lambda (port) + (format port "\ +[build-system] +build-backend = 'setuptools.build_meta' +requires = ['setuptools'] +"))) + (call-with-output-file "setup.cfg" + (lambda (port) + (format port "\ + +[metadata] +name = blake3 +version = '~a' + +[options] +packages = find: + +[options.packages.find] +exclude = + src* + c_impl* + tests* + Cargo.toml +" #$version))) + ;; ZIP does not support timestamps before 1980. + (setenv "SOURCE_DATE_EPOCH" "315532800") + (invoke "python" "-m" "build" "--wheel" "--no-isolation" "."))) + (add-after 'build-python-module 'install-python-module + (lambda* (#:key outputs #:allow-other-keys) + (let ((whl (car (find-files "dist" "\\.whl$")))) + (invoke "pip" "--no-cache-dir" "--no-input" + "install" "--no-deps" "--prefix" #$output whl)))) + (add-after 'install-python-module 'install-python-library + (lambda _ + (let ((site (string-append #$output "/lib/python" + #$(version-major+minor + (package-version python)) + "/site-packages"))) + (mkdir-p site) + (copy-file "target/release/libblake3.so" + (string-append site "/blake3.so")))))) + #:cargo-inputs + `(("rust-blake3" ,rust-blake3-1) + ("rust-hex" ,rust-hex-0.4) + ("rust-parking-lot" ,rust-parking-lot-0.11) + ("rust-pyo3" ,rust-pyo3-0.15) + ("rust-rayon" ,rust-rayon-1)))) + (inputs (list rust-blake3-1)) + (native-inputs + (list python-wrapper + python-pypa-build + python-wheel)) + (home-page "https://github.com/oconnor663/blake3-py") + (synopsis "Python bindings for the Rust blake3 crate") + (description "This package provides Python bindings for the Rust crate of +blake3, a cryptographic hash function.") + ;; This work is released into the public domain with CC0 + ;; 1.0. Alternatively, it is licensed under the Apache License 2.0. + (license (list license:asl2.0 license:cc0)))) + (define-public python-certauth (package (name "python-certauth") -- cgit v1.2.3