unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#63422] [PATCH 2/3] gnu: libfive: Add Python bindings.
       [not found] <c6e9290bb908170ceb04988ee95e73f4995368b9.1683740776.git.Morgan.J.Smith@outlook.com>
@ 2023-05-10 17:46 ` Morgan Smith
  2023-05-10 17:46 ` [bug#63422] [PATCH 3/3] gnu: libfive: Generate bindings instead of using pre-generated ones Morgan Smith
  1 sibling, 0 replies; 2+ messages in thread
From: Morgan Smith @ 2023-05-10 17:46 UTC (permalink / raw)
  To: 63422

* gnu/packages/engineering.scm (libfive)
[configure-flags]: Add python site-dir.
[phases]<fix-library-location>: Fix for python as well.
<wrap-studio>: Wrap for python as well.
[inputs]: Add python-wrapper.  Alphabetize.
[description]: Add python.
---
 gnu/packages/engineering.scm | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index 1f7fdf942f..be7e235fcc 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -914,6 +914,14 @@ (define-public libfive
                     ((guix build guile-build-system) #:prefix guile:)
                     (guix build utils))
         #:test-target "libfive-test"
+        #:configure-flags #~(list
+                             (string-append
+                              "-DPYTHON_SITE_PACKAGES_DIR="
+                              #$output "/lib/python"
+                              #$(version-major+minor
+                                 (package-version
+                                  (this-package-input "python-wrapper")))
+                              "/site-packages"))
         #:phases
         #~(modify-phases %standard-phases
             (add-after 'unpack 'remove-native-compilation
@@ -929,7 +937,10 @@ (define-public libfive
                   (("\\(get-environment-variable \"LIBFIVE_FRAMEWORK_DIR\"\\)" m)
                    (string-append m "\n\"" #$output "/lib/\""))
                   (("\\(get-environment-variable \"LIBFIVE_STDLIB_DIR\"\\)" m)
-                   (string-append m "\n\"" #$output "/lib/\"")))))
+                   (string-append m "\n\"" #$output "/lib/\"")))
+                (substitute* "libfive/bind/python/libfive/ffi.py"
+                  (("os.environ.get\\('LIBFIVE_FRAMEWORK_DIR'\\)" m)
+                   (string-append m " or \"" #$output "/lib/\"")))))
             (add-after 'unpack 'do-not-build-guile-bindings
               (lambda _
                 (delete-file "libfive/bind/guile/CMakeLists.txt")
@@ -948,22 +959,28 @@ (define-public libfive
                        (scm (string-append #$output "/share/guile/site/"
                                            effective-version))
                        (go (string-append #$output "/lib/guile/"
-                                          effective-version "/site-ccache")))
+                                          effective-version "/site-ccache"))
+                       (py (string-append #$output "/lib/python"
+                                          #$(version-major+minor
+                                             (package-version
+                                              (this-package-input "python-wrapper")))
+                                          "/site-packages")))
                   (wrap-program (string-append #$output "/bin/Studio")
                     `("GUILE_LOAD_PATH" ":" prefix (,scm))
-                    `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,go)))))))))
+                    `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,go))
+                    `("GUIX_PYTHONPATH" ":" prefix (,py)))))))))
       (native-inputs
        (list pkg-config))
       (inputs
-       (list boost libpng qtbase eigen guile-3.0 bash-minimal))
+       (list bash-minimal boost eigen guile-3.0 libpng python-wrapper qtbase))
       (home-page "https://libfive.com")
       (synopsis "Tool for programmatic computer-aided design")
       (description
        "Libfive is a tool for programmatic computer-aided design (CAD).  In
-libfive, solid models are defined as Scheme scripts, and there are no opaque
-function calls into the geometry kernel: everything is visible to the user.
-Even fundamental, primitive shapes are represented as code in the user-level
-language.")
+libfive, solid models are defined as Scheme or Python scripts, and there are
+no opaque function calls into the geometry kernel: everything is visible to
+the user.  Even fundamental, primitive shapes are represented as code in the
+user-level language.")
       (license (list license:mpl2.0               ;library
                      license:gpl2+))              ;Guile bindings and GUI
 
-- 
2.39.2





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [bug#63422] [PATCH 3/3] gnu: libfive: Generate bindings instead of using pre-generated ones.
       [not found] <c6e9290bb908170ceb04988ee95e73f4995368b9.1683740776.git.Morgan.J.Smith@outlook.com>
  2023-05-10 17:46 ` [bug#63422] [PATCH 2/3] gnu: libfive: Add Python bindings Morgan Smith
@ 2023-05-10 17:46 ` Morgan Smith
  1 sibling, 0 replies; 2+ messages in thread
From: Morgan Smith @ 2023-05-10 17:46 UTC (permalink / raw)
  To: 63422

* 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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-10 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <c6e9290bb908170ceb04988ee95e73f4995368b9.1683740776.git.Morgan.J.Smith@outlook.com>
2023-05-10 17:46 ` [bug#63422] [PATCH 2/3] gnu: libfive: Add Python bindings Morgan Smith
2023-05-10 17:46 ` [bug#63422] [PATCH 3/3] gnu: libfive: Generate bindings instead of using pre-generated ones Morgan Smith

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).