Hartmut Goebel <h.goe...@crazy-compilers.com> writes:

> Am 28.09.2016 um 17:54 schrieb Marius Bakke:
>> Or push a branch somewhere?
>
> Branch is now available at 
> <https://gitlab.com/htgoebel/guix/tree/python-build-system>

Thanks a lot for doing this!

After adding a couple of patches I'm able to build many python packages.
Patch #2 mostly emulates NixOS "shim" setup.py[0], required for packages
using distutils instead of setuptools.

Some packages really don't like the new configure flags however (scons).
Perhaps we should have them as default, but if #:configure-flags is set,
let them be overridden?

Also some packages are missing a dependency on "python-py"[1].

Perhaps we can set up a Hydra channel to deal with the fallout?

Cheers,
Marius

0: 
https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/python/run_setup.py

1: https://pypi.python.org/pypi/py/1.4.31

>From a12000dd320cebeb920a4f790fe9206a2b6bda41 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mba...@fastmail.com>
Date: Thu, 29 Sep 2016 18:29:21 +0100
Subject: [PATCH 1/2] guix: python-build-system: fix configure flag append
 (followup to dba07a8d1)

---
 guix/build/python-build-system.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 8d4d6d3..d07b83f 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -65,11 +65,11 @@
                   #: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)
+                               "--single-version-externally-managed"
+                               "--root=/")
                          configure-flags)))
-        (call-setuppy "install" params)))
+    (call-setuppy "install" params)))
 
 (define* (wrap #:key inputs outputs #:allow-other-keys)
   (define (list-of-files dir)
-- 
2.10.0

>From 84fa3e8be3d3d868ddb9278a96807086415b754d Mon Sep 17 00:00:00 2001
From: Marius Bakke <mba...@fastmail.com>
Date: Thu, 29 Sep 2016 18:41:35 +0100
Subject: [PATCH 2/2] 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.
---
 guix/build/python-build-system.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index d07b83f..4362c48 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -42,7 +42,11 @@
       (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" (string-append "import setuptools;"
+                                           "__file__='setup.py';"
+                                           "exec(open('setup.py').read())")
+                       command params)))
       (error "no setup.py found")))
 
 (define* (build #:rest empty)
-- 
2.10.0

Reply via email to