diff options
author | Marius Bakke <mbakke@fastmail.com> | 2016-09-29 18:41:35 +0100 |
---|---|---|
committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2016-11-15 17:37:43 +0100 |
commit | 46bcdcc287ecfc1db8b7a0429e72517f407b580d (patch) | |
tree | 6a63f6d94ecdaee787ef52382cdb1c62d9c72c99 /guix/build | |
parent | 7db40bce58e149ecb541d295e01cfbfe953d39a3 (diff) |
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: Hartmut Goebel <h.goebel@crazy-compilers.com>
Diffstat (limited to 'guix/build')
-rw-r--r-- | guix/build/python-build-system.scm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm index 2424fed310..6086df3e82 100644 --- a/guix/build/python-build-system.scm +++ b/guix/build/python-build-system.scm @@ -36,13 +36,25 @@ ;; ;; 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) (if (file-exists? "setup.py") (begin (format #t "running \"python setup.py\" with command ~s and parameters ~s~%" command params) - (zero? (apply system* "python" "setup.py" command params))) + (zero? (apply system* "python" "-c" setuptools-shim command params))) (error "no setup.py found"))) (define* (build #:rest empty) |