Subject: [2/5] gnu: Add python-coincurve

From: [email-masked]
Date: Sun, 27 Oct 2024 01:58:32 +0200

From: Jesse Eisses <[email-masked]>

Change-Id: I2acb09def9193247b1e4169321cf22bdb77c9960
---
 gnu/packages/finance.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index 59a11e6925..c3ff34e0cc 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -109,6 +109,7 @@ (define-module (gnu packages finance)
   #:use-module (gnu packages jemalloc)
   #:use-module (gnu packages libedit)
   #:use-module (gnu packages libevent)
+  #:use-module (gnu packages libffi)
   #:use-module (gnu packages libunwind)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
@@ -1118,6 +1119,35 @@ (define-public python-ledgercomm
     (description "Library to communicate with Ledger Nano S/X and Speculos")
     (license license:expat)))
 
+(define-public python-coincurve
+  (package
+    (name "python-coincurve")
+    (version "18.0.0")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "coincurve" version))
+              (sha256
+               (base32
+                "1hagr7hicfc1hkg5lfxj0di53bp3rbpq0rz5h279v80pwjpjcrn8"))))
+    (build-system pyproject-build-system)
+    (propagated-inputs (list python-asn1crypto python-cffi))
+    (home-page "https://pypi.org/project/coincurve")
+    (inputs (list libsecp256k1))
+    (native-inputs (list autoconf automake libtool pkg-config))
+    (arguments
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (delete 'check)
+               (add-after 'unpack 'use-libsecp256k1-input
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let ((lib-dir (string-append
+                                   (assoc-ref inputs "libsecp256k1") "/lib")))
+                     (setenv "LIB_DIR" lib-dir)))))))
+    (synopsis "Cross-platform Python CFFI bindings for libsecp256k1")
+    (description "Cross-platform Python CFFI bindings for libsecp256k1")
+    (license (list license:asl2.0
+                   license:expat))))
+
 (define-public python-trezor
   (package
     (name "python-trezor")
-- 
2.46.0