unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* 'python-build-system'
@ 2013-04-05 18:21 Nikita Karetnikov
  2013-04-07 10:34 ` 'python-build-system' Ludovic Courtès
  2013-04-27 15:14 ` 'python-build-system' Ludovic Courtès
  0 siblings, 2 replies; 23+ messages in thread
From: Nikita Karetnikov @ 2013-04-05 18:21 UTC (permalink / raw)
  To: bug-guix


[-- Attachment #1.1: Type: text/plain, Size: 2055 bytes --]

Here is my attempt to write the Python build system.  Even though it
mostly mimics the Perl build system, I failed to finalize it.  Could
you help me?

The main problem is that 'set-path-environment-variable' doesn't seem
to work.  I used Bazaar (don't forget to apply this patch [1] first)
to test the build system:

# /nix/var/nix/profiles/per-user/root/guix-profile/bin/bzr --help
bzr: warning: unsupported locale setting
  bzr could not set the application locale.
  Although this should be no problem for bzr itself, it might
  cause problems with some plugins. To investigate the issue,
  look at the output of the locale(1p) tool.
bzr: ERROR: Couldn't import bzrlib and dependencies.
Please check the directory containing bzrlib is on your PYTHONPATH.

Traceback (most recent call last):
  File "/nix/var/nix/profiles/per-user/root/guix-profile/bin/bzr", line 102, in <module>
    import bzrlib
ImportError: No module named bzrlib

(I guess that the locale-related error can be ignored.  Because it's
probably connected with my chroot.)

Bazaar seems to work if I export PYTHONPATH manually:

# export PYTHONPATH=/nix/store/gcsq72i07mlnpy912qjxwh052jq9fjxm-bazaar-2.3.1/lib/python2.7/site-packages

So what is the problem?

More questions:

1. How can I get the version of Python in 'python-build-system.scm'?
   (I hardcoded it for now.)

2. Can I remove the 'strip' phase?  Is it useful for Python packages?

There is a problem with Bazaar too.  Actually, it's a 'gnutls' problem.
I packaged Bazaar 2.3.1 because I can't get the hashes of the latest
versions.  For example:

# ./pre-inst-env guix download https://launchpad.net/bzr/2.5/2.5.1/+download/bzr-2.5.1.tar.gz

[...]

ERROR: missing interface for module (gnutls)

I've already seen this error [2], but the context was a bit different.

Is it possible (and necessary) to rewrite 'guix/build/download.scm' to
avoid similar problems in the future?

[1] https://lists.gnu.org/archive/html/bug-guix/2013-04/msg00011.html
[2] https://lists.gnu.org/archive/html/bug-guix/2013-02/msg00189.html


[-- Attachment #1.2: python-build-system.scm --]
[-- Type: text/plain, Size: 2673 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix build python-build-system)
  #:use-module ((guix build gnu-build-system)
                #:renamer (symbol-prefix-proc 'gnu:))
  #:use-module (guix build utils)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)
  #:export (%standard-phases
            python-build))

;; Commentary:
;;
;; Builder-side code of the standard Python package build procedure.
;;
;; Code:

(define* (install #:key outputs (configure-flags '())
                  #:allow-other-keys)
  "Install the 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 %standard-phases
  ;; 'configure' and 'build' phases are not needed.  Everything is done during
  ;; 'install'.
  (alist-replace 'install install
                 (alist-delete 'configure
                               (alist-delete 'build
                                             gnu:%standard-phases))))

(define* (python-build #:key inputs (phases %standard-phases)
                       #:allow-other-keys #:rest args)
  "Build the given Python package, applying all of PHASES in order."
  (set-path-environment-variable "PYTHONPATH"
                                 '("lib/python2.7/site-packages")
                                 (match inputs
                                   (((_ . location) ...)
                                    location)))

  (apply gnu:gnu-build #:inputs inputs #:phases phases args))

;;; python-build-system.scm ends here

[-- Attachment #1.3: python.scm --]
[-- Type: text/plain, Size: 4379 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix build-system python)
  #:use-module (guix store)
  #:use-module (guix utils)
  #:use-module (guix derivations)
  #:use-module (guix build-system)
  #:use-module (guix build-system gnu)
  #:use-module (guix packages)
  #:use-module (ice-9 match)
  #:export (python-build
            python-build-system))

;; Commentary:
;;
;; Standard build procedure for Python packages using 'setup.py'.  This is
;; implemented as an extension of 'gnu-build-system'.
;;
;; Code:

(define* (python-build store name source inputs
                       #:key
                       (python (@ (gnu packages python) python))
                       (tests? #t)
                       (configure-flags ''())
                       (phases '(@ (guix build python-build-system)
                                   %standard-phases))
                       (outputs '("out"))
                       (system (%current-system))
                       (guile #f)
                       (imported-modules '((guix build python-build-system)
                                           (guix build gnu-build-system)
                                           (guix build utils)))
                       (modules '((guix build python-build-system)
                                  (guix build gnu-build-system)
                                  (guix build utils))))
  "Build SOURCE using PYTHON, and with INPUTS.  This assumes that SOURCE
provides a 'setup.py' file as its build system."
  (define builder
    `(begin
       (use-modules ,@modules)
       (python-build #:name ,name
                     #:source ,(if (and source (derivation-path? source))
                                   (derivation-path->output-path source)
                                   source)
                     #:configure-flags ,configure-flags
                     #:system ,system
                     #:test-target "test"
                     #:tests? ,tests?
                     #:outputs %outputs
                     #:inputs %build-inputs)))

  (define guile-for-build
    (match guile
      ((? package?)
       (package-derivation store guile system))
      ((and (? string?) (? derivation-path?))
       guile)
      (#f                                         ; the default
       (let* ((distro (resolve-interface '(gnu packages base)))
              (guile  (module-ref distro 'guile-final)))
         (package-derivation store guile system)))))

  (let ((python (package-derivation store python system)))
    (build-expression->derivation store name system
                                  builder
                                  `(,@(if source
                                          `(("source" ,source))
                                          '())
                                    ("python" ,python)
                                    ,@inputs

                                    ;; Keep the standard inputs of
                                    ;; 'gnu-build-system'.
                                    ,@(standard-inputs system))

                                  #:modules imported-modules
                                  #:outputs outputs
                                  #:guile-for-build guile-for-build)))

(define python-build-system
  (build-system (name 'python)
                (description "The standard Python build system")
                (build python-build)))

;;; python.scm ends here

[-- Attachment #1.4: bazaar.scm --]
[-- Type: text/plain, Size: 1906 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages bazaar)
  #:use-module ((guix licenses) #:select (gpl2+))
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix build-system python)
  #:use-module (guix build utils))

(define-public bazaar
  (package
    (name "bazaar")
    (version "2.3.1")
    (source
     (origin
      (method url-fetch)
      (uri (string-append "https://launchpad.net/bzr/2.3/" version
                          "/+download/bzr-" version ".tar.gz"))
      (sha256
       (base32
        "07kx41w4gqv68bcykdflsg68wvpmcyqknzyb4vr1zqlf27hahp53"))))
    (build-system python-build-system)
    (arguments
     `(#:tests? #f))
    (home-page "https://gnu.org/software/bazaar")
    (synopsis
     "GNU Bazaar, a distributed version control system")
    (description
     "GNU Bazaar supports both central version control and distributed
version control.  Developers can organize their workspace in whichever
way they want.  It also supports things like refactoring and per-commit
regression testing.")
    (license gpl2+)))

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-05-09 20:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-05 18:21 'python-build-system' Nikita Karetnikov
2013-04-07 10:34 ` 'python-build-system' Ludovic Courtès
2013-04-23  9:49   ` ERROR: missing interface for module (gnutls) (was: 'python-build-system') Nikita Karetnikov
2013-04-23 11:51     ` ERROR: missing interface for module (gnutls) Ludovic Courtès
2013-04-23 15:03       ` Nikita Karetnikov
2013-04-23 16:01         ` Ludovic Courtès
2013-04-27 15:14 ` 'python-build-system' Ludovic Courtès
2013-04-28  1:55   ` 'python-build-system' Nikita Karetnikov
2013-04-28 17:18     ` 'python-build-system' Nikita Karetnikov
2013-04-28 20:52       ` 'python-build-system' Ludovic Courtès
2013-04-29  3:50         ` 'python-build-system' Nikita Karetnikov
2013-04-29 11:42           ` 'python-build-system' Ludovic Courtès
2013-05-08  1:52             ` 'python-build-system' Nikita Karetnikov
2013-05-08 16:47               ` 'python-build-system' Ludovic Courtès
2013-05-08 23:22                 ` 'python-build-system' Nikita Karetnikov
2013-05-09 20:29                   ` 'python-build-system' Ludovic Courtès
2013-04-29 19:33       ` 'python-build-system' Ludovic Courtès
2013-04-30 15:04         ` 'python-build-system' Ludovic Courtès
2013-04-28 22:50     ` 'python-build-system' Cyril Roelandt
2013-04-29 11:50       ` 'python-build-system' Ludovic Courtès
2013-04-29 19:24         ` 'python-build-system' Cyril Roelandt
2013-04-30 13:47           ` 'python-build-system' Nikita Karetnikov
2013-05-06 21:07             ` 'python-build-system' Ludovic Courtès

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).