From: Barry Warsaw Date: Wed, 6 Apr 2011 19:18:12 +0000 (-0400) Subject: Issue 11715: Build extension modules on multiarch Debian and Ubuntu by X-Git-Tag: v3.2.1b1~170^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ca305a599d487beba642903914f0a55259f9d52;p=thirdparty%2FPython%2Fcpython.git Issue 11715: Build extension modules on multiarch Debian and Ubuntu by extending search paths to include multiarch directories. --- diff --git a/setup.py b/setup.py index 51f8fde40aa9..29a002fa3916 100644 --- a/setup.py +++ b/setup.py @@ -339,10 +339,31 @@ class PyBuildExt(build_ext): return platform return sys.platform + def add_multiarch_paths(self): + # Debian/Ubuntu multiarch support. + # https://wiki.ubuntu.com/MultiarchSpec + tmpfile = os.path.join(self.build_temp, 'multiarch') + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + ret = os.system( + 'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' % + tmpfile) + try: + if ret >> 8 == 0: + with open(tmpfile) as fp: + multiarch_path_component = fp.readline().strip() + 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) + finally: + os.unlink(tmpfile) + def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') + self.add_multiarch_paths() # Add paths specified in the environment variables LDFLAGS and # CPPFLAGS for header and library files.