Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ca305a

Browse files
committed
Issue 11715: Build extension modules on multiarch Debian and Ubuntu by
extending search paths to include multiarch directories.
1 parent 8f377a3 commit 5ca305a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

setup.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,31 @@ def get_platform(self):
339339
return platform
340340
return sys.platform
341341

342+
def add_multiarch_paths(self):
343+
# Debian/Ubuntu multiarch support.
344+
# https://wiki.ubuntu.com/MultiarchSpec
345+
tmpfile = os.path.join(self.build_temp, 'multiarch')
346+
if not os.path.exists(self.build_temp):
347+
os.makedirs(self.build_temp)
348+
ret = os.system(
349+
'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
350+
tmpfile)
351+
try:
352+
if ret >> 8 == 0:
353+
with open(tmpfile) as fp:
354+
multiarch_path_component = fp.readline().strip()
355+
add_dir_to_list(self.compiler.library_dirs,
356+
'/usr/lib/' + multiarch_path_component)
357+
add_dir_to_list(self.compiler.include_dirs,
358+
'/usr/include/' + multiarch_path_component)
359+
finally:
360+
os.unlink(tmpfile)
361+
342362
def detect_modules(self):
343363
# Ensure that /usr/local is always used
344364
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
345365
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
366+
self.add_multiarch_paths()
346367

347368
# Add paths specified in the environment variables LDFLAGS and
348369
# CPPFLAGS for header and library files.

0 commit comments

Comments
 (0)