[PATCH 0/3] gnu: libfive: Fixes

  • Done
  • quality assurance status badge
Details
2 participants
  • Morgan.J.Smith
  • Ludovic Courtès
Owner
unassigned
Submitted by
Morgan.J.Smith
Severity
normal

Debbugs page

Morgan.J.Smith wrote 2 years ago
(address . guix-patches@gnu.org)
DM5PR03MB3163C42B52896A2D9BCFF6C2C5779@DM5PR03MB3163.namprd03.prod.outlook.com
[PATCH 1/3] gnu: libfive: Fix install and wrap Studio.
[PATCH 2/3] gnu: libfive: Add Python bindings.
[PATCH 3/3] gnu: libfive: Generate bindings instead of using
Morgan Smith wrote 2 years ago
[PATCH 1/3] gnu: libfive: Fix install and wrap Studio.
(address . 63422@debbugs.gnu.org)
DM5PR03MB316381DE47E6EE191E3598A0C5779@DM5PR03MB3163.namprd03.prod.outlook.com
The old install phase didn't handle nested directories (which there are) and
the cmake files didn't seem to install the go files in a way that guile would
use so I just used the guile build system instead.

Also Studio works much better when it know where the libraries are.

* gnu/packages/engineering.scm (libfive)
[imported-modules]: Add (guix build guile-build-system).
[modules]: Add (guix build guile-build-system).
[configure-flags]: Remove.
[phases]: Remove phases 'fix-autocompilation and 'install-scm-files. Add
phase 'do-not-build-guile-bindings and add phase 'guile-build which uses the
guile build system. Add wrap-studio phase.
[inputs]: Add bash-minimal for the wrapper. Use qtbase instead of qtbase-5
---
gnu/packages/engineering.scm | 47 ++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 15 deletions(-)

Toggle diff (86 lines)
diff --git a/gnu/packages/engineering.scm b/gnu/packages/engineering.scm
index a8261dfbc1..1f7fdf942f 100644
--- a/gnu/packages/engineering.scm
+++ b/gnu/packages/engineering.scm
@@ -20,7 +20,7 @@
;;; Copyright © 2020, 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
;;; Copyright © 2020 B. Wilson <elaexuotee@wilsonb.com>
;;; Copyright © 2020, 2021, 2022, 2023 Vinicius Monego <monego@posteo.net>
-;;; Copyright © 2020, 2021 Morgan Smith <Morgan.J.Smith@outlook.com>
+;;; Copyright © 2020, 2021, 2023 Morgan Smith <Morgan.J.Smith@outlook.com>
;;; Copyright © 2021 qblade <qblade@protonmail.com>
;;; Copyright © 2021 Gerd Heber <gerd.heber@gmail.com>
;;; Copyright © 2021, 2022 Guillaume Le Vaillant <glv@posteo.net>
@@ -908,17 +908,21 @@ (define-public libfive
(build-system cmake-build-system)
(arguments
(list
+ #:imported-modules `((guix build guile-build-system)
+ ,@%cmake-build-system-modules)
+ #:modules '((guix build cmake-build-system)
+ ((guix build guile-build-system) #:prefix guile:)
+ (guix build utils))
#:test-target "libfive-test"
- #:configure-flags
- #~(list (string-append "-DGUILE_CCACHE_DIR="
- #$output "/lib/guile/3.0/site-ccache"))
#:phases
#~(modify-phases %standard-phases
- (add-after 'unpack 'fix-autocompilation
- (lambda _ (setenv "HOME" "/tmp")))
(add-after 'unpack 'remove-native-compilation
(lambda _
(substitute* "CMakeLists.txt" (("-march=native") ""))))
+ (add-after 'unpack 'remove-environment-variable-override
+ (lambda _
+ (substitute* "studio/src/guile/interpreter.cpp"
+ (("qputenv\\(\"GUILE_LOAD_COMPILED_PATH\".*") ""))))
(add-after 'unpack 'fix-library-location
(lambda _
(substitute* "libfive/bind/guile/libfive/lib.scm"
@@ -926,19 +930,32 @@ (define-public libfive
(string-append m "\n\"" #$output "/lib/\""))
(("\\(get-environment-variable \"LIBFIVE_STDLIB_DIR\"\\)" m)
(string-append m "\n\"" #$output "/lib/\"")))))
- (add-after 'install 'install-scm-files
+ (add-after 'unpack 'do-not-build-guile-bindings
+ (lambda _
+ (delete-file "libfive/bind/guile/CMakeLists.txt")
+ (call-with-output-file
+ "libfive/bind/guile/CMakeLists.txt"
+ (lambda (port)
+ (display "add_custom_target(libfive-guile)\n" port)))))
+ (add-after 'build 'guile-build
+ (lambda args
+ (apply (assoc-ref guile:%standard-phases 'build)
+ #:source-directory "../source/libfive/bind/guile"
+ args)))
+ (add-after 'install 'wrap-studio
(lambda _
- (for-each
- (lambda (file)
- (install-file file
- (string-append #$output
- "/share/guile/site/3.0/libfive")))
- (find-files "../source/libfive/bind/guile/libfive"
- "\\.scm$")))))))
+ (let* ((effective-version (guile:target-guile-effective-version))
+ (scm (string-append #$output "/share/guile/site/"
+ effective-version))
+ (go (string-append #$output "/lib/guile/"
+ effective-version "/site-ccache")))
+ (wrap-program (string-append #$output "/bin/Studio")
+ `("GUILE_LOAD_PATH" ":" prefix (,scm))
+ `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,go)))))))))
(native-inputs
(list pkg-config))
(inputs
- (list boost libpng qtbase-5 eigen guile-3.0))
+ (list boost libpng qtbase eigen guile-3.0 bash-minimal))
(home-page "https://libfive.com")
(synopsis "Tool for programmatic computer-aided design")
(description

base-commit: e0c35d1578c10a8fe27c8372f3a8bb5dd88b01b8
--
2.39.2
Morgan Smith wrote 2 years ago
[PATCH 2/3] gnu: libfive: Add Python bindings.
(address . 63422@debbugs.gnu.org)
DM5PR03MB31637E63F7F5EF0B100D449EC5779@DM5PR03MB3163.namprd03.prod.outlook.com
* 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(-)

Toggle diff (69 lines)
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
Morgan Smith wrote 2 years ago
[PATCH 3/3] gnu: libfive: Generate bindings instead of using pre-generated ones.
(address . 63422@debbugs.gnu.org)
DM5PR03MB31634823E5124CF36B48FB51C5779@DM5PR03MB3163.namprd03.prod.outlook.com
* gnu/packages/engineering.scm (libfive)[phases]: Add phase 'generate-bindings
to generate the bindings
---
gnu/packages/engineering.scm | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (23 lines)
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
Ludovic Courtès wrote 2 years ago
Re: bug#63422: [PATCH 0/3] gnu: libfive: Fixes
(address . Morgan.J.Smith@outlook.com)(address . 63422-done@debbugs.gnu.org)
87jzx534xg.fsf@gnu.org
Hi,

Morgan.J.Smith@outlook.com skribis:

Toggle quote (4 lines)
> [PATCH 1/3] gnu: libfive: Fix install and wrap Studio.
> [PATCH 2/3] gnu: libfive: Add Python bindings.
> [PATCH 3/3] gnu: libfive: Generate bindings instead of using

Applied, thanks!

Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 63422@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 63422
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help