[Python-checkins] bpo-38472: setup.py uses LC_ALL=C to check the C compiler (GH-30929)

vstinner webhook-mailer at python.org
Wed Jan 26 18:22:13 EST 2022


https://github.com/python/cpython/commit/a9503ac39474a9cb1b1935ddf159c0d9672b04b6
commit: a9503ac39474a9cb1b1935ddf159c0d9672b04b6
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-01-27T00:22:04+01:00
summary:

bpo-38472: setup.py uses LC_ALL=C to check the C compiler (GH-30929)

Fix GCC detection in setup.py when cross-compiling. The C compiler is
now run with LC_ALL=C. Previously, the detection failed with a German
locale.

files:
A Misc/NEWS.d/next/Build/2022-01-26-22-59-12.bpo-38472.RxfLho.rst
M setup.py

diff --git a/Misc/NEWS.d/next/Build/2022-01-26-22-59-12.bpo-38472.RxfLho.rst b/Misc/NEWS.d/next/Build/2022-01-26-22-59-12.bpo-38472.RxfLho.rst
new file mode 100644
index 0000000000000..4e0ee70bdc513
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-01-26-22-59-12.bpo-38472.RxfLho.rst
@@ -0,0 +1,2 @@
+Fix GCC detection in setup.py when cross-compiling. The C compiler is now
+run with LC_ALL=C. Previously, the detection failed with a German locale.
diff --git a/setup.py b/setup.py
index e30674f31cdb8..e47b2ab90958b 100644
--- a/setup.py
+++ b/setup.py
@@ -848,7 +848,9 @@ def add_cross_compiling_paths(self):
         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))
+        # bpo-38472: With a German locale, GCC returns "gcc-Version 9.1.0
+        # (GCC)", whereas it returns "gcc version 9.1.0" with the C locale.
+        ret = run_command('LC_ALL=C %s -E -v - </dev/null 2>%s 1>/dev/null' % (CC, tmpfile))
         is_gcc = False
         is_clang = False
         in_incdirs = False



More information about the Python-checkins mailing list