Subject: [PATCH 3/3] gnu: libfive: Generate bindings instead of using pre-generated ones.

From: Morgan Smith <[email-masked]>
Date: Wed, 10 May 2023 13:46:20 -0400

* gnu/packages/engineering.scm (libfive)[phases]: Add phase 'generate-bindings
to generate the bindings
---
 gnu/packages/engineering.scm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index be7e235fcc..ec3071129e 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -941,6 +941,16 @@ (define-public libfive
                 (substitute* "libfive/bind/python/libfive/ffi.py"
                   (("os.environ.get\\('LIBFIVE_FRAMEWORK_DIR'\\)" m)
                    (string-append m " or \"" #$output "/lib/\"")))))
+            (add-before 'build 'generate-bindings
+              (lambda _
+                ;; These files already exist but we regenerate them from source
+                (with-directory-excursion "../source/libfive/stdlib"
+                  (substitute* '("gen_scm.py" "gen_c.py" "gen_py.py")
+                    (("datetime.now\\(\\)\\.strftime\\([^)]+)") "\"N/A\"")
+                    (("os\\.getlogin\\(\\)") "\"guix\""))
+                  (invoke "python" "gen_scm.py")
+                  (invoke "python" "gen_c.py")
+                  (invoke "python" "gen_py.py"))))
             (add-after 'unpack 'do-not-build-guile-bindings
               (lambda _
                 (delete-file "libfive/bind/guile/CMakeLists.txt")
-- 
2.39.2