[Yum-devel] [PATCH] setup: make build work on python 3

Martin Kletzander mkletzan at redhat.com
Fri Apr 5 13:12:15 UTC 2013


In python 3, the string module doesn't have 'split' function anymore
and users are encouraged to use '.split()' on the string itself.  Also
'map()' is lazy and returns an iterable map object, but setup expects
only a list, so it has to be wrapped in 'list()'.  All of this works
with python2 as well.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 setup.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index d0d0429..a42a9b7 100644
--- a/setup.py
+++ b/setup.py
@@ -1,16 +1,16 @@
-import os, string
+import os
 from distutils.core import setup, Extension

 pc = os.popen("pkg-config --cflags-only-I glib-2.0 libxml-2.0 sqlite3", "r")
-includes = map(lambda x:x[2:], string.split(pc.readline()))
+includes = list(map(lambda x:x[2:], pc.readline().split()))
 pc.close()

 pc = os.popen("pkg-config --libs-only-l glib-2.0 libxml-2.0 sqlite3", "r")
-libs = map(lambda x:x[2:], string.split(pc.readline()))
+libs = list(map(lambda x:x[2:], pc.readline().split()))
 pc.close()

 pc = os.popen("pkg-config --libs-only-L glib-2.0 libxml-2.0 sqlite3", "r")
-libdirs = map(lambda x:x[2:], string.split(pc.readline()))
+libdirs = list(map(lambda x:x[2:], pc.readline().split()))
 pc.close()

 module = Extension('_sqlitecache',
-- 
1.8.1.5



More information about the Yum-devel mailing list