~ruther/guix-local

b191f88ee34576a6908b9b5e94cb7664e88c7e79 — Andreas Enge 12 years ago 49b90a7
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.
1 files changed, 28 insertions(+), 21 deletions(-)

M guix/build/python-build-system.scm
M guix/build/python-build-system.scm => guix/build/python-build-system.scm +28 -21
@@ 35,27 35,33 @@
;;
;; Code:

(define* (install #:key outputs (configure-flags '())
                  #:allow-other-keys)
  "Install a given Python package."
  (let ((out (assoc-ref outputs "out")))
    (if (file-exists? "setup.py")
        (let ((args `("setup.py" "install" ,(string-append "--prefix=" out)
                      ,@configure-flags)))
          (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)
(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?
    (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"))
    (call-setuppy test-target '())
    #t))

(define* (install #:key outputs (configure-flags '())
                  #:allow-other-keys)
  "Install a given Python package."
  (let* ((out (assoc-ref outputs "out"))
         (params (append (list (string-append "--prefix=" out))
                         configure-flags)))
        (call-setuppy "install" params)))

(define* (wrap #:key inputs outputs #:allow-other-keys)
  (define (list-of-files dir)
    (map (cut string-append dir "/" <>)


@@ 92,11 98,12 @@
   'install 'wrap
   wrap
   (alist-replace
    'check check
    (alist-replace 'install install
                   (alist-delete 'configure
                                (alist-delete 'build
                                              gnu:%standard-phases))))))
    'build build
    (alist-replace
     'check check
     (alist-replace 'install install
                    (alist-delete 'configure
                                               gnu:%standard-phases))))))

(define* (python-build #:key inputs (phases %standard-phases)
                       #:allow-other-keys #:rest args)