1313import glob
1414import os
1515from collections .abc import Sequence
16- from dataclasses import dataclass
16+ from dataclasses import dataclass , field
17+ from pathlib import PurePath
1718from typing import Protocol , cast
1819
1920from cuda .pathfinder ._dynamic_libs .lib_descriptor import LibDescriptor
2021from cuda .pathfinder ._dynamic_libs .supported_nvidia_libs import is_suppressed_dll_file
2122from cuda .pathfinder ._utils .find_sub_dirs import find_sub_dirs_all_sitepackages
2223from cuda .pathfinder ._utils .platform_aware import IS_WINDOWS
24+ from cuda .pathfinder ._utils .windows_arch import windows_python_arch
2325
2426
2527def _no_such_file_in_sub_dirs (
@@ -41,7 +43,7 @@ def _find_so_in_rel_dirs(
4143 sub_dirs_searched : list [tuple [str , ...]] = []
4244 file_wild = so_basename + "*"
4345 for rel_dir in rel_dirs :
44- sub_dir = tuple (rel_dir . split ( os . path . sep ))
46+ sub_dir = PurePath (rel_dir ). parts
4547 for abs_dir in find_sub_dirs_all_sitepackages (sub_dir ):
4648 # Exact unversioned match first; fall back to versioned names because some
4749 # distros only ship lib<name>.so.<major> (e.g. conda libcupti). Only one match
@@ -78,7 +80,7 @@ def _find_dll_in_rel_dirs(
7880) -> str | None :
7981 sub_dirs_searched : list [tuple [str , ...]] = []
8082 for rel_dir in rel_dirs :
81- sub_dir = tuple (rel_dir . split ( os . path . sep ))
83+ sub_dir = PurePath (rel_dir ). parts
8284 for abs_dir in find_sub_dirs_all_sitepackages (sub_dir ):
8385 dll_name = _find_dll_under_dir (abs_dir , lib_searched_for )
8486 if dll_name is not None :
@@ -173,17 +175,19 @@ def find_in_lib_dir(
173175
174176@dataclass (frozen = True , slots = True )
175177class WindowsSearchPlatform :
178+ target_arch : str = field (default_factory = windows_python_arch )
179+
176180 def lib_searched_for (self , libname : str ) -> str :
177181 return f"{ libname } *.dll"
178182
179183 def site_packages_rel_dirs (self , desc : LibDescriptor ) -> tuple [str , ...]:
180- return cast ( tuple [ str , ...], desc .site_packages_windows )
184+ return desc .site_packages_windows . for_arch ( self . target_arch )
181185
182186 def conda_anchor_point (self , conda_prefix : str ) -> str :
183187 return os .path .join (conda_prefix , "Library" )
184188
185189 def anchor_rel_dirs (self , desc : LibDescriptor ) -> tuple [str , ...]:
186- return cast ( tuple [ str , ...], desc .anchor_rel_dirs_windows )
190+ return desc .anchor_rel_dirs_windows . for_arch ( self . target_arch )
187191
188192 def find_in_site_packages (
189193 self ,
0 commit comments