gh-92906: Enable test_cext and test_cppext on Windows (#117000)

On Windows in release mode, the test_cext and test_cppext can now
build C and C++ extensions.

* test_cext now also builds the C extension without options.
* test_cppext now also builds the C++ extension without options.
* Add C++14 test to test_cppext; C++11 is not supported by MSVC.
* Make setup_venv_with_pip_setuptools_wheel() quiet when
  support.verbose is false. Only show stdout and stderr on failure.
This commit is contained in:
Victor Stinner 2024-03-19 15:03:27 +01:00 committed by GitHub
parent 27cf3ed00c
commit a114d08a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 145 additions and 60 deletions

View file

@ -2251,16 +2251,25 @@ def _findwheel(pkgname):
# and returns the path to the venv directory and the path to the python executable
@contextlib.contextmanager
def setup_venv_with_pip_setuptools_wheel(venv_dir):
import shlex
import subprocess
from .os_helper import temp_cwd
def run_command(cmd):
if verbose:
print()
print('Run:', ' '.join(map(shlex.quote, cmd)))
subprocess.run(cmd, check=True)
else:
subprocess.run(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=True)
with temp_cwd() as temp_dir:
# Create virtual environment to get setuptools
cmd = [sys.executable, '-X', 'dev', '-m', 'venv', venv_dir]
if verbose:
print()
print('Run:', ' '.join(cmd))
subprocess.run(cmd, check=True)
run_command(cmd)
venv = os.path.join(temp_dir, venv_dir)
@ -2275,10 +2284,7 @@ def setup_venv_with_pip_setuptools_wheel(venv_dir):
'-m', 'pip', 'install',
_findwheel('setuptools'),
_findwheel('wheel')]
if verbose:
print()
print('Run:', ' '.join(cmd))
subprocess.run(cmd, check=True)
run_command(cmd)
yield python