Skip to content

gh-116869: Fix test_cext on RHEL7 #117010

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 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
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
Diff view
23 changes: 13 additions & 10 deletions Lib/test/test_cext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ def main():
if std:
if support.MS_WINDOWS:
cflags.append(f'/std:{std}')
std_prefix = '/std'
else:
cflags.append(f'-std={std}')
std_prefix = '-std'

# Remove existing -std options to only test ours
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_prefix)]
cmd = shlex.join(cmd)
# CC env var overrides sysconfig CC variable in setuptools
os.environ['CC'] = cmd
# Remove existing -std or /std options from CC command line.
# Python adds -std=c11 option.
cmd = (sysconfig.get_config_var('CC') or '')
if cmd is not None:
if support.MS_WINDOWS:
std_prefix = '/std'
else:
std_prefix = '-std'
cmd = shlex.split(cmd)
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
cmd = shlex.join(cmd)
# CC env var overrides sysconfig CC variable in setuptools
os.environ['CC'] = cmd

# Define Py_LIMITED_API macro
if limited:
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_cppext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def test_build_cpp03(self):
def test_build_cpp11(self):
self.check_build('_testcpp11ext', std='c++11')

# Only test C++14 on MSVC.
# On s390x RHEL7, GCC 4.8.5 doesn't support C++14.
@unittest.skipIf(not support.MS_WINDOWS, "need Windows")
def test_build_cpp14(self):
self.check_build('_testcpp14ext', std='c++14')

Expand Down
24 changes: 14 additions & 10 deletions Lib/test/test_cppext/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ def main():
if std:
if support.MS_WINDOWS:
cppflags.append(f'/std:{std}')
std_prefix = '/std'
else:
cppflags.append(f'-std={std}')
std_prefix = '-std'

# Remove existing -std options to only test ours
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_prefix)]
cmd = shlex.join(cmd)
# CC env var overrides sysconfig CC variable in setuptools
os.environ['CC'] = cmd
# 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:
if support.MS_WINDOWS:
std_prefix = '/std'
else:
std_prefix = '-std'
cmd = shlex.split(cmd)
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
cmd = shlex.join(cmd)
# CC env var overrides sysconfig CC variable in setuptools
os.environ['CC'] = cmd

# On Windows, add PCbuild\amd64\ to include and library directories
include_dirs = []
Expand Down