guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[WIP 4/8] guix: python-build-system: Add option "#:use-setuptools?" (def


From: Hartmut Goebel
Subject: [WIP 4/8] guix: python-build-system: Add option "#:use-setuptools?" (default true).
Date: Mon, 10 Oct 2016 16:57:15 +0200

TODO: Documentation, test-case.

* guix/build-system/python.scm (python-build): New keyword argument
  "#:use-setuptools?", defaulting to #t.
* guix/build/python-build-system.scm (call-setup-py): New positional
  parameter "use-setuptools?". If false, do not use the shim-wrapper
  for addin setuptools. (build, check): accept keyword-
  parameter, and pass to call-setuppy. (install): same; if
  "use-setuptools?" is false, do not use options "--root" and
  "--single-version-externally-managed" for setup.py.
* doc/guix.texi (Build Systems): Document it.
---
 doc/guix.texi                      |  5 +++++
 guix/build-system/python.scm       |  2 ++
 guix/build/python-build-system.scm | 28 +++++++++++++++++-----------
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 02f7486..92a827a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3092,6 +3092,11 @@ the @code{#:python} parameter.  This is a useful way to 
force a package
 to be built for a specific version of the Python interpreter, which
 might be necessary if the package is only compatible with a single
 interpreter version.
+
+By default guix calls @code{setup.py} under control of
address@hidden, much like @command{pip} does.  Some packages are not
+compatible with setuptools (and pip), thus you can disable this by
+setting the @code{#:use-setuptools} parameter to @code{#f}.
 @end defvr
 
 @defvr {Scheme Variable} perl-build-system
diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm
index adeceb4..d4d3d28 100644
--- a/guix/build-system/python.scm
+++ b/guix/build-system/python.scm
@@ -177,6 +177,7 @@ pre-defined variants."
                        #:key
                        (tests? #t)
                        (test-target "test")
+                       (use-setuptools? #t)
                        (configure-flags ''())
                        (phases '(@ (guix build python-build-system)
                                    %standard-phases))
@@ -204,6 +205,7 @@ provides a 'setup.py' file as its build system."
                      #:system ,system
                      #:test-target ,test-target
                      #:tests? ,tests?
+                     #:use-setuptools? ,use-setuptools?
                      #:phases ,phases
                      #:outputs %outputs
                      #:search-paths ',(map search-path-specification->sexp
diff --git a/guix/build/python-build-system.scm 
b/guix/build/python-build-system.scm
index 50a094d..038fa97 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -47,22 +47,25 @@
    "exec(compile(getattr(tokenize, 'open', open)(__file__).read()"
    ".replace('\\r\\n', '\\n'), __file__, 'exec'))"))
 
-(define (call-setuppy command params)
+(define (call-setuppy command params use-setuptools?)
   (if (file-exists? "setup.py")
       (begin
          (format #t "running \"python setup.py\" with command ~s and 
parameters ~s~%"
                 command params)
-         (zero? (apply system* "python" "-c" setuptools-shim command params)))
+         (if use-setuptools?
+             (zero? (apply system* "python" "-c" setuptools-shim
+                           command params))
+             (zero? (apply system* "python" "./setup.py" command params))))
       (error "no setup.py found")))
 
-(define* (build #:rest empty)
+(define* (build #:key use-setuptools? #:allow-other-keys)
   "Build a given Python package."
-  (call-setuppy "build" '()))
+  (call-setuppy "build" '() use-setuptools?))
 
-(define* (check #:key tests? test-target #:allow-other-keys)
+(define* (check #:key tests? test-target use-setuptools? #:allow-other-keys)
   "Run the test suite of a given Python package."
   (if tests?
-    (call-setuppy test-target '())
+    (call-setuppy test-target '() use-setuptools?)
     #t))
 
 (define (get-python-version python)
@@ -71,15 +74,18 @@
          (major+minor (take components 2)))
     (string-join major+minor ".")))
 
-(define* (install #:key outputs inputs (configure-flags '())
+(define* (install #:key outputs inputs (configure-flags '()) use-setuptools?
                   #:allow-other-keys)
   "Install a given Python package."
   (let* ((out (assoc-ref outputs "out"))
-         (params (append (list (string-append "--prefix=" out)
-                               "--single-version-externally-managed"
-                               "--root=/")
+         (params (append (list (string-append "--prefix=" out))
+                         (if use-setuptools?
+                             ;; distutils does not accept these flags
+                             (list "--single-version-externally-managed"
+                                    "--root=/")
+                             '())
                          configure-flags)))
-    (call-setuppy "install" params)))
+    (call-setuppy "install" params use-setuptools?)))
 
 (define* (wrap #:key inputs outputs #:allow-other-keys)
   (define (list-of-files dir)
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]