summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-19 14:03:27 (GMT)
committerGitHub <noreply@github.com>2024-03-19 14:03:27 (GMT)
commita114d08a8912a50530ab3f19842c6ba73b0d1017 (patch)
treee161344235cf2feb8d32a7a593134ec384c68e68 /Lib/test/support/__init__.py
parent27cf3ed00cfe942f4277c273a3dda8ee2ba61fc8 (diff)
downloadcpython-a114d08a8912a50530ab3f19842c6ba73b0d1017.zip
cpython-a114d08a8912a50530ab3f19842c6ba73b0d1017.tar.gz
cpython-a114d08a8912a50530ab3f19842c6ba73b0d1017.tar.bz2
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.
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index ce693e5..a1c7987 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -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