From 3df47231e6c632aadcd7b103bb5b399a8d29772d Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Wed, 4 Sep 2013 18:04:15 +0200 Subject: guix: python: Switch to python-wrapper as the default version for the python build system (switches to Python 3) and compute python-version instead of passing it as a parameter. * guix/build-system/python.scm (default-python): Switch to python-wrapper. * guix/build-system/python.scm (python-build): Drop parameter #:python-version. * guix/build/python-build-system.scm (wrap): Compute python version from input. --- guix/build-system/python.scm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'guix/build-system') diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index b60adb182f..7ac93b296b 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -39,13 +39,11 @@ (define (default-python) "Return the default Python package." ;; Lazily resolve the binding to avoid a circular dependency. (let ((python (resolve-interface '(gnu packages python)))) - (module-ref python 'python))) + (module-ref python 'python-wrapper))) (define* (python-build store name source inputs #:key (python (default-python)) - (python-version - (string-take (package-version (default-python)) 3)) (tests? #t) (configure-flags ''()) (phases '(@ (guix build python-build-system) @@ -62,6 +60,7 @@ (define* (python-build store name source inputs (guix build utils)))) "Build SOURCE using PYTHON, and with INPUTS. This assumes that SOURCE provides a 'setup.py' file as its build system." + (define python-search-paths (append (package-native-search-paths python) (standard-search-paths))) @@ -78,7 +77,6 @@ (define builder #:test-target "test" #:tests? ,tests? #:outputs %outputs - #:python-version ,python-version #:search-paths ',(map search-path-specification->sexp (append python-search-paths search-paths)) -- cgit v1.2.3 From 11bb85a10d4a84dab7fdfaaaf7012b743ce7a09f Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Sun, 8 Sep 2013 16:57:37 +0200 Subject: guix: python: Add package-with-python2, a procedure rewriting a package to compile with Python 2 instead of the default Python 3. * guix/build-system/python.scm (default-python2, package-with-explicit-python, package-with-python2): New procedures. * guix/build-system/python.scm (python2-pytz, python2-babel): Use package-with-python2. --- gnu/packages/python.scm | 11 +++------ guix/build-system/python.scm | 54 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 9 deletions(-) (limited to 'guix/build-system') diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index ce89281e26..3ff4da2149 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -28,6 +28,7 @@ (define-module (gnu packages python) #:use-module (gnu packages patchelf) #:use-module (guix packages) #:use-module (guix download) + #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (guix build-system python) #:use-module (guix build-system trivial)) @@ -215,9 +216,7 @@ (define-public python-pytz (license x11))) (define-public python2-pytz - (package (inherit python-pytz) - (name "python2-pytz") - (arguments (append (package-arguments python-pytz) `(#:python ,python-2))))) + (package-with-python2 python-pytz)) (define-public python-babel (package @@ -247,8 +246,4 @@ (define-public python-babel (license bsd-3))) (define-public python2-babel - (package (inherit python-babel) - (name "python2-babel") - (inputs - `(("python2-pytz" ,python2-pytz))) - (arguments (append (package-arguments python-babel) `(#:python ,python-2))))) + (package-with-python2 python-babel)) diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index 7ac93b296b..d120cc9cc3 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013 Ludovic Courtès +;;; Copyright © 2013 Andreas Enge ;;; Copyright © 2013 Nikita Karetnikov ;;; ;;; This file is part of GNU Guix. @@ -25,7 +26,9 @@ (define-module (guix build-system python) #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (ice-9 match) - #:export (python-build + #:use-module (srfi srfi-26) + #:export (package-with-python2 + python-build python-build-system)) ;; Commentary: @@ -41,6 +44,55 @@ (define (default-python) (let ((python (resolve-interface '(gnu packages 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 #:key (python (default-python)) -- cgit v1.2.3 From 1d1f939798d2649bbabc962e37f90efe5805e202 Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Tue, 10 Sep 2013 11:42:07 +0200 Subject: guix: python: Add parameter #:phases to build system. * guix/build-system/python.scm (python-build): Use parameter #:phases. --- guix/build-system/python.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'guix/build-system') diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index d120cc9cc3..d018ee70f3 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -128,6 +128,7 @@ (define builder #:system ,system #:test-target "test" #:tests? ,tests? + #:phases ,phases #:outputs %outputs #:search-paths ',(map search-path-specification->sexp (append python-search-paths -- cgit v1.2.3 From e1a264f6fac2f517a2192e07eaae1db600eb8b1d Mon Sep 17 00:00:00 2001 From: Andreas Enge Date: Tue, 10 Sep 2013 20:32:50 +0200 Subject: guix: python: Do not import %standard-phases from gnu-build-system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build-system/python.scm (python-build): Drop module gnu-build-system. Thanks to Ludovic Courtès . --- guix/build-system/python.scm | 1 - 1 file changed, 1 deletion(-) (limited to 'guix/build-system') diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index d018ee70f3..03e587ba01 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -108,7 +108,6 @@ (define* (python-build store name source inputs (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." -- cgit v1.2.3