Skip to content

Commit 82bf244

Browse files
committed
Update test_cppext to stop invoking setuptools-based script as a CLI
This allows the "package" to be built using regular Python packaging workflows instead of relying on `setuptools` being present in the virtual environment.
1 parent 6aef7f9 commit 82bf244

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed
File renamed without changes.

Lib/test/test_cppext.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# gh-91321: Build a basic C++ test extension to check that the Python C API is
22
# compatible with C++ and does not emit C++ compiler warnings.
33
import os.path
4+
try:
5+
import ssl
6+
except ImportError:
7+
ssl = None
48
import sys
59
import unittest
610
import subprocess
@@ -12,7 +16,7 @@
1216
MS_WINDOWS = (sys.platform == 'win32')
1317

1418

15-
SETUP_TESTCPPEXT = support.findfile('setup_testcppext.py')
19+
PKG_CPPEXTDATA = os.path.dirname(support.findfile('setup.py', subdir="cppextdata"))
1620

1721

1822
@support.requires_subprocess()
@@ -31,6 +35,8 @@ def test_build_cpp03(self):
3135
@unittest.skipIf(
3236
'-fsanitize' in (sysconfig.get_config_var('PY_CFLAGS') or ''),
3337
'test does not work with analyzing builds')
38+
# the test uses pip which needs a TLS connection to PyPI
39+
@unittest.skipIf(ssl is None, 'No ssl module')
3440
# the test uses venv+pip: skip if it's not available
3541
@support.requires_venv_with_pip()
3642
def check_build(self, std_cpp03, extension_name):
@@ -76,14 +82,9 @@ def run_cmd(operation, cmd):
7682
self.fail(
7783
f"{operation} failed with exit code {proc.returncode}")
7884

79-
# Build the C++ extension
85+
# Build and install the C++ extension
8086
cmd = [python, '-X', 'dev',
81-
SETUP_TESTCPPEXT, 'build_ext', '--verbose']
82-
run_cmd('Build', cmd)
83-
84-
# Install the C++ extension
85-
cmd = [python, '-X', 'dev',
86-
SETUP_TESTCPPEXT, 'install']
87+
'-m', 'pip', 'install', PKG_CPPEXTDATA]
8788
run_cmd('Install', cmd)
8889

8990
# Do a reference run. Until we test that running python

0 commit comments

Comments
 (0)