From 344f12bdb694314ca85da16a5b7d0d59d41d9b2f Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Thu, 16 Sep 2021 15:46:09 -0500
Subject: [PATCH 08/25] bpo-22699: Allow compiling on debian/ubuntu with a
different compiler
This PR fixes one issue mentioned in the bpo
https://bugs.python.org/issue22699#msg364685 with a slightly better
patch than given
---
setup.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 534b14104b..9c3dd04989 100644
--- a/setup.py
+++ b/setup.py
@@ -667,9 +667,30 @@ def check_extension_import(self, ext):
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)
+
+ tmpfile_sysroot = os.path.join(self.build_temp, 'sysroot')
+ ret_sysroot = run_command(
+ '%s -print-sysroot > %s 2> /dev/null' % (CC, tmpfile_sysroot))
+
+ try:
+ if ret_sysroot == 0:
+ with open(tmpfile_sysroot) as fp:
+ sysroot = fp.readline().strip()
+ # if the sysroot is not /, then we are not using
+ # the compiler from debian/ubuntu
+ if sysroot not in ['', '/']:
+ add_dir_to_list(self.compiler.library_dirs,
+ sysroot + '/usr/lib/')
+ add_dir_to_list(self.compiler.include_dirs,
+ sysroot + '/usr/include/')
+ return
+ finally:
+ os.unlink(tmpfile_sysroot)
+
+ tmpfile = os.path.join(self.build_temp, 'multiarch')
+
ret = run_command(
'%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile))
multiarch_path_component = ''
--
2.32.1 (Apple Git-133)