guix: python-build-system: Add option "#:use-setuptools?" (default true).

* 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.
This commit is contained in:
Hartmut Goebel 2016-10-02 14:03:32 +02:00
parent 46bcdcc287
commit 5f7565d190
No known key found for this signature in database
GPG Key ID: 634A8DFFD3F631DF
3 changed files with 24 additions and 11 deletions

View File

@ -3137,6 +3137,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 to be built for a specific version of the Python interpreter, which
might be necessary if the package is only compatible with a single might be necessary if the package is only compatible with a single
interpreter version. interpreter version.
By default guix calls @code{setup.py} under control of
@code{setuptools}, 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 @end defvr
@defvr {Scheme Variable} perl-build-system @defvr {Scheme Variable} perl-build-system

View File

@ -177,6 +177,7 @@ pre-defined variants."
#:key #:key
(tests? #t) (tests? #t)
(test-target "test") (test-target "test")
(use-setuptools? #t)
(configure-flags ''()) (configure-flags ''())
(phases '(@ (guix build python-build-system) (phases '(@ (guix build python-build-system)
%standard-phases)) %standard-phases))
@ -204,6 +205,7 @@ provides a 'setup.py' file as its build system."
#:system ,system #:system ,system
#:test-target ,test-target #:test-target ,test-target
#:tests? ,tests? #:tests? ,tests?
#:use-setuptools? ,use-setuptools?
#:phases ,phases #:phases ,phases
#:outputs %outputs #:outputs %outputs
#:search-paths ',(map search-path-specification->sexp #:search-paths ',(map search-path-specification->sexp

View File

@ -49,22 +49,25 @@
"f.close();" "f.close();"
"exec(compile(code, __file__, 'exec'))")) "exec(compile(code, __file__, 'exec'))"))
(define (call-setuppy command params) (define (call-setuppy command params use-setuptools?)
(if (file-exists? "setup.py") (if (file-exists? "setup.py")
(begin (begin
(format #t "running \"python setup.py\" with command ~s and parameters ~s~%" (format #t "running \"python setup.py\" with command ~s and parameters ~s~%"
command params) 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"))) (error "no setup.py found")))
(define* (build #:rest empty) (define* (build #:key use-setuptools? #:allow-other-keys)
"Build a given Python package." "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." "Run the test suite of a given Python package."
(if tests? (if tests?
(call-setuppy test-target '()) (call-setuppy test-target '() use-setuptools?)
#t)) #t))
(define (get-python-version python) (define (get-python-version python)
@ -73,15 +76,18 @@
(major+minor (take components 2))) (major+minor (take components 2)))
(string-join major+minor "."))) (string-join major+minor ".")))
(define* (install #:key outputs (configure-flags '()) (define* (install #:key outputs (configure-flags '()) use-setuptools?
#:allow-other-keys) #:allow-other-keys)
"Install a given Python package." "Install a given Python package."
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(params (append (list (string-append "--prefix=" out) (params (append (list (string-append "--prefix=" out))
"--single-version-externally-managed" (if use-setuptools?
;; distutils does not accept these flags
(list "--single-version-externally-managed"
"--root=/") "--root=/")
'())
configure-flags))) configure-flags)))
(call-setuppy "install" params))) (call-setuppy "install" params use-setuptools?)))
(define* (wrap #:key inputs outputs #:allow-other-keys) (define* (wrap #:key inputs outputs #:allow-other-keys)
(define (list-of-files dir) (define (list-of-files dir)