]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- Issue #11715: Fix multiarch detection without having Debian development
authordoko@ubuntu.com <doko@ubuntu.com>
Wed, 8 Aug 2012 10:15:55 +0000 (12:15 +0200)
committerdoko@ubuntu.com <doko@ubuntu.com>
Wed, 8 Aug 2012 10:15:55 +0000 (12:15 +0200)
  tools (dpkg-dev) installed.

Misc/NEWS
setup.py

index 9b53ce9b92b8ceb982fb0b8e8e3152cdbc90106d..53975f02b8a10922df544bfaaabf0667968510e2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -312,6 +312,9 @@ Tests
 Build
 -----
 
+- Issue #11715: Fix multiarch detection without having Debian development
+  tools (dpkg-dev) installed.
+
 - Issue #15037: Build OS X installers with local copy of ncurses 5.9 libraries
   to avoid curses.unget_wch bug present in older versions of ncurses such as
   those shipped with OS X.
index bc1e1bbd877465b14255120aef7c44a2667e0ac3..7f863a47896b14e91ee32d5d785caef9bbb2b5a6 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -379,6 +379,27 @@ class PyBuildExt(build_ext):
     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
         opt = ''