Skip to content
Snippets Groups Projects
Unverified Commit 46bcdcc2 authored by Marius Bakke's avatar Marius Bakke Committed by Hartmut Goebel
Browse files

guix: python-build-system: Import setuptools before calling `setup.py'.


This is needed for packages using "distutils" instead of "setuptools" since
the former does not understand the "--single-version-externally-managed"
flag. Also export __file__ since it will be unset when setup.py is called from
python "exec".

* guix/build/python-build-system.scm (call-setuppy): extend "python setup.py"
  call to import setuptools, export __file__, and call setup.py from
  setuptools python environment.

Co-Authored-By: default avatarHartmut Goebel <h.goebel@crazy-compilers.com>
parent 7db40bce
No related branches found
No related tags found
No related merge requests found
...@@ -36,13 +36,25 @@ (define-module (guix build python-build-system) ...@@ -36,13 +36,25 @@ (define-module (guix build python-build-system)
;; ;;
;; Code: ;; Code:
(define setuptools-shim
;; Run setup.py with "setuptools" being imported, which will patch
;; "distutils". This is needed for packages using "distutils" instead of
;; "setuptools" since the former does not understand the
;; "--single-version-externally-managed" flag.
;; Python code taken from pip 9.0.1 pip/utils/setuptools_build.py
(string-append
"import setuptools, tokenize;__file__='setup.py';"
"f=getattr(tokenize, 'open', open)(__file__);"
"code=f.read().replace('\\r\\n', '\\n');"
"f.close();"
"exec(compile(code, __file__, 'exec'))"))
(define (call-setuppy command params) (define (call-setuppy command params)
(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" "setup.py" command params))) (zero? (apply system* "python" "-c" setuptools-shim command params)))
(error "no setup.py found"))) (error "no setup.py found")))
(define* (build #:rest empty) (define* (build #:rest empty)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment