+
    ‘°³jI'  ã                   óÚ  a € R. t-0 t R t^ RIt^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
HtHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ] ! R
 R4      4       t] ! R R4      4       t]].]R,          3,          tR R ltR R ltR R ltR R ltR R ltR R lt R R lt!R R lt"R R lt#R  R! lt$R" R# lt%R$ R% lt&R& R' lt'R( R) lt(R* R+ lt)]%]&3t*] ^ k ]'](])3t+] ^k R, R- lt,R# )/a¬  Composable search steps for locating NVIDIA libraries.

Each find step is a callable with signature::

    (SearchContext) -> FindResult | None

Find steps locate a library file on disk without loading it.  The
orchestrator in :mod:`load_nvidia_dynamic_lib` handles loading, the
already-loaded check, and dependency resolution.

Step sequences are defined per search strategy so that adding a new
step or strategy only requires adding a function and a tuple entry.

This module is intentionally platform-agnostic: it does not branch on the
current operating system. Platform differences are routed through the
:data:`~cuda.pathfinder._dynamic_libs.search_platform.PLATFORM` instance.
N)ÚCallableÚIterator)Ú	dataclassÚfield)ÚNoReturnÚcast)ÚLibDescriptor)ÚDynamicLibNotFoundError)ÚPLATFORMÚSearchPlatform)Úget_cuda_path_or_home)Únumeric_aware_path_sort_keyc                   ó0   a € ] tR t^'t o RtV 3R ltRtV tR# )Ú
FindResultz0A library file located on disk (not yet loaded).c                ó2   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   # )é   Úabs_pathÚ	found_via©Ústr)ÚformatÚ__classdict__s   "€Úk/home/luca/screen-checking/.venv/lib/python3.14/site-packages/cuda/pathfinder/_dynamic_libs/search_steps.pyÚ__annotate__ÚFindResult.__annotate__'   s   ø‡ ‚ ñ �Mñ	 ñ
 �Nò ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r   '   s   ø‡ € á:÷ ƒ r   r   c                   ó¢   a € ] tR t^/t o Rt]t]! ]R7      t	]! ]R7      t
]V 3R lR l4       t]V 3R lR l4       tV 3R lR ltV 3R	 ltR
tV tR# )ÚSearchContextz4Mutable state accumulated during the search cascade.)Údefault_factoryc                ó    <€ V ^8„  d   QhRS[ /# ©r   Úreturnr   )r   r   s   "€r   r   ÚSearchContext.__annotate__9   s   ø€ ÷ ñ ™ñ r   c                ó.   € V P                   P                  # ©N)ÚdescÚname©Úselfs   &r   ÚlibnameÚSearchContext.libname8   s   € à�y‰y�~‰~Ðr   c                ó    <€ V ^8„  d   QhRS[ /# r*   r   )r   r   s   "€r   r   r,   =   s   ø€ ÷ Dñ D¡#ñ Dr   c                óh   € \        \        V P                  P                  V P                  4      4      # r.   )r   r   ÚplatformÚlib_searched_forr/   r1   s   &r   r8   ÚSearchContext.lib_searched_for<   s"   € ä”C˜Ÿ™×7Ñ7¸¿	¹	ÓBÓCÐCr   c                ó    <€ V ^8„  d   QhRS[ /# r*   )r   )r   r   s   "€r   r   r,   @   s   ø€ ÷ bñ b¡ñ br   c                óª   € R P                  V P                  4      pRP                  V P                  4      p\        RV P                   RV RV 24      h)z, Ú
zFailure finding "z": )ÚjoinÚerror_messagesÚattachmentsr	   r8   )r2   ÚerrÚatts   &  r   Úraise_not_foundÚSearchContext.raise_not_found@   sV   € Ø�i‰i˜×+Ñ+Ó,ˆØ�i‰i˜×(Ñ(Ó)ˆÜ%Ð(9¸$×:OÑ:OÐ9PÐPSÐTWÐSXÐXZÐ[^ÐZ_Ð&`ÓaÐar   c                ój   <€ V ^8„  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   S[S[,          ;R&   # )r   r/   r7   r>   r?   )r   r   Úlistr   )r   r   s   "€r   r   r,   /   sA   ø‡ ‚ ñ Ññ	 ñ
 Ñ'ñ ñ ™•IÑ;ñ ñ ‘c•Ñ8ò r   r   N)r   r   r   r    r!   r
   r7   r   rE   r>   r?   Úpropertyr3   r8   rB   r"   r#   r$   r%   s   @r   r'   r'   /   s^   ø‡ € á>ð  (€HÙ %°dÔ ;€NÙ"°4Ô8€Kà÷ó ðð ÷Dó ðD÷bð b÷# ƒ r   r'   c                ól   € V ^8„  d   QhR\         R\        \         R3,          R\        \         ,          /# )r   ÚrootÚrel_dirs.r+   )r   Útupler   )r   s   "r   r   r   J   s-   € ÷ 0ñ 0œð 0¬¬c°3¨h­ð 0¼HÄS½Mñ 0r   c           	   #  ó6  "  € V FŽ  p\        \        P                  ! \        P                  P	                  W4      4      4       FK  p\        P                  P                  V4      '       g   K*  \        P                  P                  V4      x € KM  	  K�  	  R# 5i)zDYield existing library directories under *root* in descriptor order.N)ÚsortedÚglobÚosÚpathr=   ÚisdirÚnormpath)rH   rI   Úrel_pathÚdirnames   &&  r   Ú_iter_lib_dirsrT   J   s]   é € ãˆÜœdŸiši¬¯©¯©°TÓ(DÓEÖFˆGÜ�w‰w�}‰}˜W×%Ô%Ü—g‘g×&Ñ& wÓ/Ô/ó Gó ùs   ‚A'BÁ.+Bc          	      ó^   € V ^8„  d   QhR\         R\        R\        R\        \        ,          /# )r   r/   r7   Úanchor_pointr+   )r   r   r   r   )r   s   "r   r   r   R   s:   € ÷ Lñ LÜ
ðLäðLô ðLô Œc…]ñ	Lr   c              #  óV   "  € \        W!P                  V 4      4       Rj  x€L
  R#  L5i)zLYield existing library directories under *anchor_point* in descriptor order.N)rT   Úanchor_rel_dirs©r/   r7   rV   s   &&&r   Ú_iter_lib_dirs_using_anchorrZ   R   s    é € ô ˜l×,DÑ,DÀTÓ,JÓK×KÔKùs   ‚) '¡)c          	      óV   € V ^8„  d   QhR\         R\        R\        R\        R,          /# )r   r/   r7   rV   r+   N)r   r   r   )r   s   "r   r   r   [   s6   € ÷ Qñ Q¤]ð Q¼nð QÔ\_ð QÔdgÐjnÕdnñ Qr   c                ó.   € \        \        WV4      R4      # )z6Find the first library directory under *anchor_point*.N)ÚnextrZ   rY   s   &&&r   Ú_find_lib_dir_using_anchorr^   [   s   € äÔ+¨D¸LÓIÈ4ÓPÐPr   c                óX   € V ^8„  d   QhR\         R\        R,          R\        R,          /# )r   ÚctxÚlib_dirNr+   )r'   r   )r   s   "r   r   r   `   s)   € ÷ ñ œ]ð ´S¸4µZð ÄCÈ$ÅJñ r   c           	     ó°   € Vf   R# \        \        R,          V P                  P                  VV P                  V P
                  V P                  4      4      # )z0Find a library file in a resolved lib directory.N)r   r   r7   Úfind_in_lib_dirr/   r>   r?   )r`   ra   s   &&r   Ú_find_using_lib_dirrd   `   sJ   € à‚ÙÜÜˆd�
Ø�‰×$Ñ$ØØ�H‰HØ×ÑØ�O‰Oó		
óð r   c                ó|   € V ^8„  d   QhR\         R\        R\        \        R3,          R\        R\        R,          /# )r   r`   rH   rI   .r   r+   N)r'   r   rJ   r   )r   s   "r   r   r   o   sG   € ÷ ñ Ü	ðä
ðô ”C˜�H�oðô ð	ô
 �$Õñr   c                ób   € \        W4       F  p\        W4      pVf   K  \        WS4      u # 	  R# )zAResolve *rel_dirs* under *root*, then find the requested library.N)rT   rd   r   )r`   rH   rI   r   ra   r   s   &&&&  r   Ú_find_under_rootrg   o   s3   € ô " $Ö1ˆÜ& sÓ4ˆØÔÜ˜hÓ2Ò2ñ 2ñ r   c          	      óV   € V ^8„  d   QhR\         R\        R\        R\        R,          /# )r   r`   rH   r   r+   N©r'   r   r   )r   s   "r   r   r   }   s4   € ÷ Zñ Z¤ð Z´cð ZÄcð ZÌjÐ[_ÕN_ñ Zr   c                ób   € \        WV P                  P                  V P                  4      V4      # )z6Resolve the descriptor's general anchors under *root*.)rg   r7   rX   r/   )r`   rH   r   s   &&&r   Ú_find_under_anchor_rootrk   }   s$   € ä˜C s§|¡|×'CÑ'CÀCÇHÁHÓ'MÈyÓYÐYr   c                ó>   € V ^8„  d   QhR\         R\         R,          /# ©r   Úresolved_lib_pathr+   Nr   )r   s   "r   r   r   ‚   s   € ÷ ñ ¬cð ´c¸Dµjñ r   c                ó–  € \         P                  P                  V 4      p\         P                  P                  V4      pVR9   d„   \         P                  P                  V4      p\         P                  P                  V4      p\         P                  P                  V4      R8X  d    \         P                  P                  V4      # V# R# )zÙDerive CTK root from Linux canary path.

Supports:
- ``$CTK_ROOT/lib64/libfoo.so.*``
- ``$CTK_ROOT/lib/libfoo.so.*``
- ``$CTK_ROOT/targets/<triple>/lib64/libfoo.so.*``
- ``$CTK_ROOT/targets/<triple>/lib/libfoo.so.*``
ÚtargetsN)Úlib64Úlib)rN   rO   rS   Úbasename)rn   ra   rs   ÚparentÚgrandparents   &    r   Ú_derive_ctk_root_linuxrv   ‚   sŠ   € ô �g‰g�o‰oÐ/Ó0€GÜ�w‰w×Ñ Ó(€HØÐ#Ô#Ü—‘—‘ Ó)ˆÜ—g‘g—o‘o fÓ-ˆÜ�7‰7×Ñ˜KÓ(¨IÔ5Ü—7‘7—?‘? ;Ó/Ð/ØˆÙr   c                ó>   € V ^8„  d   QhR\         R\         R,          /# rm   r   )r   s   "r   r   r   –   s   € ÷ ñ ´ð ¼¸d½
ñ r   c                ó>  € ^ RI pVP                  V 4      pVP                  V4      P                  4       pVR9   dJ   VP                  V4      pVP                  V4      P                  4       R8X  d   VP                  V4      #  R# VR8X  d   VP                  V4      # R# )zÏDerive CTK root from Windows canary path.

Supports:
- ``$CTK_ROOT/bin/x64/foo.dll`` (CTK 13 style)
- ``$CTK_ROOT/bin/arm64/foo.dll`` (Windows on Arm CTK 13 style)
- ``$CTK_ROOT/bin/foo.dll`` (CTK 12 style)
NÚbin)Úx64Úarm64)ÚntpathrS   rs   Úlower)rn   r|   ra   rs   rt   s   &    r   Ú_derive_ctk_root_windowsr~   –   s“   € ó à�n‰nÐ.Ó/€GØ�‰˜wÓ'×-Ñ-Ó/€HØÐ#Ô#Ø—‘ Ó(ˆØ�?‰?˜6Ó"×(Ñ(Ó*¨eÔ3Ø—>‘> &Ó)Ð)ð 4ñ ð 
�UÔ	Ø�~‰~˜gÓ&Ð&Ùr   c                ó>   € V ^8„  d   QhR\         R\         R,          /# rm   r   )r   s   "r   r   r   «   s   € ÷ 7ñ 7¤sð 7¬s°T­zñ 7r   c                ó:   € \        V 4      pVe   V# \        V 4      # )z4Derive CTK root from a resolved canary library path.)rv   r~   )rn   Úctk_roots   & r   Úderive_ctk_rootr‚   «   s$   € ä%Ð&7Ó8€HØÒØˆÜ#Ð$5Ó6Ð6r   c                óJ   € V ^8„  d   QhR\         R\        R\        R,          /# )r   r`   r�   r+   Nri   )r   s   "r   r   r   ³   s+   € ÷ Eñ Eœ=ð E´Cð E¼JÈÕ<Mñ Er   c                ó   € \        WR4      # )z3Find a library under a previously derived CTK root.zsystem-ctk-root)rk   )r`   r�   s   &&r   Úfind_via_ctk_rootr…   ³   s   € ä" 3Ð2CÓDÐDr   c                ó>   € V ^8„  d   QhR\         R\        R,          /# ©r   r`   r+   N©r'   r   )r   s   "r   r   r   ½   s   € ÷ ñ œ}ð ´¸dÕ1Bñ r   c                óü   € V P                   P                  V P                  4      pV'       g   R# V P                   P                  VV P                  V P                  V P
                  4      pVe   \        VR4      # R# )z#Search pip wheel install locations.Nzsite-packages)r7   Úsite_packages_rel_dirsr/   Úfind_in_site_packagesr>   r?   r   )r`   rI   r   s   &  r   r‹   r‹   ½   sf   € à�|‰|×2Ñ2°3·8±8Ó<€HßÙØ�|‰|×1Ñ1ØØ�‰Ø×ÑØ�‰ó	€Hð ÒÜ˜( OÓ4Ð4Ùr   c                ó>   € V ^8„  d   QhR\         R\        R,          /# r‡   rˆ   )r   s   "r   r   r   Í   s   € ÷ 9ñ 9”}ð 9¬°dÕ):ñ 9r   c                ó¢   € \         P                  P                  R4      pV'       g   R# V P                  P	                  V4      p\        WR4      # )zSearch ``$CONDA_PREFIX``.ÚCONDA_PREFIXNÚconda)rN   ÚenvironÚgetr7   Úconda_anchor_pointrk   )r`   Úconda_prefixÚanchors   &  r   Úfind_in_condar•   Í   s;   € ä—:‘:—>‘> .Ó1€LßÙØ�\‰\×,Ñ,¨\Ó:€FÜ" 3°Ó8Ð8r   c                ó>   € V ^8„  d   QhR\         R\        R,          /# r‡   rˆ   )r   s   "r   r   r   Ö   s   € ÷ 
ñ 
¤}ð 
¼ÀdÕ9Jñ 
r   c                ó"  € V P                   P                  V P                  4      pV P                   P                  V P                  4       F@  p\        P
                  P                  V4      pV'       g   K,  \        WW4      pVf   K>  Vu # 	  R# )zMSearch installation roots named by descriptor-specific environment variables.N)r7   Úinstall_root_env_rel_dirsr/   Úinstall_root_env_varsrN   r�   r‘   rg   )r`   rI   Úenv_varrH   Úresults   &    r   Úfind_in_install_root_env_varsrœ   Ö   sl   € à�|‰|×5Ñ5°c·h±hÓ?€HØ—<‘<×5Ñ5°c·h±hÖ?ˆÜ�z‰z�~‰~˜gÓ&ˆßÙÜ! #¨XÓ?ˆØÔØŠMñ @ñ r   c                ó>   € V ^8„  d   QhR\         R\        R,          /# r‡   rˆ   )r   s   "r   r   r   ã   s#   € ÷ @ñ @œ=ð @¬Z¸$Õ->ñ @r   c                ó:   € \        4       pVf   R# \        WR4      # )aÙ  Search ``$CUDA_PATH`` / ``$CUDA_HOME``.

On Windows, this is the normal fallback for system-installed CTK DLLs when
they are not already discoverable via the native ``LoadLibraryExW(..., 0)``
path used by :func:`cuda.pathfinder._dynamic_libs.load_dl_windows.load_with_system_search`.
Python 3.8+ does not include ``PATH`` in that native DLL search.

The returned ``found_via`` is always ``"CUDA_PATH"`` regardless of which
environment variable actually provided the value.
NÚ	CUDA_PATH)r   rk   )r`   Ú	cuda_homes   & r   Úfind_in_cuda_pathr¡   ã   s"   € ô &Ó'€IØÒÙÜ" 3°;Ó?Ð?r   c                ó>   € V ^8„  d   QhR\         R\        R,          /# r‡   rˆ   )r   s   "r   r   r   ô   s   € ÷ 	ñ 	¤]ð 	´zÀDÕ7Hñ 	r   c                ón  € V P                   P                  V P                  4       F‹  p\        \        P                  ! V4      \
        RR7       F^  p\        P                  P                  V4      '       g   K*  \        V \        P                  P                  V4      R4      pVf   KZ  Vu u # 	  K�  	  R# )zDSearch descriptor-configured installation roots under Program Files.T)ÚkeyÚreverseÚProgramFilesN)r7   Úprogram_files_root_globsr/   rL   rM   r   rN   rO   rP   rk   rQ   )r`   Ú	root_globrH   r›   s   &   r   Úfind_in_program_files_rootsr©   ô   s‚   € à—\‘\×:Ñ:¸3¿8¹8ÖDˆ	Üœ4Ÿ9š9 YÓ/Ô5PÐZ^×_ˆDÜ—7‘7—=‘= ×&Ò&ÙÜ,¨S´"·'±'×2BÑ2BÀ4Ó2HÈ.ÓYˆFØÔ!Ø”ó `ñ Eñ r   c                ód   € V ^8„  d   QhR\         R\        \        R3,          R\        R,          /# )r   r`   Ústeps.r+   N)r'   rJ   ÚFindStepr   )r   s   "r   r   r     s0   € ÷ ñ œð ¬e´H¸c°MÕ.Bð ÄzÐTXÕGXñ r   c                ó8   € V F  pV! V 4      pVf   K  Vu # 	  R# )z1Run find steps in order, returning the first hit.Nr   )r`   r«   Ústepr›   s   &&  r   Úrun_find_stepsr¯     s%   € ãˆÙ�c“ˆØÔØŠMñ ñ r   c                óœ   € V ^8„  d   Qh/ ^ \         9   d   \        \        R3,          ;R&   ^\         9   d   \        \        R3,          ;R&   # )r   .ÚEARLY_FIND_STEPSÚLATE_FIND_STEPS)Ú__conditional_annotations__rJ   r¬   )r   s   "r   r   r      sK   € ÷ ñ ÷B PÒ O”%œ #˜Õ&Ñ OñC÷Hò ””x �}Õ%ñ òIr   ).r³   r!   rM   rN   Úcollections.abcr   r   Údataclassesr   r   Útypingr   r   Ú,cuda.pathfinder._dynamic_libs.lib_descriptorr   Ú,cuda.pathfinder._dynamic_libs.load_dl_commonr	   Ú-cuda.pathfinder._dynamic_libs.search_platformr
   r   Úcuda.pathfinder._utils.env_varsr   Ú cuda.pathfinder._utils.path_sortr   r   r'   r¬   rT   rZ   r^   rd   rg   rk   rv   r~   r‚   r…   r‹   r•   rœ   r¡   r©   r±   r²   r¯   r   )r³   s   @r   Ú<module>r¼      sõ   øðöó$ Û 	ß .ß (ß !å FÝ Pß RÝ AÝ Hð ÷ð ó ðð ÷bð bó ðbð. �]�O Z°$Õ%6Ð6Õ7€õ0õLõQõ
õõZõ
õ(õ*7õEõõ 9õ
õ@õ"	ð" +@ÀÐ)OÐ Ó Oð "ØØð)€ó ÷r   