1010import pytest
1111
1212from cuda .pathfinder import UnsupportedWindowsArchError
13+ from cuda .pathfinder ._dynamic_libs import search_platform as search_platform_mod
1314from cuda .pathfinder ._dynamic_libs .descriptor_catalog import WindowsSearchDir , WindowsSearchDirs
1415from cuda .pathfinder ._dynamic_libs .lib_descriptor import LIB_DESCRIPTORS , LibDescriptor
1516from cuda .pathfinder ._dynamic_libs .load_dl_common import DynamicLibNotFoundError
@@ -78,7 +79,7 @@ def test_lib_searched_for_linux(self):
7879 assert ctx .lib_searched_for == "libcublas.so"
7980
8081 def test_lib_searched_for_windows (self ):
81- ctx = SearchContext (_make_desc (name = "cublas" ), platform = WindowsSearchPlatform ())
82+ ctx = SearchContext (_make_desc (name = "cublas" ), platform = WindowsSearchPlatform (target_arch = "x64" ))
8283 assert ctx .lib_searched_for == "cublas*.dll"
8384
8485 def test_raise_not_found_includes_messages (self ):
@@ -100,6 +101,16 @@ def test_raise_not_found_empty_messages(self):
100101
101102
102103class TestWindowsPythonArch :
104+ @pytest .mark .agent_authored (model = "gpt-5" )
105+ def test_linux_platform_does_not_detect_windows_arch (self , mocker ):
106+ mocker .patch .object (search_platform_mod , "IS_WINDOWS" , False )
107+ get_windows_arch = mocker .patch .object (search_platform_mod , "windows_python_arch" )
108+
109+ platform = search_platform_mod ._platform_for_current_system ()
110+
111+ assert isinstance (platform , LinuxSearchPlatform )
112+ get_windows_arch .assert_not_called ()
113+
103114 def test_detects_sysconfig_x64 (self , mocker ):
104115 mocker .patch .object (windows_arch_mod .sysconfig , "get_platform" , return_value = "win-amd64" )
105116
@@ -167,7 +178,7 @@ def test_found_windows(self, mocker, tmp_path):
167178 name = "cudart" ,
168179 site_packages_windows = WindowsSearchDirs .common (os .path .join ("nvidia" , "cuda_runtime" , "bin" )),
169180 )
170- result = find_in_site_packages (_ctx (desc , platform = WindowsSearchPlatform ()))
181+ result = find_in_site_packages (_ctx (desc , platform = WindowsSearchPlatform (target_arch = "x64" )))
171182 assert result is not None
172183 assert result .abs_path == str (dll )
173184 assert result .found_via == "site-packages"
@@ -338,7 +349,7 @@ def test_found_windows(self, mocker, tmp_path):
338349
339350 mocker .patch .dict (os .environ , {"CONDA_PREFIX" : str (tmp_path )})
340351
341- result = find_in_conda (_ctx (platform = WindowsSearchPlatform ()))
352+ result = find_in_conda (_ctx (platform = WindowsSearchPlatform (target_arch = "x64" )))
342353 assert result is not None
343354 assert result .abs_path == str (dll )
344355 assert result .found_via == "conda"
@@ -439,7 +450,7 @@ def test_found_windows(self, mocker, tmp_path):
439450
440451 mocker .patch (f"{ _STEPS_MOD } .get_cuda_path_or_home" , return_value = str (tmp_path ))
441452
442- result = find_in_cuda_path (_ctx (platform = WindowsSearchPlatform ()))
453+ result = find_in_cuda_path (_ctx (platform = WindowsSearchPlatform (target_arch = "x64" )))
443454 assert result is not None
444455 assert result .abs_path == str (dll )
445456 assert result .found_via == "CUDA_PATH"
@@ -575,7 +586,7 @@ def test_find_lib_dir_uses_descriptor_windows(self, tmp_path):
575586 )
576587 ),
577588 )
578- result = _find_lib_dir_using_anchor (desc , WindowsSearchPlatform (), str (tmp_path ))
589+ result = _find_lib_dir_using_anchor (desc , WindowsSearchPlatform (target_arch = "x64" ), str (tmp_path ))
579590 assert result is not None
580591 assert result .endswith (os .path .join ("nvvm" , "bin" ))
581592
0 commit comments