@@ -82,24 +82,26 @@ def test_cpp17_modern_msvc_workaround(tmp_path):
82
82
# Use existing setuptools code to run Visual Studio's vcvarsall.bat and get the
83
83
# necessary environment variables, since running vcvarsall.bat in a subprocess
84
84
# does not keep the relevant environment variables
85
- # In normal CI setup: run vcvarsall.bat before running cibuildwheel
85
+ # There are different environment variables for 32-bit/64-bit targets, so we
86
+ # need to run cibuildwheel twice, once for 32-bit with `vcvarsall.bat x86, and
87
+ # once for 64-bit with `vcvarsall.bat x64`
88
+ # In a normal CI setup, just run vcvarsall.bat before running cibuildwheel and set
89
+ # DISTUTILS_USE_SDK and MSSdk
86
90
import setuptools
87
91
88
- # Different environment variables for 32-bit/64-bit targets
89
- # First, 32-bit (or x86)
90
- vcvarsall_env = setuptools .msvc .msvc14_get_vc_env ('x86' )
91
- add_env_x86 = add_env .copy ()
92
+ def add_vcvars (prev_env , platform ):
93
+ vcvarsall_env = setuptools .msvc .msvc14_get_vc_env (platform )
94
+ env = prev_env .copy ()
95
+ for vcvar in ['path' , 'include' , 'lib' ]:
96
+ env [vcvar ] = vcvarsall_env [vcvar ]
97
+ return env
98
+
99
+ add_env_x86 = add_vcvars (add_env , 'x86' )
92
100
add_env_x86 ['CIBW_BUILD' ] = '*-win32'
93
- for vc_var in ['path' , 'include' , 'lib' ]:
94
- add_env_x86 [vc_var ] = vcvarsall_env [vc_var ]
95
101
actual_wheels = utils .cibuildwheel_run (project_dir , add_env = add_env_x86 )
96
102
97
- # Then, 64-bit (or x64)
98
- vcvarsall_env = setuptools .msvc .msvc14_get_vc_env ('x64' )
99
- add_env_x64 = add_env .copy ()
103
+ add_env_x64 = add_vcvars (add_env , 'x64' )
100
104
add_env_x64 ['CIBW_BUILD' ] = '*-win_amd64'
101
- for vc_var in ['path' , 'include' , 'lib' ]:
102
- add_env_x64 [vc_var ] = vcvarsall_env [vc_var ]
103
105
actual_wheels += utils .cibuildwheel_run (project_dir , add_env = add_env_x64 )
104
106
105
107
expected_wheels = utils .expected_wheels ('spam' , '0.1.0' )
0 commit comments