Merge branch 'python'

This commit is contained in:
Andreas Enge 2013-09-14 10:45:01 +02:00
commit aae4ead814
20 changed files with 314 additions and 67 deletions

View File

@ -45,7 +45,7 @@
`(("libgcrypt" ,libgcrypt) `(("libgcrypt" ,libgcrypt)
("lvm2" ,lvm2) ("lvm2" ,lvm2)
("popt" ,popt) ("popt" ,popt)
("python" ,python) ("python" ,python-wrapper)
("util-linux" ,util-linux))) ("util-linux" ,util-linux)))
(synopsis "hard disk encryption tool") (synopsis "hard disk encryption tool")
(description (description

View File

@ -53,7 +53,7 @@
("gmp" ,gmp) ("gmp" ,gmp)
("readline" ,readline) ("readline" ,readline)
("ncurses" ,ncurses) ("ncurses" ,ncurses)
("python" ,python) ("python" ,python-wrapper)
("texinfo" ,texinfo) ("texinfo" ,texinfo)
("dejagnu" ,dejagnu))) ("dejagnu" ,dejagnu)))
(home-page "http://www.gnu.org/software/gdb/") (home-page "http://www.gnu.org/software/gdb/")

View File

@ -136,7 +136,7 @@ printing, and psresize, for adjusting page sizes.")
("libtiff" ,libtiff) ("libtiff" ,libtiff)
("perl" ,perl) ("perl" ,perl)
("pkg-config" ,pkg-config) ; needed to find libtiff ("pkg-config" ,pkg-config) ; needed to find libtiff
("python" ,python) ("python" ,python-wrapper)
("tcl" ,tcl) ("tcl" ,tcl)
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments

View File

@ -104,7 +104,7 @@ shared NFS home directories.")
("gettext" ,guix:gettext) ("gettext" ,guix:gettext)
("libffi" ,libffi) ("libffi" ,libffi)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python) ("python" ,python-wrapper)
("zlib" ,zlib) ("zlib" ,zlib)
("perl" ,perl) ; needed by GIO tests ("perl" ,perl) ; needed by GIO tests
("dbus" ,dbus) ; for GDBus tests ("dbus" ,dbus) ; for GDBus tests

View File

@ -191,7 +191,7 @@ S/MIME.")
"1g1jly3wl4ks6h8ydkygyl2c4i7v3z91rg42005m6vm70y1d8b3d")))) "1g1jly3wl4ks6h8ydkygyl2c4i7v3z91rg42005m6vm70y1d8b3d"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs `(("perl" ,perl) (inputs `(("perl" ,perl)
("python" ,python) ("python" ,python-wrapper)
("gpg" ,gnupg))) ("gpg" ,gnupg)))
(arguments (arguments
`(#:tests? #f `(#:tests? #f

View File

@ -83,7 +83,7 @@ tools have full access to view and control running applications.")
("libspectre" ,libspectre) ("libspectre" ,libspectre)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("poppler" ,poppler) ("poppler" ,poppler)
("python" ,python) ("python" ,python-wrapper)
("xextproto" ,xextproto) ("xextproto" ,xextproto)
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments
@ -123,7 +123,7 @@ affine transformation (scale, rotation, shear, etc.)")
`(("cairo" ,cairo) `(("cairo" ,cairo)
("icu4c" ,icu4c) ("icu4c" ,icu4c)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python))) ("python" ,python-wrapper)))
(synopsis "opentype text shaping engine") (synopsis "opentype text shaping engine")
(description (description
"HarfBuzz is an OpenType text shaping engine.") "HarfBuzz is an OpenType text shaping engine.")

View File

@ -44,7 +44,7 @@
;; Dependencies used for the tests and for `event_rpcgen.py'. ;; Dependencies used for the tests and for `event_rpcgen.py'.
("which" ,which) ("which" ,which)
("python" ,python))) ("python" ,python-wrapper)))
(arguments (arguments
'(#:patches (list (assoc-ref %build-inputs "patch/dns-tests")))) '(#:patches (list (assoc-ref %build-inputs "patch/dns-tests"))))
(home-page "http://libevent.org/") (home-page "http://libevent.org/")

View File

@ -57,7 +57,7 @@
("libxml2" ,libxml2) ("libxml2" ,libxml2)
("perl" ,perl) ("perl" ,perl)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python) ("python" ,python-wrapper)
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments
`(#:phases `(#:phases

View File

@ -191,7 +191,7 @@ meaning that audio is compressed in FLAC without any loss in quality.")
("libogg" ,libogg) ("libogg" ,libogg)
("libpng" ,libpng) ("libpng" ,libpng)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python) ("python" ,python-wrapper)
("zlib" ,zlib))) ("zlib" ,zlib)))
(synopsis "kate, a karaoke and text codec for embedding in ogg") (synopsis "kate, a karaoke and text codec for embedding in ogg")
(description (description

View File

@ -19,19 +19,24 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages python) (define-module (gnu packages python)
#:use-module ((guix licenses) #:select (bsd-3 psfl x11)) #:use-module ((guix licenses) #:select (bsd-3 bsd-style psfl x11))
#:use-module ((guix licenses) #:select (zlib)
#:renamer (symbol-prefix-proc 'license))
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages gdbm) #:use-module (gnu packages gdbm)
#:use-module (gnu packages readline) #:use-module (gnu packages readline)
#:use-module (gnu packages openssl) #:use-module (gnu packages openssl)
#:use-module (gnu packages patchelf) #:use-module (gnu packages patchelf)
#:use-module (gnu packages sqlite)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix build-system python)) #:use-module (guix build-system python)
#:use-module (guix build-system trivial))
(define-public python (define-public python-2
(package (package
(name "python") (name "python")
(version "2.7.5") (version "2.7.5")
@ -151,8 +156,8 @@ packages; exception-based error handling; and very high level dynamic
data types.") data types.")
(license psfl))) (license psfl)))
(define-public python-3 (define-public python
(package (inherit python) (package (inherit python-2)
(version "3.3.2") (version "3.3.2")
(source (source
(origin (origin
@ -167,9 +172,34 @@ data types.")
(variable "PYTHONPATH") (variable "PYTHONPATH")
(directories '("lib/python3.3/site-packages"))))))) (directories '("lib/python3.3/site-packages")))))))
(define-public pytz (define-public python-wrapper
(package (inherit python)
(name "python-wrapper")
(source #f)
(build-system trivial-build-system)
(inputs `(("python" ,python)))
(arguments
`(#:modules ((guix build utils))
#:builder
(begin
(use-modules (guix build utils))
(let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
(python (string-append (assoc-ref %build-inputs "python") "/bin/")))
(mkdir-p bin)
(for-each
(lambda (old new)
(symlink (string-append python old)
(string-append bin "/" new)))
`("python3", "pydoc3", "idle3")
`("python", "pydoc", "idle"))))))
(description (string-append (package-description python)
"\n\nThis wrapper package provides symbolic links to the python binaries
without version suffix."))))
(define-public python-pytz
(package (package
(name "pytz") (name "python-pytz")
(version "2013b") (version "2013b")
(source (source
(origin (origin
@ -180,6 +210,7 @@ data types.")
(base32 (base32
"19giwgfcrg0nr1gdv49qnmf2jb2ilkcfc7qyqvfpz4dp0p64ksv5")))) "19giwgfcrg0nr1gdv49qnmf2jb2ilkcfc7qyqvfpz4dp0p64ksv5"))))
(build-system python-build-system) (build-system python-build-system)
(arguments `(#:tests? #f)) ; no test target
(home-page "https://launchpad.net/pytz") (home-page "https://launchpad.net/pytz")
(synopsis "The Python timezone library.") (synopsis "The Python timezone library.")
(description (description
@ -187,22 +218,28 @@ data types.")
using Python 2.4 or higher and provides access to the Olson timezone database.") using Python 2.4 or higher and provides access to the Olson timezone database.")
(license x11))) (license x11)))
(define-public babel (define-public python2-pytz
(package-with-python2 python-pytz))
(define-public python-babel
(package (package
(name "babel") (name "python-babel")
(version "0.9.6") (version "1.3")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
(uri (string-append "http://ftp.edgewall.com/pub/babel/Babel-" (uri (string-append "https://pypi.python.org/packages/source/B/Babel/Babel-"
version ".tar.gz")) version ".tar.gz"))
(sha256 (sha256
(base32 (base32
"03vmr54jq5vf3qw6kpdv7cdk7x7i2jhzyf1mawv2gk8zrxg0hfja")))) "0bnin777lc53nxd1hp3apq410jj5wx92n08h7h4izpl4f4sx00lz"))))
(build-system python-build-system) (build-system python-build-system)
(inputs (inputs
`(("pytz" ,pytz))) `(("python-pytz" ,python-pytz)
(home-page "http://babel.edgewall.org/") ("python-setuptools" ,python-setuptools)))
(arguments `(#:tests? #f)) ; no test target
(home-page "http://babel.pocoo.org/")
(synopsis (synopsis
"Tools for internationalizing Python applications") "Tools for internationalizing Python applications")
(description (description
@ -212,3 +249,133 @@ using Python 2.4 or higher and provides access to the Olson timezone database.")
access to various locale display names, localized number and date formatting, access to various locale display names, localized number and date formatting,
etc. ") etc. ")
(license bsd-3))) (license bsd-3)))
(define-public python2-babel
(package-with-python2 python-babel))
(define-public python-setuptools
(package
(name "python-setuptools")
(version "1.1.4")
(source
(origin
(method url-fetch)
(uri (string-append "https://pypi.python.org/packages/source/s/setuptools/setuptools-"
version ".tar.gz"))
(sha256
(base32
"0hl9sa5xr9bi2ifq51wy1bawsjv5nzvpbac7m9z1ciz778874csf"))))
(build-system python-build-system)
(arguments
`(#:tests? #f))
;;FIXME: test_sdist_with_utf8_encoded_filename fails in
;; /tmp/nix-build-python2-setuptools-1.1.4.drv-0/setuptools-1.1.4/setuptools/tests/test_sdist.py"
;; line 354
;; The tests pass with Python 2.7.5.
(home-page "https://pypi.python.org/pypi/setuptools")
(synopsis
"Library designed to facilitate packaging Python projects")
(description
"Setuptools is a fully-featured, stable library designed to facilitate
packaging Python projects, where packaging includes:
Python package and module definitions,
distribution package metadata,
test hooks,
project installation,
platform-specific details,
Python 3 support.")
(license psfl)))
(define-public python2-setuptools
(package-with-python2 python-setuptools))
(define-public python-dateutil
(package
(name "python-dateutil")
(version "1.5") ; last version for python < 3
(source
(origin
(method url-fetch)
(uri (string-append "http://labix.org/download/python-dateutil/python-dateutil-"
version ".tar.gz"))
(sha256
(base32
"0fqfglhy5khbvsipr3x7m6bcaqljh8xl5cw33vbfxy7qhmywm2n0"))))
(build-system python-build-system)
(inputs
`(("python-setuptools" ,python-setuptools)))
(home-page "http://labix.org/python-dateutil")
(synopsis
"Extensions to the standard datetime module, available in Python 2.3+")
(description
"The dateutil module provides powerful extensions to the standard
datetime module, available in Python 2.3+.")
(license psfl)))
(define-public python2-dateutil
(package-with-python2 python-dateutil))
(define-public python2-pysqlite
(package
(name "python2-pysqlite")
(version "2.6.3")
(source
(origin
(method url-fetch)
(uri (string-append "http://pysqlite.googlecode.com/files/pysqlite-"
version ".tar.gz"))
(sha256
(base32
"0nsqqfp072rgqbls100rdvbzkjkin7li3kprhfxlfqvzf608hlqd"))))
(build-system python-build-system)
(inputs
`(("sqlite" ,sqlite)))
(arguments
`(#:python ,python-2 ; incompatible with Python 3
#:tests? #f)) ; no test target
(home-page "http://labix.org/python-dateutil")
(synopsis
"SQLite bindings for Python.")
(description
"Pysqlite provides SQLite bindings for Python that comply to the
Database API 2.0T.")
(license zlib)))
(define-public python2-mechanize
(package
(name "python2-mechanize")
(version "0.2.5")
(source
(origin
(method url-fetch)
(uri (string-append "https://pypi.python.org/packages/source/m/mechanize/mechanize-"
version ".tar.gz"))
(sha256
(base32
"0rj7r166i1dyrq0ihm5rijfmvhs8a04im28lv05c0c3v206v4rrf"))))
(build-system python-build-system)
(inputs
`(("python2-setuptools" ,python2-setuptools)))
(arguments
`(#:python ,python-2 ; apparently incompatible with Python 3
#:tests? #f))
;; test fails with message
;; AttributeError: 'module' object has no attribute 'test_pullparser'
;; (python-3.3.2) or
;; AttributeError: 'module' object has no attribute 'test_urllib2_localnet'
;; (python-2.7.5).
;; The source code is from March 2011 and probably not up-to-date
;; with respect to python unit tests.
(home-page "http://wwwsearch.sourceforge.net/mechanize/")
(synopsis
"Stateful programmatic web browsing in Python")
(description
"Mechanize implements stateful programmatic web browsing in Python,
after Andy Lesters Perl module WWW::Mechanize.")
(license (bsd-style "file://COPYING"
"See COPYING in the distribution."))))

View File

@ -94,7 +94,7 @@
`(;; ("mesa" ,mesa) `(;; ("mesa" ,mesa)
;; ("libaio" ,libaio) ;; ("libaio" ,libaio)
("glib" ,glib) ("glib" ,glib)
("python" ,python) ("python" ,python-2) ; incompatible with Python 3 according to error message
("ncurses" ,ncurses) ("ncurses" ,ncurses)
("libpng" ,libpng) ("libpng" ,libpng)
("libjpeg" ,libjpeg-8) ("libjpeg" ,libjpeg-8)

View File

@ -150,7 +150,7 @@ anywhere.")
("patchelf" ,patchelf))) ; for (guix build rpath) ("patchelf" ,patchelf))) ; for (guix build rpath)
(native-inputs ; for the test suite (native-inputs ; for the test suite
`(("perl" ,perl) `(("perl" ,perl)
("python" ,python))) ("python" ,python-wrapper)))
(home-page "http://www.samba.org/") (home-page "http://www.samba.org/")
(synopsis (synopsis
"The standard Windows interoperability suite of programs for GNU and Unix") "The standard Windows interoperability suite of programs for GNU and Unix")

View File

@ -81,7 +81,7 @@
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
;; FIXME: Add interpreters fontforge and ruby, ;; FIXME: Add interpreters fontforge and ruby,
;; once they are available. ;; once they are available.
("python" ,python) ("python" ,python-2) ; incompatible with Python 3 (print syntax)
("tcsh" ,tcsh) ("tcsh" ,tcsh)
("teckit" ,teckit) ("teckit" ,teckit)
("t1lib" ,t1lib) ("t1lib" ,t1lib)
@ -202,7 +202,7 @@ world.")
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments '(#:tests? #f)) ; no `check' target (arguments '(#:tests? #f)) ; no `check' target
(inputs `(("texinfo" ,texinfo) (inputs `(("texinfo" ,texinfo)
("python" ,python) ("python" ,python-2) ; incompatible with Python 3 (print syntax)
("which" ,which))) ("which" ,which)))
(home-page "https://launchpad.net/rubber") (home-page "https://launchpad.net/rubber")
(synopsis "Rubber, a wrapper for LaTeX and friends") (synopsis "Rubber, a wrapper for LaTeX and friends")

View File

@ -58,7 +58,9 @@
;; require Zsh. ;; require Zsh.
`(("gettext" ,guix:gettext))) `(("gettext" ,guix:gettext)))
(arguments (arguments
`(#:tests? #f)) ; no test target `(#:tests? #f ; no test target
#:python ,python-2)) ; Python 3 apparently not yet supported, see
; https://answers.launchpad.net/bzr/+question/229048
(home-page "https://gnu.org/software/bazaar") (home-page "https://gnu.org/software/bazaar")
(synopsis "Decentralized revision control system") (synopsis "Decentralized revision control system")
(description (description
@ -86,7 +88,7 @@ from a command line or use a GUI application.")
("gettext" ,guix:gettext) ("gettext" ,guix:gettext)
("openssl" ,openssl) ("openssl" ,openssl)
("perl" ,perl) ("perl" ,perl)
("python" ,python) ; CAVEAT: incompatible with python-3 according to INSTALL ("python" ,python-2) ; CAVEAT: incompatible with python-3 according to INSTALL
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments
`(#:make-flags `("V=1") ; more verbose compilation `(#:make-flags `("V=1") ; more verbose compilation
@ -126,7 +128,7 @@ everything from small to very large projects with speed and efficiency.")
`(("apr" ,apr) `(("apr" ,apr)
("apr-util" ,apr-util) ("apr-util" ,apr-util)
("perl" ,perl) ("perl" ,perl)
("python" ,python) ("python" ,python-2) ; incompatible with Python 3 (print syntax)
("sqlite" ,sqlite) ("sqlite" ,sqlite)
("zlib" ,zlib))) ("zlib" ,zlib)))
(home-page "http://subversion.apache.org/") (home-page "http://subversion.apache.org/")

View File

@ -66,7 +66,7 @@ things the parser might find in the XML document (like start tags).")
(home-page "http://www.xmlsoft.org/") (home-page "http://www.xmlsoft.org/")
(synopsis "libxml2, a C parser for XML") (synopsis "libxml2, a C parser for XML")
(inputs `(("perl" ,perl) (inputs `(("perl" ,perl)
("python" ,python) ("python" ,python-2) ; incompatible with Python 3 (print syntax)
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments
`(#:phases `(#:phases
@ -102,7 +102,7 @@ things the parser might find in the XML document (like start tags).")
(synopsis "libxslt, a C library for applying XSLT stylesheets to XML documents") (synopsis "libxslt, a C library for applying XSLT stylesheets to XML documents")
(inputs `(("libgcrypt" ,libgcrypt) (inputs `(("libgcrypt" ,libgcrypt)
("libxml2" ,libxml2) ("libxml2" ,libxml2)
("python" ,python) ("python" ,python-wrapper)
("zlib" ,zlib))) ("zlib" ,zlib)))
(description (description
"Libxslt is an XSLT C library developed for the GNOME project. It is "Libxslt is an XSLT C library developed for the GNOME project. It is

View File

@ -1857,7 +1857,7 @@ tracking.")
"0ds4qg6slidrzyz6q9ckq0a19hn6blzpnvciy4brh741gn49jpdd")))) "0ds4qg6slidrzyz6q9ckq0a19hn6blzpnvciy4brh741gn49jpdd"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (inputs
`(("pkg-config" ,pkg-config) ("python" ,python))) `(("pkg-config" ,pkg-config) ("python" ,python-wrapper)))
(home-page "http://www.x.org/wiki/") (home-page "http://www.x.org/wiki/")
(synopsis "xorg implementation of the X Window System") (synopsis "xorg implementation of the X Window System")
(description "X.org provides an implementation of the X Window System") (description "X.org provides an implementation of the X Window System")
@ -4169,7 +4169,7 @@ tracking.")
("libxml2" ,libxml2) ("libxml2" ,libxml2)
("makedepend" ,makedepend) ("makedepend" ,makedepend)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python))) ("python" ,python-2))) ; incompatible with Python 3 (print syntax)
(arguments (arguments
`(#:configure-flags `(#:configure-flags
`("--with-gallium-drivers=r600,svga,swrast") ; drop r300 from the default list as it requires llvm `("--with-gallium-drivers=r600,svga,swrast") ; drop r300 from the default list as it requires llvm
@ -4215,7 +4215,7 @@ emulation to complete hardware acceleration for modern GPUs.")
`(("xcb-proto" ,xcb-proto) `(("xcb-proto" ,xcb-proto)
("libxslt" ,libxslt) ("libxslt" ,libxslt)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python))) ("python" ,python-wrapper)))
(home-page "http://www.x.org/wiki/") (home-page "http://www.x.org/wiki/")
(synopsis "xorg implementation of the X Window System") (synopsis "xorg implementation of the X Window System")
(description "X.org provides an implementation of the X Window System") (description "X.org provides an implementation of the X Window System")
@ -4270,7 +4270,7 @@ emulation to complete hardware acceleration for modern GPUs.")
("mesa" ,mesa) ("mesa" ,mesa)
("openssl" ,openssl) ("openssl" ,openssl)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python) ("python" ,python-wrapper)
("recordproto" ,recordproto) ("recordproto" ,recordproto)
("resourceproto" ,resourceproto) ("resourceproto" ,resourceproto)
("scrnsaverproto" ,scrnsaverproto) ("scrnsaverproto" ,scrnsaverproto)

View File

@ -40,7 +40,7 @@
"0cfg7ji3ia2in628w42wrfvw2ixmmm4rghwmv2k202mraysgm3vn")))) "0cfg7ji3ia2in628w42wrfvw2ixmmm4rghwmv2k202mraysgm3vn"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (inputs
`(("python" ,python) `(("python" ,python-wrapper)
("xmlto" ,xmlto))) ("xmlto" ,xmlto)))
(home-page "http://yasm.tortall.net/") (home-page "http://yasm.tortall.net/")
(synopsis "Rewrite of the NASM assembler") (synopsis "Rewrite of the NASM assembler")

View File

@ -120,7 +120,8 @@ UnZip recreates the stored directory structure by default.")
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs `(("perl" ,perl) ; for the documentation (inputs `(("perl" ,perl) ; for the documentation
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("python" ,python) ; for the documentation ("python" ,python-2) ; for the documentation; Python 3 not supported,
; http://forums.gentoo.org/viewtopic-t-863161-start-0.html
("zip" ,zip) ; to create test files ("zip" ,zip) ; to create test files
("zlib" ,zlib))) ("zlib" ,zlib)))
(arguments (arguments

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -25,7 +26,9 @@
#:use-module (guix build-system) #:use-module (guix build-system)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:export (python-build #:use-module (srfi srfi-26)
#:export (package-with-python2
python-build
python-build-system)) python-build-system))
;; Commentary: ;; Commentary:
@ -39,13 +42,60 @@
"Return the default Python package." "Return the default Python package."
;; Lazily resolve the binding to avoid a circular dependency. ;; Lazily resolve the binding to avoid a circular dependency.
(let ((python (resolve-interface '(gnu packages python)))) (let ((python (resolve-interface '(gnu packages python))))
(module-ref python 'python))) (module-ref python 'python-wrapper)))
(define (default-python2)
"Return the default Python 2 package."
(let ((python (resolve-interface '(gnu packages python))))
(module-ref python 'python-2)))
(define (package-with-explicit-python p python old-prefix new-prefix)
"Create a package with the same fields as P, which is assumed to use
PYTHON-BUILD-SYSTEM, such that it is compiled with PYTHON instead. The
inputs are changed recursively accordingly. If the name of P starts with
OLD-PREFIX, this is replaced by NEW-PREFIX; otherwise, NEW-PREFIX is
prepended to the name."
(let* ((build-system (package-build-system p))
(rewrite-if-package
(lambda (content)
;; CONTENT may be a string (e.g., for patches), in which case it
;; is returned, or a package, which is rewritten with the new
;; PYTHON and NEW-PREFIX.
(if (package? content)
(package-with-explicit-python content python
old-prefix new-prefix)
content)))
(rewrite
(match-lambda
((name content . rest)
(append (list name (rewrite-if-package content)) rest)))))
(package (inherit p)
(name
(let ((name (package-name p)))
(if (eq? build-system python-build-system)
(string-append new-prefix
(if (string-prefix? old-prefix name)
(substring name (string-length old-prefix))
name))
name)))
(arguments
(let ((arguments (package-arguments p)))
(if (eq? build-system python-build-system)
(if (member #:python arguments)
(substitute-keyword-arguments arguments ((#:python p) python))
(append arguments `(#:python ,python)))
arguments)))
(inputs
(map rewrite (package-inputs p)))
(native-inputs
(map rewrite (package-native-inputs p))))))
(define package-with-python2
(cut package-with-explicit-python <> (default-python2) "python-" "python2-"))
(define* (python-build store name source inputs (define* (python-build store name source inputs
#:key #:key
(python (default-python)) (python (default-python))
(python-version
(string-take (package-version (default-python)) 3))
(tests? #t) (tests? #t)
(configure-flags ''()) (configure-flags ''())
(phases '(@ (guix build python-build-system) (phases '(@ (guix build python-build-system)
@ -58,10 +108,10 @@
(guix build gnu-build-system) (guix build gnu-build-system)
(guix build utils))) (guix build utils)))
(modules '((guix build python-build-system) (modules '((guix build python-build-system)
(guix build gnu-build-system)
(guix build utils)))) (guix build utils))))
"Build SOURCE using PYTHON, and with INPUTS. This assumes that SOURCE "Build SOURCE using PYTHON, and with INPUTS. This assumes that SOURCE
provides a 'setup.py' file as its build system." provides a 'setup.py' file as its build system."
(define python-search-paths (define python-search-paths
(append (package-native-search-paths python) (append (package-native-search-paths python)
(standard-search-paths))) (standard-search-paths)))
@ -77,8 +127,8 @@ provides a 'setup.py' file as its build system."
#:system ,system #:system ,system
#:test-target "test" #:test-target "test"
#:tests? ,tests? #:tests? ,tests?
#:phases ,phases
#:outputs %outputs #:outputs %outputs
#:python-version ,python-version
#:search-paths ',(map search-path-specification->sexp #:search-paths ',(map search-path-specification->sexp
(append python-search-paths (append python-search-paths
search-paths)) search-paths))

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -34,26 +35,49 @@
;; ;;
;; Code: ;; 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 #:allow-other-keys) (define (call-setuppy command params)
"Run the test suite of a given Python package."
(if (file-exists? "setup.py") (if (file-exists? "setup.py")
(let ((args `("setup.py" "check"))) (begin
(format #t "running 'python' with arguments ~s~%" args) (format #t "running \"python setup.py\" with command ~s and parameters ~s~%"
(zero? (apply system* "python" args))) command params)
(zero? (apply system* "python" "setup.py" command params)))
(error "no setup.py found"))) (error "no setup.py found")))
(define* (wrap #:key outputs python-version #:allow-other-keys) (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 (get-python-version python)
(string-take (string-take-right python 5) 3))
(define* (install #:key outputs inputs (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))
(python-version (get-python-version (assoc-ref inputs "python")))
(old-path (getenv "PYTHONPATH"))
(add-path (string-append out "/lib/python" python-version
"/site-packages/")))
;; create the module installation directory and add it to PYTHONPATH
;; to make setuptools happy
(mkdir-p add-path)
(setenv "PYTHONPATH"
(string-append (if old-path
(string-append old-path ":")
"")
add-path))
(call-setuppy "install" params)))
(define* (wrap #:key inputs outputs #:allow-other-keys)
(define (list-of-files dir) (define (list-of-files dir)
(map (cut string-append dir "/" <>) (map (cut string-append dir "/" <>)
(or (scandir dir (lambda (f) (or (scandir dir (lambda (f)
@ -69,9 +93,11 @@
outputs)) outputs))
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(python (assoc-ref inputs "python"))
(var `("PYTHONPATH" prefix (var `("PYTHONPATH" prefix
,(cons (string-append out "/lib/python" ,(cons (string-append out "/lib/python"
python-version "/site-packages") (get-python-version python)
"/site-packages")
(search-path-as-string->list (search-path-as-string->list
(or (getenv "PYTHONPATH") "")))))) (or (getenv "PYTHONPATH") ""))))))
(for-each (lambda (dir) (for-each (lambda (dir)
@ -87,11 +113,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)