diff options
author | Victor Stinner <vstinner@python.org> | 2023-08-23 04:52:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 02:52:56 +0000 |
commit | 9173b2bbe13aeccc075b571da05c653a2a91de1b (patch) | |
tree | 56e441a4e8bbf97021596ec2e229c00347ee7178 /Lib/test/test_cppext/setup.py | |
parent | 3a1ac87f8f89d3206b46a0df4908afae629d669d (diff) | |
download | cpython-9173b2bbe13aeccc075b571da05c653a2a91de1b.tar.gz cpython-9173b2bbe13aeccc075b571da05c653a2a91de1b.zip |
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.
Diffstat (limited to 'Lib/test/test_cppext/setup.py')
-rw-r--r-- | Lib/test/test_cppext/setup.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_cppext/setup.py b/Lib/test/test_cppext/setup.py index 6867094a420..976633bc338 100644 --- a/Lib/test/test_cppext/setup.py +++ b/Lib/test/test_cppext/setup.py @@ -1,7 +1,9 @@ # gh-91321: Build a basic C++ test extension to check that the Python C API is # compatible with C++ and does not emit C++ compiler warnings. import os +import shlex import sys +import sysconfig from setuptools import setup, Extension @@ -30,6 +32,17 @@ def main(): cppflags = [*CPPFLAGS, f'-std={std}'] + # gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11 + # option emits a C++ compiler warning. Remove "-std11" option from the + # CC command. + cmd = (sysconfig.get_config_var('CC') or '') + if cmd is not None: + cmd = shlex.split(cmd) + cmd = [arg for arg in cmd if not arg.startswith('-std=')] + cmd = shlex.join(cmd) + # CC env var overrides sysconfig CC variable in setuptools + os.environ['CC'] = cmd + cpp_ext = Extension( name, sources=[SOURCE], |