summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-24 17:53:33 (GMT)
committerGitHub <noreply@github.com>2021-11-24 17:53:33 (GMT)
commitb30bf4520ae9d6e7eca09d812dd8a86c020b9202 (patch)
treeafa4acc502fcd753c4c20090981bbf7fd6ccb623
parent64c3807da93fc3e0c15bc376f220b2d24551023e (diff)
downloadcpython-b30bf4520ae9d6e7eca09d812dd8a86c020b9202.zip
cpython-b30bf4520ae9d6e7eca09d812dd8a86c020b9202.tar.gz
cpython-b30bf4520ae9d6e7eca09d812dd8a86c020b9202.tar.bz2
bpo-45881: Use CC from env first for cross building (GH-29752)
-rw-r--r--Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst2
-rw-r--r--setup.py19
2 files changed, 11 insertions, 10 deletions
diff --git a/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst b/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst
new file mode 100644
index 0000000..b697658
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-11-24-17-14-06.bpo-45881.GTXXLk.rst
@@ -0,0 +1,2 @@
+``setup.py`` now uses ``CC`` from environment first to discover multiarch
+and cross compile paths.
diff --git a/setup.py b/setup.py
index 932667a..79f8f4e 100644
--- a/setup.py
+++ b/setup.py
@@ -84,6 +84,9 @@ CYGWIN = (HOST_PLATFORM == 'cygwin')
MACOS = (HOST_PLATFORM == 'darwin')
AIX = (HOST_PLATFORM.startswith('aix'))
VXWORKS = ('vxworks' in HOST_PLATFORM)
+CC = os.environ.get("CC")
+if not CC:
+ CC = sysconfig.get_config_var("CC")
SUMMARY = """
@@ -556,6 +559,9 @@ class PyBuildExt(build_ext):
def build_extensions(self):
self.set_srcdir()
+ self.set_compiler_executables()
+ self.configure_compiler()
+ self.init_inc_lib_dirs()
# Detect which modules should be compiled
self.detect_modules()
@@ -565,7 +571,6 @@ class PyBuildExt(build_ext):
self.update_sources_depends()
mods_built, mods_disabled = self.handle_configured_extensions()
- self.set_compiler_executables()
if LIST_MODULE_NAMES:
for ext in self.extensions:
@@ -751,12 +756,11 @@ 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 = run_command(
- '%s -print-multiarch > %s 2> /dev/null' % (cc, tmpfile))
+ '%s -print-multiarch > %s 2> /dev/null' % (CC, tmpfile))
multiarch_path_component = ''
try:
if ret == 0:
@@ -818,11 +822,10 @@ class PyBuildExt(build_ext):
d = os.path.normpath(d)
add_dir_to_list(self.compiler.library_dirs, d)
- cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'wrccpaths')
os.makedirs(self.build_temp, exist_ok=True)
try:
- ret = run_command('%s --print-search-dirs >%s' % (cc, tmpfile))
+ ret = run_command('%s --print-search-dirs >%s' % (CC, tmpfile))
if ret:
return
with open(tmpfile) as fp:
@@ -840,11 +843,10 @@ class PyBuildExt(build_ext):
pass
def add_cross_compiling_paths(self):
- cc = sysconfig.get_config_var('CC')
tmpfile = os.path.join(self.build_temp, 'ccpaths')
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
- ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (cc, tmpfile))
+ ret = run_command('%s -E -v - </dev/null 2>%s 1>/dev/null' % (CC, tmpfile))
is_gcc = False
is_clang = False
in_incdirs = False
@@ -1407,9 +1409,6 @@ class PyBuildExt(build_ext):
# remove dummy extension
self.extensions = []
- self.configure_compiler()
- self.init_inc_lib_dirs()
-
# Some C extensions are built by entries in Modules/Setup.bootstrap.
# These are extensions are required to bootstrap the interpreter or
# build process.