[Python-checkins] cpython (2.7): - Issue #11715: Fix multiarch detection without having Debian development

matthias.klose python-checkins at python.org
Fri Sep 21 14:04:55 CEST 2012


http://hg.python.org/cpython/rev/53fa224b95f4
changeset:   79080:53fa224b95f4
branch:      2.7
user:        doko at ubuntu.com
date:        Fri Sep 21 13:51:40 2012 +0200
summary:
  - Issue #11715: Fix multiarch detection without having Debian development
  tools (dpkg-dev) installed.

files:
  Misc/NEWS |   3 +++
  setup.py  |  21 +++++++++++++++++++++
  2 files changed, 24 insertions(+), 0 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -400,6 +400,9 @@
 Build
 -----
 
+- Issue #11715: Fix multiarch detection without having Debian development
+  tools (dpkg-dev) installed.
+
 - Issue #15819: Make sure we can build Python out-of-tree from a readonly
   source directory.  (Somewhat related to Issue #9860.)
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -351,6 +351,27 @@
     def add_multiarch_paths(self):
         # Debian/Ubuntu multiarch support.
         # https://wiki.ubuntu.com/MultiarchSpec
+        cc = sysconfig.get_config_var('CC')
+        tmpfile = os.path.join(self.build_temp, 'multiarch')
+        if not os.path.exists(self.build_temp):
+            os.makedirs(self.build_temp)
+        ret = os.system(
+            '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
+        multiarch_path_component = ''
+        try:
+            if ret >> 8 == 0:
+                with open(tmpfile) as fp:
+                    multiarch_path_component = fp.readline().strip()
+        finally:
+            os.unlink(tmpfile)
+
+        if multiarch_path_component != '':
+            add_dir_to_list(self.compiler.library_dirs,
+                            '/usr/lib/' + multiarch_path_component)
+            add_dir_to_list(self.compiler.include_dirs,
+                            '/usr/include/' + multiarch_path_component)
+            return
+
         if not find_executable('dpkg-architecture'):
             return
         tmpfile = os.path.join(self.build_temp, 'multiarch')

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list