Skip to content

Commit 59c8ac7

Browse files
committed
Issue 11715: Merge multiarch fix from 3.1 branch.
2 parents 8debacb + 3178b7d commit 59c8ac7

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
@@ -370,12 +370,33 @@ def get_platform(self):
370370
return platform
371371
return sys.platform
372372

373+
def add_multiarch_paths(self):
374+
# Debian/Ubuntu multiarch support.
375+
# https://wiki.ubuntu.com/MultiarchSpec
376+
tmpfile = os.path.join(self.build_temp, 'multiarch')
377+
if not os.path.exists(self.build_temp):
378+
os.makedirs(self.build_temp)
379+
ret = os.system(
380+
'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
381+
tmpfile)
382+
try:
383+
if ret >> 8 == 0:
384+
with open(tmpfile) as fp:
385+
multiarch_path_component = fp.readline().strip()
386+
add_dir_to_list(self.compiler.library_dirs,
387+
'/usr/lib/' + multiarch_path_component)
388+
add_dir_to_list(self.compiler.include_dirs,
389+
'/usr/include/' + multiarch_path_component)
390+
finally:
391+
os.unlink(tmpfile)
392+
373393
def detect_modules(self):
374394
# Ensure that /usr/local is always used, but the local build
375395
# directories (i.e. '.' and 'Include') must be first. See issue
376396
# 10520.
377397
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
378398
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
399+
self.add_multiarch_paths()
379400

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

0 commit comments

Comments
 (0)