summary refs log tree commit diff
path: root/gnu/packages/python-crypto.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-27 14:24:37 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2022-09-27 14:27:28 -0400
commit3c6e220d8100281074c414a43c1efe9a01b53771 (patch)
treedc5d47fbbac3842d0da893adcd398dea10c1e681 /gnu/packages/python-crypto.scm
parent08473753a0ebafef22c0894d846e3b42fd6be2a2 (diff)
parent62048ff9fcfbe3fc790a7207fc5f6f3e0476a02a (diff)
downloadguix-3c6e220d8100281074c414a43c1efe9a01b53771.tar.gz
Merge branch 'master' into staging.
With resolved conflicts in:
	gnu/local.mk
	gnu/packages/crates-io.scm
Diffstat (limited to 'gnu/packages/python-crypto.scm')
-rw-r--r--gnu/packages/python-crypto.scm81
1 files changed, 81 insertions, 0 deletions
diff --git a/gnu/packages/python-crypto.scm b/gnu/packages/python-crypto.scm
index 417f9c5a34..dfc0bad7a0 100644
--- a/gnu/packages/python-crypto.scm
+++ b/gnu/packages/python-crypto.scm
@@ -50,6 +50,7 @@
   #: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 @@ general production use.  Include this module and use its backends at your own
 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")