Ë
    èÿæi+  ã                   óØ   — d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	  edddg«      Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)é    N)Ú
namedtuple©ÚIS_WIN32)Úfind_libÚ	find_fileÚ_env_path_tupleÚbyÚinfoc                 ó(   — | D ]  \  }}|€Œ	||fc S  y)z»Find valid path from *options*, which is a list of 2-tuple of
    (name, path).  Return first pair where *path* is not None.
    If no valid path is found, return ('<unknown>', None)
    )z	<unknown>N© )Úoptionsr	   Údatas      új/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/numba/cuda/cuda_paths.pyÚ_find_valid_pathr      s&   € ó
 ‰ˆˆDØÑØ�t�8ŠOð ð !ó    c                  ó    — dt        «       fdt        «       fdt        dd«      fdt        dd«      fdt	        «       fg} t        | «      \  }}||fS )NúConda environmentú"Conda environment (NVIDIA package)Ú	CUDA_HOMEÚnvvmÚ	libdeviceÚSystemzDebian package)Úget_conda_ctkÚget_nvidia_libdevice_ctkÚget_cuda_homeÚget_system_ctkÚget_debian_pkg_libdevicer   ©r   r	   Úlibdirs      r   Ú_get_libdevice_path_decisionr       sc   € à	œm›oÐ.Ø	-Ô/GÓ/IÐJØ	”m F¨KÓ8Ð9Ø	”> &¨+Ó6Ð7Ø	Ô3Ó5Ð6ð€Gô " 'Ó*�J€BˆØˆvˆ:Ðr   c                  ó   — t         ryy)N)r   Úbin)r   Úlib64r   r   r   r   Ú_nvvm_lib_dirr$   %   s   € ÝØàr   c                  óš   — dt        «       fdt        «       fdt        t        «       Ž fdt	        t        «       Ž fg} t        | «      \  }}||fS ©Nr   r   r   r   )r   Úget_nvidia_nvvm_ctkr   r$   r   r   )r   r	   Úpaths      r   Ú_get_nvvm_path_decisionr)   ,   sV   € à	œm›oÐ.Ø	-Ô/BÓ/DÐEØ	”m¤]£_Ð5Ð6Ø	”>¤=£?Ð3Ð4ð	€Gô   Ó(�H€BˆØˆtˆ8€Or   c                  ó�   — t        «       \  } }d}t        t        j                  |«      |«      }t	        |d ¬«      }t        | |«      S )Nzlibdevice(\.\d+)*\.bc$)Údefault)r    r   ÚreÚcompileÚmaxr   )r	   r   ÚpatÚ
candidatesÚouts        r   Ú_get_libdevice_pathsr2   7   s@   € Ü-Ó/�J€Bˆà
#€CÜœ2Ÿ:™: c›?¨FÓ3€Jä
ˆj $Ô
'€CÜ˜2˜sÓ#Ð#r   c                  ó   — t         ryy)Nr"   r#   r   r   r   r   Ú_cudalib_pathr4   A   s   € ÝØàr   c                  ó   — t         ryy)N)ÚlibÚx64)r#   r   r   r   r   Ú_cuda_home_static_cudalib_pathr8   H   s   € ÝØàr   c                  ó¦   — dt        «       fdt        «       fdt        t        «       «      fdt	        t        «       «      fg} t        | «      \  }}||fS r&   )r   Úget_nvidia_cudalib_ctkr   r4   r   r   r   s      r   Ú_get_cudalib_dir_path_decisionr;   O   sW   € à	œm›oÐ.Ø	-Ô/EÓ/GÐHØ	”m¤M£OÓ4Ð5Ø	”>¤-£/Ó2Ð3ð	€Gô " 'Ó*�J€BˆØˆvˆ:Ðr   c                  ó    — dt        «       fdt        «       fdt        t        «       Ž fdt	        t        «       «      fg} t        | «      \  }}||fS r&   )r   Úget_nvidia_static_cudalib_ctkr   r8   r   r4   r   r   s      r   Ú%_get_static_cudalib_dir_path_decisionr>   Z   sY   € à	œm›oÐ.Ø	-Ô/LÓ/NÐOØ	”mÔ%CÓ%EÐFÐGØ	”>¤-£/Ó2Ð3ð	€Gô " 'Ó*�J€BˆØˆvˆ:Ðr   c                  ó4   — t        «       \  } }t        | |«      S ©N)r;   r   ©r	   r   s     r   Ú_get_cudalib_dirrB   e   s   € Ü/Ó1�J€BˆÜ˜2˜vÓ&Ð&r   c                  ó4   — t        «       \  } }t        | |«      S r@   )r>   r   rA   s     r   Ú_get_static_cudalib_dirrD   j   s   € Ü6Ó8�J€BˆÜ˜2˜vÓ&Ð&r   c                  óÆ   — t         j                  j                  d«      rBd}t        j                  j                  |«      r t        j                  j                  |g| ¢­Ž S yy)zJReturn path to system-wide cudatoolkit; or, None if it doesn't exist.
    Úlinuxz/usr/local/cudaN)ÚsysÚplatformÚ
startswithÚosr(   ÚexistsÚjoin)ÚsubdirsÚbases     r   r   r   o   sO   € ô ‡|�|×Ñ˜wÔ'ð !ˆÜ�7‰7�>‰>˜$ÔÜ—7‘7—<‘< Ð/ wÒ/Ð/ð  ð	 (r   c                  ó
  — t         j                  j                  t         j                  j                  t        j
                  d«      «      } | syt        d«      }|syt         j                  j                  t        |«      «      S )úMReturn path to directory containing the shared libraries of cudatoolkit.
    ú
conda-metaNr   )	rJ   r(   rK   rL   rG   Úprefixr   Údirnamer.   )Úis_conda_envÚpathss     r   r   r   {   sV   € ô —7‘7—>‘>¤"§'¡'§,¡,¬s¯z©z¸<Ó"HÓI€LÙØä�VÓ€EÙØä�7‰7�?‰?œ3˜u›:Ó&Ð&r   c                  óæ  — t         j                  j                  t         j                  j                  t        j
                  d«      «      } | syt         j                  j                  t        j
                  dt        «       «      }t         j                  j                  |«      rt         j                  j                  |«      swt         j                  j                  t        j
                  ddt        «       «      }t         j                  j                  |«      rt         j                  j                  |«      syt        d|¬«      }|syt         j                  j                  t        |«      «      S )zAReturn path to directory containing the NVVM shared library.
    rQ   Nr   ÚLibrary)r   )rJ   r(   rK   rL   rG   rR   r4   Úisdirr   rS   r.   )rT   r   rU   s      r   r'   r'   ‰   s×   € ô —7‘7—>‘>¤"§'¡'§,¡,¬s¯z©z¸<Ó"HÓI€LÙØô �W‰W�\‰\œ#Ÿ*™* f¬m«oÓ>€FÜ�7‰7�>‰>˜&Ô!¬¯©¯©°vÔ)>ä—‘—‘œcŸj™j¨)°V¼]»_ÓMˆÜ�w‰w�~‰~˜fÔ%¬R¯W©W¯]©]¸6Ô-Bð ä�V FÔ+€EÙØä�7‰7�?‰?œ3˜u›:Ó&Ð&r   c                  óš   — t        «       } | syt        j                  j                  | «      }t        j                  j	                  |d«      S )z?Return path to directory containing the libdevice library.
    Nr   )r'   rJ   r(   rS   rL   )Únvvm_ctkÚnvvm_dirs     r   r   r   ¤   s9   € ô #Ó$€HÙØÜ�w‰w�‰˜xÓ(€HÜ�7‰7�<‰<˜ +Ó.Ð.r   c                  óè   — t        «       } | syt        j                  j                  t        j                  j                  | «      «      }t        rdnd}t        j                  j                  ||«      S )rP   Nr"   r6   )r'   rJ   r(   rS   r   rL   )rZ   Úenv_dirÚsubdirs      r   r:   r:   ®   sO   € ô #Ó$€HÙØÜ�g‰g�o‰oœbŸg™gŸo™o¨hÓ7Ó8€GÝ‰U E€FÜ�7‰7�<‰<˜ Ó(Ð(r   c                  óò   — t        «       } | syt        rd| vrd}nd}t        j                  j	                  t        j                  j	                  | «      «      }t        j                  j
                  |g|¢­Ž S )zMReturn path to directory containing the static libraries of cudatoolkit.
    NrW   )ÚLibr7   )r6   )r'   r   rJ   r(   rS   rL   )rZ   Údirsr]   s      r   r=   r=   ¹   s_   € ô #Ó$€HÙØå�Y hÑ.à‰ð ˆä�g‰g�o‰oœbŸg™gŸo™o¨hÓ7Ó8€GÜ�7‰7�<‰<˜Ð' $Ò'Ð'r   c                  óÈ   — t         j                  j                  d«      }|€t         j                  j                  d«      }|� t        j                  j                  |g| ¢­Ž S y)zqGet paths of CUDA_HOME.
    If *subdirs* are the subdirectory name to be appended in the resulting
    path.
    r   NÚ	CUDA_PATH)rJ   ÚenvironÚgetr(   rL   )rM   Ú	cuda_homes     r   r   r   Ë   sQ   € ô
 —
‘
—‘˜{Ó+€IØÐä—J‘J—N‘N ;Ó/ˆ	ØÐÜ�w‰w�|‰|˜IÐ0¨Ò0Ð0ð r   c                  ój   — t        «       \  } }t        d|«      }|rt        |«      nd }t        | |«      S )Nr   )r)   r   r.   r   )r	   r(   r0   s      r   Ú_get_nvvm_pathrh   Ø   s4   € Ü&Ó(�H€BˆÜ˜& $Ó'€JÙ(Œ3ˆzŒ?¨d€DÜ˜2˜tÓ$Ð$r   c                  óª   — t        t        d«      rt        j                  S t        «       t	        «       t        «       t        «       dœ} | t        _        | S )a@  Returns a dictionary mapping component names to a 2-tuple
    of (source_variable, info).

    The returned dictionary will have the following keys and infos:
    - "nvvm": file_path
    - "libdevice": List[Tuple[arch, file_path]]
    - "cudalib_dir": directory_path

    Note: The result of the function is cached.
    Ú_cached_result)r   r   Úcudalib_dirÚstatic_cudalib_dir)ÚhasattrÚget_cuda_pathsrj   rh   r2   rB   rD   )Úds    r   rn   rn   ß   sK   € ô Œ~Ð/Ô0Ü×,Ñ,Ð,ô #Ó$Ü-Ó/Ü+Ó-Ü"9Ó";ñ	
ˆð )*ŒÔ%Øˆr   c                  óJ   — d} t         j                  j                  | «      sy| S )z]
    Return the Debian NVIDIA Maintainers-packaged libdevice location, if it
    exists.
    z&/usr/lib/nvidia-cuda-toolkit/libdeviceN)rJ   r(   rK   )Úpkg_libdevice_locations    r   r   r   ú   s%   € ð
 FÐÜ�7‰7�>‰>Ð0Ô1ØØ!Ð!r   ) rG   r,   rJ   Úcollectionsr   Únumba.core.configr   Únumba.misc.findlibr   r   r   r   r    r$   r)   r2   r4   r8   r;   r>   rB   rD   r   r   r'   r   r:   r=   r   rh   rn   r   r   r   r   Ú<module>ru      s“   ðÛ 
Û 	Û 	Ý "å &ß 2ñ Ð.°°v°Ó?€ò	!ò	òòò$òòòòò'ò
'ò
	0ò'ò'ò6/ò)ò(ò$
1ò%òó6"r   