Package: guix-patches;
Reported by: Rouby Pierre-Antoine <pierre-antoine.rouby <at> inria.fr>
Date: Mon, 14 May 2018 09:09:02 UTC
Severity: normal
Tags: patch
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
Message #26 received at 31449 <at> debbugs.gnu.org (full text, mbox):
From: Rouby Pierre-Antoine <pierre-antoine.rouby <at> inria.fr> To: ludo <at> gnu.org Cc: 31449 <at> debbugs.gnu.org, Rouby Pierre-Antoine <pierre-antoine.rouby <at> inria.fr> Subject: [PATCH 2/3] gnu: Add jupyter-guile-kernel. Date: Tue, 15 May 2018 11:24:01 +0200
* gnu/package/guile.scm (jupyter-guile-kernel): New variable. --- gnu/packages/guile.scm | 126 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm index 3a0158944..a6a0ada8c 100644 --- a/gnu/packages/guile.scm +++ b/gnu/packages/guile.scm @@ -2184,4 +2184,130 @@ It has a nice, simple s-expression based syntax.") messaging library.") (license license:gpl3+)))) +(define-public jupyter-guile-kernel + (let ((commit "b751d80730f3d64a4b38df1902c3e36672d46b2b") + (revision "0")) + (package + (name "jupyter-guile-kernel") + (version (git-version "0.0.0" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/jerry40/guile-kernel") + (commit commit))) + (sha256 + (base32 + "0mah16mjg84l6fc52caqzk5b3m4lfi7f4fki96nbwmrgcxz9hy4g")))) + (build-system trivial-build-system) + (arguments + `(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils) + (srfi srfi-26) + (ice-9 match) + (ice-9 popen) + (ice-9 rdelim)) + + (let* ((out (assoc-ref %outputs "out")) + (guile (assoc-ref %build-inputs "guile")) + (effective (read-line + (open-pipe* OPEN_READ + (string-append guile "/bin/guile") + "-c" "(display (effective-version))"))) + (module-dir (string-append out "/share/guile/site/" + effective)) + (kernel-dir (string-append out "/share/jupyter/kernels/guile")) + (go-dir (string-append out "/lib/guile/" + effective + "/site-ccache")) + (source (string-append (assoc-ref %build-inputs "source") + "/src")) + (scm-files '("hmac.scm" + "tools.scm" + "main.scm")) + (kernel-file "kernel.json") + (guild (string-append (assoc-ref %build-inputs "guile") + "/bin/guild")) + (zmq (string-append (assoc-ref %build-inputs "zeromq") + "/lib")) + (g-szmq (assoc-ref %build-inputs "guile-simple-zmq")) + (json (assoc-ref %build-inputs "guile-json")) + (deps (list g-szmq json)) + (path (string-join + (map (cut string-append <> + "/share/guile/site/" + effective) + deps) + ":")) + (gopath (string-join + (map (cut string-append <> + "/lib/guile/" effective + "/site-ccache/") + deps) + ":"))) + + ;; Make installation directories. + (mkdir-p module-dir) + (mkdir-p kernel-dir) + (mkdir-p go-dir) + + ;; Compile .scm files and install. + (chdir source) + (setenv "GUILE_AUTO_COMPILE" "0") + (setenv "GUILE_LOAD_PATH" path) + (setenv "GUILE_LOAD_COMPILED_PATH" gopath) + + (for-each (lambda (file) + (let* ((dest-file (string-append module-dir "/" + file)) + (go-file (match (string-split file #\.) + ((base _) + (string-append go-dir "/" + base ".go"))))) + ;; Install source module. + (copy-file file dest-file) + + ;; Install compiled module. + (unless (zero? (system* guild "compile" + "-L" source + "-o" go-file + file)) + (error (format #f "Failed to compile ~s to ~s!" + file go-file))))) + scm-files) + + ;; Fix executable file name + (rename-file (string-append module-dir "/main.scm") + (string-append module-dir "/guile-jupyter-kernel.scm")) + (rename-file (string-append go-dir "/main.go") + (string-append go-dir "/guile-jupyter-kernel.go")) + + ;; Install kernel + (copy-file kernel-file (string-append kernel-dir "/" + kernel-file)) + ;; Fix hard-coded file name in the kernel + (substitute* (string-append kernel-dir "/" + kernel-file) + (("/home/jerry/.local/share/jupyter/kernels/guile/main.scm") + (string-append module-dir "/guile-jupyter-kernel.scm"))) + (substitute* (string-append kernel-dir "/" + kernel-file) + (("-s") + (string-append "--no-auto-compile\", \"-s"))) + #t)))) + (propagated-inputs + `(("guile" ,guile-2.2) + ("zeromq" ,zeromq) + ("openssl" ,openssl) + ("guile-json" ,guile-json) + ("guile-simple-zmq" ,guile-simple-zmq))) + (synopsis "Guile kernel for the Jupyter Notebook") + (description + "This package provides a Guile 2.x kernel for the Jupyter Notebook. It +allows users to interact with the Guile REPL through Jupyter.") + (home-page "https://github.com/jerry40/guile-kernel") + (license license:gpl3+)))) + ;;; guile.scm ends here -- 2.17.0
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.