diff options
| author | pjotrp <pjotr.public01@thebird.nl> | 2026-10-13 15:56:34 +0000 |
|---|---|---|
| committer | pjotrp <pjotr.public01@thebird.nl> | 2026-10-13 15:56:34 +0000 |
| commit | 3e23f7502fd56bca1d703d8ba89bfeffbd5c798e (patch) | |
| tree | 534348d68aad4acab2f5861f332c3acc65ec3683 | |
| parent | 62d06b1ff7789552c30c38de3b8a0fa6ba54b140 (diff) | |
| download | guix-bioinformatics-3e23f7502fd56bca1d703d8ba89bfeffbd5c798e.tar.gz | |
julia: package the Optim closure; share the full load-path closure
Add julia-optim and its unpackaged dependencies, staying within Julia 1.8 (the version Guix ships): ArrayInterfaceCore + ArrayInterface 6.x (Static 0.8, matching Guix's), FiniteDiff 2.17, NLSolversBase 7.8.3 and LineSearches 7.2.0 (Optim 1.6.2 predates its MathOptInterface dependency). ArrayInterfaceCore is extracted from the lib/ArrayInterfaceCore subdir of the ArrayInterface monorepo. Also fix the shared environment: the wrapper only put the direct notebook packages on JULIA_LOAD_PATH, so their dependencies were missing (Distributions failed to precompile). It now prepends the load path of the whole dependency closure. Verified in the container: Optim, Distributions, QuadGK, PrettyTables, LaTeXStrings, Roots, PlutoUI and Pluto all import.
| -rw-r--r-- | gn/packages/julia.scm | 207 |
1 files changed, 185 insertions, 22 deletions
diff --git a/gn/packages/julia.scm b/gn/packages/julia.scm index 021b0e5..e152bf2 100644 --- a/gn/packages/julia.scm +++ b/gn/packages/julia.scm @@ -10,7 +10,8 @@ #:use-module (gnu packages compression) #:use-module (gnu packages julia-jll) #:use-module (gnu packages julia-xyz) - #:use-module (gnu packages version-control)) + #:use-module (gnu packages version-control) + #:use-module (srfi srfi-1)) (define S specification->package) @@ -1851,6 +1852,178 @@ possible to print a nicely formatted table presenting how much time, allocations and number of calls were made in each section. The output can be customized as to only show the things you are interested in.") (license license:expat))) +;; --- Julia packages for the Pluto notebooks (not in Guix upstream) ------ +;; +;; Chosen to stay within Julia 1.8 (the version Guix ships): ArrayInterface +;; 3.x and FiniteDiff 2.9 predate the ArrayInterfaceCore monorepo split, and +;; Optim 1.6 predates its MathOptInterface dependency. + +(define-public julia-arrayinterface-core + ;; ArrayInterfaceCore lives in lib/ArrayInterfaceCore of the ArrayInterface + ;; monorepo; extract it to the root so julia-build-system can build it. + (package + (name "julia-arrayinterface-core") + (version "0.1.28") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaArrays/ArrayInterface.jl") + (commit "v6.0.24"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0zl9k0npf545hf0dspync1g6ddqlx0wfr5bv4ilcv9c0jj8alq0s")) + (snippet + '(begin + (use-modules (guix build utils)) + (for-each make-file-writable (find-files ".")) + (copy-recursively "lib/ArrayInterfaceCore" "core") + (delete-file-recursively "lib") + (delete-file-recursively "src") + (copy-recursively "core" ".") + (delete-file-recursively "core"))))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) + (home-page "https://github.com/JuliaArrays/ArrayInterface.jl") + (synopsis "Core traits for ArrayInterface") + (description "The dependency-free core of ArrayInterface.") + (license license:expat))) + +(define-public julia-arrayinterface + (package + (name "julia-arrayinterface") + (version "6.0.24") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaArrays/ArrayInterface.jl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0zl9k0npf545hf0dspync1g6ddqlx0wfr5bv4ilcv9c0jj8alq0s")))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) ; test-only deps are not packaged + (propagated-inputs (list julia-arrayinterface-core julia-compat + julia-ifelse julia-static)) + (home-page "https://github.com/JuliaArrays/ArrayInterface.jl") + (synopsis "Interface for dispatching on array properties in Julia") + (description "ArrayInterface provides traits for dispatching on array +properties (size, axes, mutability, ...).") + (license license:expat))) + +(define-public julia-finite-diff + (package + (name "julia-finite-diff") + (version "2.17.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaDiff/FiniteDiff.jl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "06y9364jwi12y9a6jm6vbmdcdqprsimmgwzia7j8gpqfr2hjwk6m")))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) ; test-only deps are not packaged + (propagated-inputs (list julia-arrayinterface-core julia-requires + julia-setfield julia-staticarrays)) + (home-page "https://github.com/JuliaDiff/FiniteDiff.jl") + (synopsis "Finite difference derivatives for Julia") + (description "FiniteDiff provides numerically approximate derivatives of +functions on arrays.") + (license license:expat))) + +(define-public julia-nlsolversbase + (package + (name "julia-nlsolversbase") + (version "7.8.3") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaNLSolvers/NLSolversBase.jl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "04ilwkhml2lkabfsa8aqj7h3a0f5sxcqdxxg2h2byfkbjf9sp59r")))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) ; test-only deps are not packaged + (propagated-inputs (list julia-diffresults julia-finite-diff + julia-forwarddiff)) + (home-page "https://github.com/JuliaNLSolvers/NLSolversBase.jl") + (synopsis "Base types for nonlinear solvers") + (description "NLSolversBase provides the objective/cache types shared by +Julia's nonlinear solvers (Optim, NLsolve, ...).") + (license license:expat))) + +(define-public julia-line-searches + (package + (name "julia-line-searches") + (version "7.2.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaNLSolvers/LineSearches.jl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0rwl8v1s3i2610l3pgn2y7alr4qn5nnw18pf0q872pxg9jsgrx27")))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) ; test-only deps are not packaged + (propagated-inputs (list julia-nlsolversbase julia-nanmath + julia-parameters)) + (home-page "https://github.com/JuliaNLSolvers/LineSearches.jl") + (synopsis "Line search methods for Julia") + (description "LineSearches implements a collection of line searches for +use by nonlinear solvers.") + (license license:expat))) + +(define-public julia-optim + (package + (name "julia-optim") + (version "1.6.2") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/JuliaNLSolvers/Optim.jl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "187vc4f37v9sl0fmc7jar8i7nc2yfzcbz92va5n5877wrv74zcfh")))) + (build-system julia-build-system) + (arguments (list #:tests? #f)) ; test-only deps are not packaged + (propagated-inputs (list julia-compat julia-fillarrays julia-forwarddiff + julia-line-searches julia-nlsolversbase + julia-nanmath julia-parameters + julia-positivefactorizations julia-statsbase)) + (home-page "https://github.com/JuliaNLSolvers/Optim.jl") + (synopsis "Optimization functions for Julia") + (description "Optim provides algorithms for unconstrained and box +constrained optimization (Nelder-Mead, BFGS, gradient descent, ...).") + (license license:expat))) + +;; The Julia packages the bundled notebooks need, for the shared +;; environment (see pluto-notebook). Plots and CairoMakie are not here +;; yet: they pull much larger closures (GR/Makie). +(define %pluto-notebook-julia-deps + (list julia-plutoui julia-distributions julia-roots julia-latexstrings + julia-quadgk julia-prettytables julia-optim)) + +(define %pluto-notebook-loadpath + ;; share/julia/loadpath of every Julia package in the dependency closure + ;; of the above -- the shared environment the wrapper prepends to + ;; JULIA_LOAD_PATH. Includes the packages' own dependencies. + (delete-duplicates + (filter-map (lambda (input) + (let ((p (cadr input))) + (and (string-prefix? "julia-" (package-name p)) + (file-append p "/share/julia/loadpath/")))) + (append-map package-transitive-inputs + %pluto-notebook-julia-deps)))) (define-public pluto-notebook ;; The current Pluto notebook server, superseding julia-visuals. It @@ -1886,22 +2059,13 @@ customized as to only show the things you are interested in.") (guile (search-input-file inputs "/bin/guile")) (julia (search-input-file inputs "/bin/julia")) (pathdir (dirname (search-input-file inputs "/bin/yes"))) - ;; Share every input that ships a Julia load path - ;; (the packaged notebook dependencies), on top of - ;; the build-time JULIA_LOAD_PATH that carries the - ;; transitive deps of PlutoSliderServer. + ;; The notebook packages (and their dependencies), + ;; prepended to the build-time JULIA_LOAD_PATH that + ;; carries the transitive deps of PlutoSliderServer. (extra-load-path - (let loop ((rest inputs) (acc "")) - (if (null? rest) - acc - (let* ((path (cdr (car rest))) - (dir (and (string? path) - (string-append - path "/share/julia/loadpath/")))) - (loop (cdr rest) - (if (and dir (file-exists? dir)) - (string-append acc dir ":") - acc)))))) + (apply string-append + (map (lambda (dir) (string-append dir ":")) + (list #$@%pluto-notebook-loadpath)))) (load-path (string-append extra-load-path (getenv "JULIA_LOAD_PATH"))) (julia-update "import Pkg; Pkg.update()") @@ -1926,11 +2090,9 @@ customized as to only show the things you are interested in.") (format #t "(zero? (system* ~s \"--optimize=0\" \"-e\" ~s))\n" julia julia-run))) (chmod (string-append out "/bin/runsliderserver") #o555)))))))) - ;; Shared Julia environment: these land on the wrapper's - ;; JULIA_LOAD_PATH, so every notebook can `using` them without - ;; downloading. Plots, CairoMakie and Optim are not packaged yet, - ;; so notebooks that use them still need a writable depot (or the - ;; network); see the container header. + ;; Shared Julia environment: these and their dependencies land on the + ;; wrapper's JULIA_LOAD_PATH, so every notebook can `using` them + ;; without downloading. Plots and CairoMakie are not packaged yet. (inputs (modify-inputs (package-inputs julia-visuals) (prepend julia-plutoui @@ -1938,7 +2100,8 @@ customized as to only show the things you are interested in.") julia-roots julia-latexstrings julia-quadgk - julia-prettytables))) + julia-prettytables + julia-optim))) (home-page "https://git.genenetwork.org/") (synopsis "Serve Pluto notebooks with PlutoSliderServer") (description "A Pluto notebook server: runs a directory of Pluto |
