guix: python: Add build phase and factor out calls to setup.py.
* guix/build/python-build-system.scm (call-setuppy): New procedure. * guix/build/python-build-system.scm (build): New procedure. * guix/build/python-build-system.scm (check, install): Use call-setuppy. * guix/build/python-build-system.scm (%standard-phases): Add call to build.
This commit is contained in:
parent
49b90a7539
commit
b191f88ee3
|
@ -35,26 +35,32 @@
|
||||||
;;
|
;;
|
||||||
;; Code:
|
;; Code:
|
||||||
|
|
||||||
|
|
||||||
|
(define (call-setuppy command params)
|
||||||
|
(if (file-exists? "setup.py")
|
||||||
|
(begin
|
||||||
|
(format #t "running \"python setup.py\" with command ~s and parameters ~s~%"
|
||||||
|
command params)
|
||||||
|
(zero? (apply system* "python" "setup.py" command params)))
|
||||||
|
(error "no setup.py found")))
|
||||||
|
|
||||||
|
(define* (build #:rest empty)
|
||||||
|
"Build a given Python package."
|
||||||
|
(call-setuppy "build" '()))
|
||||||
|
|
||||||
|
(define* (check #:key tests? test-target #:allow-other-keys)
|
||||||
|
"Run the test suite of a given Python package."
|
||||||
|
(if tests?
|
||||||
|
(call-setuppy test-target '())
|
||||||
|
#t))
|
||||||
|
|
||||||
(define* (install #:key outputs (configure-flags '())
|
(define* (install #:key outputs (configure-flags '())
|
||||||
#:allow-other-keys)
|
#:allow-other-keys)
|
||||||
"Install a given Python package."
|
"Install a given Python package."
|
||||||
(let ((out (assoc-ref outputs "out")))
|
(let* ((out (assoc-ref outputs "out"))
|
||||||
(if (file-exists? "setup.py")
|
(params (append (list (string-append "--prefix=" out))
|
||||||
(let ((args `("setup.py" "install" ,(string-append "--prefix=" out)
|
configure-flags)))
|
||||||
,@configure-flags)))
|
(call-setuppy "install" params)))
|
||||||
(format #t "running 'python' with arguments ~s~%" args)
|
|
||||||
(zero? (apply system* "python" args)))
|
|
||||||
(error "no setup.py found"))))
|
|
||||||
|
|
||||||
(define* (check #:key outputs tests? test-target #:allow-other-keys)
|
|
||||||
"Run the test suite of a given Python package."
|
|
||||||
(if tests?
|
|
||||||
(if (file-exists? "setup.py")
|
|
||||||
(let ((args `("setup.py" ,test-target)))
|
|
||||||
(format #t "running 'python' with arguments ~s~%" args)
|
|
||||||
(zero? (apply system* "python" args)))
|
|
||||||
(error "no setup.py found"))
|
|
||||||
#t))
|
|
||||||
|
|
||||||
(define* (wrap #:key inputs outputs #:allow-other-keys)
|
(define* (wrap #:key inputs outputs #:allow-other-keys)
|
||||||
(define (list-of-files dir)
|
(define (list-of-files dir)
|
||||||
|
@ -92,11 +98,12 @@
|
||||||
'install 'wrap
|
'install 'wrap
|
||||||
wrap
|
wrap
|
||||||
(alist-replace
|
(alist-replace
|
||||||
'check check
|
'build build
|
||||||
(alist-replace 'install install
|
(alist-replace
|
||||||
(alist-delete 'configure
|
'check check
|
||||||
(alist-delete 'build
|
(alist-replace 'install install
|
||||||
gnu:%standard-phases))))))
|
(alist-delete 'configure
|
||||||
|
gnu:%standard-phases))))))
|
||||||
|
|
||||||
(define* (python-build #:key inputs (phases %standard-phases)
|
(define* (python-build #:key inputs (phases %standard-phases)
|
||||||
#:allow-other-keys #:rest args)
|
#:allow-other-keys #:rest args)
|
||||||
|
|
Loading…
Reference in New Issue