From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI9Va-0000PQ-7I for guix-patches@gnu.org; Mon, 14 May 2018 05:11:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fI9VW-0005Us-Tr for guix-patches@gnu.org; Mon, 14 May 2018 05:11:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:53631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fI9VW-0005Uf-Po for guix-patches@gnu.org; Mon, 14 May 2018 05:11:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fI9VW-0002Ff-LC for guix-patches@gnu.org; Mon, 14 May 2018 05:11:02 -0400 Subject: [bug#31449] [PATCH 2/3] gnu: Add jupyter-guile-kernel. References: <20180514090751.1021-1-pierre-antoine.rouby@inria.fr> In-Reply-To: <20180514090751.1021-1-pierre-antoine.rouby@inria.fr> Resent-Message-ID: From: Rouby Pierre-Antoine Date: Mon, 14 May 2018 11:10:14 +0200 Message-Id: <20180514091014.1072-1-pierre-antoine.rouby@inria.fr> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 31449@debbugs.gnu.org Cc: Rouby Pierre-Antoine * gnu/package/guile.scm (jupyter-guile-kernel): New variable. --- gnu/packages/guile.scm | 127 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm index 9df59ba1d..bcd26461c 100644 --- a/gnu/packages/guile.scm +++ b/gnu/packages/guile.scm @@ -2180,4 +2180,131 @@ It has a nice, simple s-expression based syntax.") "This package is Guile wrapper over ZeroMQ library.") (license license:gpl3+))) +(define-public jupyter-guile-kernel + (package + (name "jupyter-guile-kernel") + (version "0.0.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/jerry40/guile-kernel") + (commit "b751d80730f3d64a4b38df1902c3e36672d46b2b"))) + (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) + ":")) + (guile-env (if (not (eq? (getenv "GUILE_LOAD_PATH") + #f)) + (string-append + (getenv "GUILE_LOAD_PATH") ":") + "")) + (guile-go-env (if (not (eq? (getenv "GUILE_LOAD_COMPILED_PATH") + #f)) + (string-append + (getenv "GUILE_LOAD_COMPILED_PATH") ":") + ""))) + ;; 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" (string-append guile-env path)) + (setenv "GUILE_LOAD_COMPILED_PATH" (string-append guile-go-env + 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) + + ;; Install kernel + (copy-file kernel-file (string-append kernel-dir "/" + kernel-file)) + ;; Sed kernel file + (substitute* (string-append kernel-dir "/" + kernel-file) + (("/home/jerry/.local/share/jupyter/kernels/guile/main.scm") + (string-append module-dir "/main.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 jupyter") + (description + "This package is Guile kernel for Jupyter Notebook. This software is +write for GNU Guile 2.0.") + (home-page "https://github.com/jerry40/guile-kernel") + (license license:gpl3+))) + ;;; guile.scm ends here -- 2.17.0