bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnu: Fix zlib support in Python.


From: Cyril Roelandt
Subject: [PATCH] gnu: Fix zlib support in Python.
Date: Wed, 3 Apr 2013 23:33:29 +0200

We must adjust 'inc_dirs' and 'lib_dirs' in setup.py.
---
On 04/03/2013 10:35 AM, Ludovic Courtès wrote:
> Can you strace it to see which zlib gets loaded?

Well, this is funny. When running "python -c "import zlib", /usr/bin/python is
called:

execve("/home/cyril/.guix-profile/bin/python", ["python", "-c", "import zlib"], 
[/* 23 vars */]) = 0

I had to use an absolute path to run the right interpreter:

execve("/home/cyril/.guix-profile/bin/python", 
["/home/cyril/.guix-profile/bin/py"..., "-c", "import zlib"], [/* 23 vars */]) 
= 0

and it fails to load zlib.


Anyway, I think the zlib module was not found because setup.py only looks for
the libraries/headers in a few hardcoded directories

        lib_dirs = self.compiler.library_dirs + [
            '/lib64', '/usr/lib64',
            '/lib', '/usr/lib',
            ]
        inc_dirs = self.compiler.include_dirs + ['/usr/include']


Could you confirm that:
1) This patch fixes your zlib issues
2) A similar error occurs when importing other modules, such as bz2

?

I do not think there is a more elegant solution than patching setup.py. I tried
running "CFLAGS=-I/path/to/zlib/include ./configure" and
"CFLAGS=-I/path/to/zlib/include make" but it does not seem to make any
difference.


Cyril.


 gnu/packages/python.scm |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 52b11e4..505dcd9 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -38,7 +38,22 @@
        (base32
         "11f9aw855lrmknr6c82gm1ijr3n0smc6idyp94y7774yivjnplv1"))))
     (build-system gnu-build-system)
-    (arguments `(#:tests? #f)) ; XXX: some tests fail
+    (arguments
+     `(#:tests? #f ; XXX: some tests fail
+       #:phases
+       (alist-replace
+        'configure
+        (lambda* (#:key inputs #:allow-other-keys #:rest args)
+          (let ((configure (assoc-ref %standard-phases 'configure))
+                (zlib (assoc-ref inputs "zlib")))
+            (substitute* "setup.py"
+              (("'/lib64', '/usr/lib64'")
+               (string-append "'" zlib "/lib'")))
+            (substitute* "setup.py"
+              (("\\['/usr/include'\\]")
+               (string-append "['" zlib "/include']")))
+            (apply configure args)))
+        %standard-phases)))
     (inputs
      `(("zlib" ,zlib)
        ("openssl" ,openssl)
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]