Subject: [bug#49123] [PATCH 02/24] gnu: libolm: Add python bindings output.

From: slg <[email-masked]>
Date: Sat, 19 Jun 2021 22:07:20 -0300

* gnu/packages/crypto.scm (libolm): Add python bindings
---
 gnu/packages/crypto.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/crypto.scm b/gnu/packages/crypto.scm
index 99455dc632..b1cfd46adc 100644
--- a/gnu/packages/crypto.scm
+++ b/gnu/packages/crypto.scm
@@ -1310,13 +1310,30 @@ Trusted comments are signed, thus verified, before being displayed.")
                 "0bixly6jqpwfx3p37c1qp1j685yg6m429r1nazwh43w4n527bs3y"))
               (file-name (git-file-name name version))))
     (build-system cmake-build-system)
+    (outputs '("out" "python"))
+    (propagated-inputs
+     `(("python-cffi" ,python-cffi)))
+    (native-inputs
+     `(("python" ,python-wrapper)))
     (arguments
      `(#:phases
        (modify-phases %standard-phases
          (replace 'check
            (lambda _
              (with-directory-excursion "tests"
-               (invoke "ctest" ".")))))))
+               (invoke "ctest" "."))))
+         (add-after 'install 'install-python-binding
+           (lambda* (#:key outputs #:allow-other-keys)
+             (with-directory-excursion "../source/python"
+               (invoke "make" "headers" "CPP=cpp") ;; Somehow default $(CPP) is cc?
+               (invoke "python" "setup.py" "build_ext"
+                       (string-append "--library-dirs="
+                                      (assoc-ref outputs "out")
+                                      "/lib"))
+               (invoke "python" "setup.py" "install"
+                       (string-append "--prefix="
+                                      (assoc-ref outputs "python"))
+                       "--root=/")))))))
     (synopsis "Implementation of the olm and megolm cryptographic ratchets")
     (description "The libolm library implements the Double Ratchet
 cryptographic ratchet.  It is written in C and C++11, and exposed as a C
-- 
2.32.0