unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 5f222f0850ee8b1d247446978911354c6bf9cdd0 5466 bytes (raw)
name: guix/build/julia-build-system.scm 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
(define-module (guix build julia-build-system)
  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  #:use-module (guix build utils)
  ;; #:use-module (srfi srfi-1)
  ;; #:use-module (srfi srfi-11)
  ;; #:use-module (srfi srfi-26)
  ;; #:use-module (ice-9 rdelim)
  ;; #:use-module (ice-9 regex)
  #:use-module (ice-9 match)
  #:export (%standard-phases
	    julia-create-package-toml
            julia-build))

;; (define* (set-emacs-load-path #:key source inputs #:allow-other-keys)
;;   (define (inputs->directories inputs)
;;     "Extract the directory part from INPUTS."
;;     (match inputs
;;       (((names . directories) ...) directories)))

;;   (define (input-directory->el-directory input-directory)
;;     "Return the correct Emacs Lisp directory in INPUT-DIRECTORY or #f, if there
;; is no Emacs Lisp directory."
;;     (let ((legacy-elisp-directory (string-append input-directory %legacy-install-suffix))
;;           (guix-elisp-directory
;;            (string-append
;;             input-directory %install-suffix "/"
;;             (store-directory->elpa-name-version input-directory))))
;;       (cond
;;        ((file-exists? guix-elisp-directory) guix-elisp-directory)
;;        ((file-exists? legacy-elisp-directory) legacy-elisp-directory)
;;        (else #f))))

;;   (define (input-directories->el-directories input-directories)
;;     "Return the list of Emacs Lisp directories in INPUT-DIRECTORIES."
;;     (filter-map input-directory->el-directory input-directories))

;;   "Set the EMACSLOADPATH environment variable so that dependencies are found."
;;   (let* ((source-directory (getcwd))
;;          (input-elisp-directories (input-directories->el-directories
;;                                    (inputs->directories inputs)))
;;          (emacs-load-path-value
;;           (string-join
;;            (append input-elisp-directories (list source-directory))
;;            ":" 'suffix)))
;;     (setenv "EMACSLOADPATH" emacs-load-path-value)
;;     (format #t "environment variable `EMACSLOADPATH' set to ~a\n"
;;             emacs-load-path-value)))


(define* (install #:key outputs source #:allow-other-keys)
  (let* ((out (assoc-ref outputs "out"))
	 (package-dir (string-append out "/share/julia/packages/"
				     (string-append
				      (strip-store-file-name source)))))
    (mkdir-p package-dir)
    (copy-recursively source package-dir))
  #t)

;; FIXME: Precompilation is working, but I don't know how to tell
;; julia to use use it. If setting HOME to
;; /gnu/store/xib48jxkhiy0gylnm3q430zfwk6am47h-profile/share/julia/compiled/,
;; julia tries to write files there
(define* (precompile #:key outputs source inputs #:allow-other-keys)
  (define (inputs->directories inputs)
    "Extract the directory part from INPUTS."
    (match inputs
      (((names . directories) ...) directories)))
  (let* ((out (assoc-ref outputs "out"))
	 (builddir (string-append out "/share/julia/"))
	 (pacakge (strip-store-file-name source)))
    (mkdir-p builddir)
    (setenv "JULIA_DEPOT_PATH" builddir)
    (setenv "JULIA_LOAD_PATH"
	    (string-append
	     "@stdlib:"
	     (string-append out "/share/julia/packages/:")
	     (string-join (inputs->directories inputs) "/share/julia/packages/:")))
    ;; (invoke "julia" "-e" (string-append "println(LOAD_PATH)"))
    (invoke "julia" "-e" (string-append "using " pacakge))
    )
  #t)

;; (define* (check #:key outputs source inputs #:allow-other-keys)
;;   (define (inputs->directories inputs)
;;     "Extract the directory part from INPUTS."
;;     (match inputs
;;       (((names . directories) ...) directories)))
;;   (let* ((out (assoc-ref outputs "out"))
;; 	 (builddir (string-append out "/share/julia/"))
;; 	 (pacakge (strip-store-file-name source)))
;;     (mkdir-p builddir)
;;     (setenv "JULIA_DEPOT_PATH" builddir)
;;     (setenv "JULIA_LOAD_PATH"
;;     	    (string-append
;; 	     "@:@v#.#:@stdlib:"
;;     	     (string-append out "/share/julia/packages/:")
;;     	     (string-join (inputs->directories inputs) "/share/julia/packages/:")))
;;     ;; (invoke "julia" "-e" (string-append "println(LOAD_PATH)"))
;;     (invoke "julia" "-e" (string-append "using Pkg; Pkg.test(\"" pacakge "\")"))
;;     )
;;   #t)

;;* 
(define (julia-create-package-toml outputs source
				   name uuid version
				   deps) 
  (let ((f (open-file
	    (string-append
	     (assoc-ref outputs "out")
	     "/share/julia/packages/"
	     (string-append
	      name "/Project.toml"))
	    "w")))
    (display (string-append
	      "
name = \"" name "\"
uuid = \"" uuid "\"
version = \"" version "\"
") f)
    (when (not (null? deps))
      (display "[deps]\n" f)
      (for-each (lambda dep
		  (display (string-append (car (car dep)) " = \"" (cdr (car dep)) "\"\n")
			   f))
		deps))
    (close-port f))
  #t)

(define %standard-phases
  (modify-phases gnu:%standard-phases
    (replace 'install install)
    (add-after 'install 'precompile precompile)
    ;; (replace 'check check)
    ;; (add-after 'unpack 'set-julia-load-path set-julia-load-path)
    (delete 'configure)
    (delete 'bootstrap)
    (delete 'patch-usr-bin-file)
    (delete 'build)
    (delete 'reset-gzip-timestamps)
    (delete 'check)))

(define* (julia-build #:key inputs (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
         args))

debug log:

solving 5f222f0850 ...
found 5f222f0850 in https://yhetil.org/guix-patches/CAO7Ox=Y2-3TCYRnYcohASYEfJfAnULJAbNr8xRXB1dT325fE8Q@mail.gmail.com/

applying [1/1] https://yhetil.org/guix-patches/CAO7Ox=Y2-3TCYRnYcohASYEfJfAnULJAbNr8xRXB1dT325fE8Q@mail.gmail.com/
diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm
new file mode 100644
index 0000000000..5f222f0850

1:109: trailing whitespace.
;;* 
1:112: trailing whitespace.
				   deps) 
Checking patch guix/build/julia-build-system.scm...
Applied patch guix/build/julia-build-system.scm cleanly.
warning: 2 lines add whitespace errors.

index at:
100644 5f222f0850ee8b1d247446978911354c6bf9cdd0	guix/build/julia-build-system.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).