summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--guix/build/python-build-system.scm14
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)