File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
# gh-91321: Build a basic C++ test extension to check that the Python C API is
2
2
# compatible with C++ and does not emit C++ compiler warnings.
3
3
import os
4
+ import shlex
4
5
import sys
6
+ import sysconfig
5
7
6
8
from setuptools import setup , Extension
7
9
@@ -30,6 +32,17 @@ def main():
30
32
31
33
cppflags = [* CPPFLAGS , f'-std={ std } ' ]
32
34
35
+ # gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11
36
+ # option emits a C++ compiler warning. Remove "-std11" option from the
37
+ # CC command.
38
+ cmd = (sysconfig .get_config_var ('CC' ) or '' )
39
+ if cmd is not None :
40
+ cmd = shlex .split (cmd )
41
+ cmd = [arg for arg in cmd if not arg .startswith ('-std=' )]
42
+ cmd = shlex .join (cmd )
43
+ # CC env var overrides sysconfig CC variable in setuptools
44
+ os .environ ['CC' ] = cmd
45
+
33
46
cpp_ext = Extension (
34
47
name ,
35
48
sources = [SOURCE ],
Original file line number Diff line number Diff line change
1
+ Fix test_cppext when the C compiler command ``-std=c11 `` option: remove
2
+ ``-std= `` options from the compiler command. Patch by Victor Stinner.
You can’t perform that action at this time.
0 commit comments