summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorJean-Baptiste Volatier <jbv@pm.me>2021-11-12 14:23:52 +0000
committerEfraim Flashner <efraim@flashner.co.il>2021-11-16 14:39:51 +0200
commit3af351a7de41b8d50f27f3623c46392f571b9a4e (patch)
tree4bb6d5d021633c1c0c5883ab7c6ac0c7b8da17f1 /guix/build
parente31d48d8db09e723727eeadbeea22d677f5d1d52 (diff)
downloadguix-3af351a7de41b8d50f27f3623c46392f571b9a4e.tar.gz
guix-3af351a7de41b8d50f27f3623c46392f571b9a4e.tar.xz
build-system/julia: Enable Julia Pkg to find installed packages.
Julia's built-in package manager (Pkg) looks for packages in JULIA_DEPOT_PATH/packages/PACKAGENAME/XXXX, where XXXX is a string encoding package UUID and SHA1 of files. The link-depot phase creates a link at the correct location to allow Pkg to find packages that were already installed by Guix. * guix/build/julia-build-system.scm (link-depot): New phase. (%package-path): Modified package path from packages/ to loadpath/. (project.toml->uuid): New procedure, retrive package uuid from TOML file. (precompile, check): Adjust to the change in paths. (%standard-phases): Add link-depot phase. (julia-build): Add julia-package-uuid keyword. * guix/build-system/julia.scm (julia-build): Also use the julia-package-uuid keyword. * gnu/packages/julia-jll.scm (julia-bzip2-jll, julia-cairo-jll, julia-compilersupportlibraries-jll, julia-expat-jll, julia-ffmpeg-jll, julia-fontconfig-jll, julia-freetype2-jll, julia-fribidi-jll, julia-gettext-jll, julia-glib-jll, julia-gr-jll, julia-gumbo-jll, julia-imagemagick-jll, julia-jllwrappers-jll, julia-jpegturbo-jll, julia-lame-jll, julia-libass-jll, julia-libfdk-aac-jll, julia-libffi-jll, julia-libgcrypt-jll, julia-libglvnd-jll, julia-libgpg-error-jll, juli-libiconv-jll, julia-libmount-jll, julia-libpng-jll, julia-libsass-jll, julia-libtiff-jll, julia-libuuid-jll, julia-libvorbis-jll, julia-lzo-jll, julia-mbedtls-jll, julia-ogg-jll, julia-openspecfun-jll, julia-openssl-jll, julia-opus-jll, julia-pcre-jll, julia-pixman-jll, julia-qt5base-jll, julia-wayland-jll, julia-wayland-protocols-jll, julia-x264-jll, julia-x265-jll, julia-xkbcommon-jll, julia-xml2-jll, julia-xorg-libpthread-stubs-jll, julia-xorg-libx11-jll, julia-xorg-libxau-jll, julia-xorg-libxcb-jll, julia-xorg-libxcursor-jll, julia-xorg-libxdmcp-jll, julia-xorg-libxext-jll, julia-xorg-libxfixes-jll, julia-xorg-libxi-jll, julia-xorg-libxinerama-jll, julia-xorg-libxkbfile-jll, julia-xorg-libxrandr-jll, julia-xorg-libxrender-jll, julia-xorg-xcb-util-jll, julia-xorg-xcb-util-keysyms-jll, julia-xorg-xcb-util-renderutil-jll, julia-xorg-xcb-util-wm-jll, julia-xorg-xkbcomp-jll, julia-xorg-xkeyboard-config-jll, julia-xorg-xtrans-jll, julia-xslt-jll, julia-zlib-jll, julia-zstd-jll) [argument]: Adjust the order of the phases to the change in the julia-build-system. * gnu/packages/julia-xyz.scm (julia-bufferedstreams, julia-calculus, julia-dataframes, julia-datavalues, julia-distances, julia-documenter, julia-dualnumbers, julia-ellipsisnotation, julia-expronicon, julia-fileio, julia-fixedpointnumbers, julia-functionwrappers, julia-fuzzycompletions, julia-genericlinearalgebra, julia-genericschur, julia-geometrybasics, julia-imagemagick, julia-infinity, julia-matrixfactorizations, julia-media, julia-missings, julia-nnlib, julia-optimtestproblems, julia-orderedcollections, julia-prettytables, julia-pycall, julia-quadmath, julia-safetests, julia-stackviews) [arguments]: Correct paths to reflect change of %package-path modify order of phases as link-depot needs to run on an unmodified src directory add package-name-uuid keyword argument to packages without Project.toml file. * gnu/packages/julia.scm (julia)[native-search-paths]: Correct paths to reflect change of %package-path modify order of phases as link-depot needs to run on an unmodified src directory. Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/julia-build-system.scm48
1 files changed, 43 insertions, 5 deletions
diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm
index d74acf2a05..41c69665c6 100644
--- a/guix/build/julia-build-system.scm
+++ b/guix/build/julia-build-system.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
+;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,9 +21,11 @@
(define-module (guix build julia-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build utils)
+ #:use-module (rnrs io ports)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (ice-9 rdelim)
+ #:use-module (ice-9 popen)
#:export (%standard-phases
julia-create-package-toml
julia-build))
@@ -37,7 +40,7 @@
(invoke "julia" "-e" code))
;; subpath where we store the package content
-(define %package-path "/share/julia/packages/")
+(define %package-path "/share/julia/loadpath/")
(define (project.toml->name file)
"Look for Julia package name in the TOML file FILE (usually named
@@ -51,6 +54,18 @@ Project.toml)."
(if m (match:substring m 1)
(loop (read-line in 'concat)))))))))
+(define (project.toml->uuid file)
+ "Look for Julia package uuid in the TOML file FILE (usually named
+Project.toml)."
+ (call-with-input-file file
+ (lambda (in)
+ (let loop ((line (read-line in 'concat)))
+ (if (eof-object? line)
+ #f
+ (let ((m (string-match "uuid\\s*=\\s*\"(.*)\"" line)))
+ (if m (match:substring m 1)
+ (loop (read-line in 'concat)))))))))
+
(define* (install #:key source inputs outputs julia-package-name
#:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
@@ -73,7 +88,7 @@ Project.toml)."
(setenv "JULIA_DEPOT_PATH" builddir)
;; Add new package dir to the load path.
(setenv "JULIA_LOAD_PATH"
- (string-append builddir "packages/" ":"
+ (string-append builddir "loadpath/" ":"
(or (getenv "JULIA_LOAD_PATH")
"")))
;; Actual precompilation:
@@ -97,15 +112,36 @@ Project.toml)."
(setenv "SOURCE_DATE_EPOCH" "1")
(setenv "JULIA_DEPOT_PATH" builddir)
(setenv "JULIA_LOAD_PATH"
- (string-append builddir "packages/" ":"
+ (string-append builddir "loadpath/" ":"
(or (getenv "JULIA_LOAD_PATH")
"")))
(setenv "HOME" "/tmp")
(invoke "julia" "--depwarn=yes"
- (string-append builddir "packages/"
+ (string-append builddir "loadpath/"
package "/test/runtests.jl"))))
#t)
+(define* (link-depot #:key source inputs outputs julia-package-name julia-package-uuid
+ #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (package-name (or
+ julia-package-name
+ (project.toml->name "Project.toml")))
+ (package-dir (string-append out %package-path package-name))
+ (uuid (or julia-package-uuid (project.toml->uuid "Project.toml")))
+ (pipe (open-pipe* OPEN_READ "julia" "-e"
+ (format #f "using Pkg;
+println(Base.version_slug(Base.UUID(\"~a\"),
+ Base.SHA1(Pkg.GitTools.tree_hash(\".\"))))" uuid)))
+ (slug (string-trim-right (get-string-all pipe))))
+ ;; When installing a package, julia looks first at in the JULIA_DEPOT_PATH
+ ;; for a path like packages/PACKAGE/XXXX
+ ;; Where XXXX is a slug encoding the package UUID and SHA1 of the files
+ ;; Here we create a link with the correct path to enable julia to find the package
+ (mkdir-p (string-append out "/share/julia/packages/" package-name))
+ (symlink package-dir (string-append out "/share/julia/packages/" package-name "/" slug)))
+ #t)
+
(define (julia-create-package-toml outputs source
name uuid version
deps)
@@ -138,6 +174,7 @@ version = \"" version "\"
(delete 'check) ; tests must be run after installation
(replace 'install install)
(add-after 'install 'precompile precompile)
+ (add-after 'unpack 'link-depot link-depot)
(add-after 'install 'check check)
;; TODO: In the future we could add a "system-image-generation" phase
;; where we use PackageCompiler.jl to speed up package loading times
@@ -146,11 +183,12 @@ version = \"" version "\"
(delete 'patch-usr-bin-file)
(delete 'build)))
-(define* (julia-build #:key inputs julia-package-name
+(define* (julia-build #:key inputs julia-package-name julia-package-uuid
(phases %standard-phases)
#:allow-other-keys #:rest args)
"Build the given Julia package, applying all of PHASES in order."
(apply gnu:gnu-build
#:inputs inputs #:phases phases
#:julia-package-name julia-package-name
+ #:julia-package-uuid julia-package-uuid
args))