@@ -211,3 +211,36 @@ def test_compiler(venv, package_detect_compiler, tmp_path):
211211 venv .pip ('install' , os .fspath (tmp_path / wheel ))
212212 compiler = venv .python ('-c' , 'import detect_compiler; print(detect_compiler.compiler())' ).strip ()
213213 assert compiler == 'msvc'
214+
215+
216+ @pytest .mark .skipif (sys .platform != 'darwin' , reason = 'macOS specific test' )
217+ @pytest .mark .parametrize ('archflags' , [
218+ '-arch x86_64' ,
219+ '-arch arm64' ,
220+ '-arch arm64 -arch arm64' ,
221+ ])
222+ def test_archflags_envvar_parsing (package_purelib_and_platlib , monkeypatch , archflags ):
223+ try :
224+ monkeypatch .setenv ('ARCHFLAGS' , archflags )
225+ arch = archflags .split ()[- 1 ]
226+ with mesonpy ._project ():
227+ assert mesonpy ._tags .Tag ().platform .endswith (arch )
228+ finally :
229+ # revert environment variable setting done by the in-process build
230+ os .environ .pop ('_PYTHON_HOST_PLATFORM' , None )
231+
232+
233+ @pytest .mark .skipif (sys .platform != 'darwin' , reason = 'macOS specific test' )
234+ @pytest .mark .parametrize ('archflags' , [
235+ '-arch arm64 -arch x86_64' ,
236+ '-arch arm64 -DFOO=1' ,
237+ ])
238+ def test_archflags_envvar_parsing_invalid (package_purelib_and_platlib , monkeypatch , archflags ):
239+ try :
240+ monkeypatch .setenv ('ARCHFLAGS' , archflags )
241+ with pytest .raises (mesonpy .ConfigError ):
242+ with mesonpy ._project ():
243+ pass
244+ finally :
245+ # revert environment variable setting done by the in-process build
246+ os .environ .pop ('_PYTHON_HOST_PLATFORM' , None )
0 commit comments