8000 Fix setup.py when CC contains -std=c11 option by vstinner · Pull Request #70 · python/pythoncapi-compat · GitHub
[go: up one dir, main page]

Skip to content

Fix setup.py when CC contains -std=c11 option #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
30 changes: 26 additions & 4 deletions tests/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/usr/bin/env python3
import os.path
import shlex
import sys
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
try:
from distutils import sysconfig
except ImportError:
import sysconfig


8E24
# C++ is only supported on Python 3.6 and newer
Expand Down Expand Up @@ -43,10 +52,23 @@


def main():
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
# 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:
cmd = shlex.split(cmd)
cmd = [arg for arg in cmd if not arg.startswith('-std=')]
if (sys.version_info >= (3, 8)):
cmd = shlex.join(cmd)
elif (sys.version_info >= (3, 3)):
cmd = ' '.join(shlex.quote(arg) for arg in cmd)
else:
# Python 2.7
import pipes
cmd = ' '.join(pipes.quote(arg) for arg in cmd)
# CC env var overrides sysconfig CC variable in setuptools
os.environ['CC'] = cmd

cflags = ['-I' + SRC_DIR]
cppflags = list(cflags)
Expand Down
0