Skip to content

Commit 5fea0d7

Browse files
committed
Add test to build wheels on Windows for C++17, setting DISTUTILS_USE_SDK and MSSdk to not use vcpython27 or MSVC 10
1 parent 2e4a29b commit 5fea0d7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/10_cpp_standards/cibuildwheel_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,32 @@ def test_cpp17():
5959
and 'pp36-pypy36_pp73-win32' not in w]
6060

6161
assert set(actual_wheels) == set(expected_wheels)
62+
63+
64+
def test_cpp17_modern_msvc_workaround(tmp_path):
65+
# This test checks the workaround for modern C++ versions, using a modern compiler
66+
67+
if utils.platform != 'windows':
68+
pytest.skip('the test is only relevant to the Windows build')
69+
70+
if os.environ.get('APPVEYOR_BUILD_WORKER_IMAGE', '') == 'Visual Studio 2015':
71+
pytest.skip('Visual Studio 2015 does not support C++17')
72+
73+
# VC++ for Python 2.7 and MSVC 10 do not support modern standards
74+
# This is a workaround which forces distutils/setupstools to a newer version
75+
# Wheels compiled need a more modern C++ redistributable installed, which is not
76+
# included with Python: see documentation for more info
77+
# DISTUTILS_USE_SDK and MSSdk=1 tell distutils/setuptools that we are adding
78+
# MSVC's compiler, tools, and libraries to PATH ourselves
79+
add_env = {'CIBW_ENVIRONMENT': 'STANDARD=17',
80+
'DISTUTILS_USE_SDK': 1, 'MSSdk': 1}
81+
82+
# Use existing distutils code to run Visual Studio's vcvarsall.bat
83+
import distutils.msvc9compiler
84+
vcvarsall_env = distutils.msvc9compiler.query_vcvarsall(14)
85+
add_env.update(vcvarsall_env)
86+
87+
actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env)
88+
expected_wheels = utils.expected_wheels('spam', '0.1.0')
89+
90+
assert set(actual_wheels) == set(expected_wheels)

0 commit comments

Comments
 (0)