a
    ?RhC                     @  s   d dl mZ d dlZd dlZd dlZG dd deZddddZd	dd
dZd	dd	dddZ	d	dd	dddZ
ddddZdS )    )annotationsNc                   @  s   e Zd ZdS )
UvNotFoundN)__name__
__module____qualname__ r   r   A/opt/python-3.9.24/usr/lib/python3.9/site-packages/uv/_find_uv.pyr          r   str)returnc                  C  s   dt d } t dt jddtjidtjdkrDttt ddnttt d	d
ttt dd
t jdt	 dg}g }|D ]@}|sq~||v rq~|
| tj|| }tj|r~|  S q~ddd |D }td| ddS )zReturn the uv binary path.ZuvEXEscriptsbase)varswin32zLib/site-packages/uvScriptszlib/python*/site-packages/uvbin)scheme
c                 s  s   | ]}d | V  qdS )z - Nr   ).0targetr   r   r   	<genexpr>1   r	   zfind_uv_bin.<locals>.<genexpr>z@Could not find the uv binary in any of the following locations:
N)	sysconfigget_config_varget_pathsysbase_prefixplatform_join_matching_parents_module_path_user_schemeappendospathjoinisfiler   )Zuv_exetargetsseenr   r$   	locationsr   r   r   find_uv_bin   s2    


r*   z
str | Nonec                  C  s   t jt} | S N)r#   r$   dirname__file__)r$   r   r   r   r    7   s    r    )r$   matchr   c                   s   ddl m   | sdS | tj}|d}t|t|k r>dS t fddtt|t|D sfdS tj|dt|  S )aW  
    Return the parent directory of `path` after trimming a `match` from the end.
    The match is expected to contain `/` as a path separator, while the `path`
    is expected to use the platform's path separator (e.g., `os.sep`). The path
    components are compared case-insensitively and a `*` wildcard can be used
    in the `match`.
    r   fnmatchN/c                 3  s   | ]\}} ||V  qd S r+   r   )r   partZ
match_partr/   r   r   r   M   s   z$_matching_parents.<locals>.<genexpr>)	r0   splitr#   seplenallzipreversedr%   )r$   r.   partsZmatch_partsr   r/   r   r   <   s    
r   )r$   r9   r   c                 G  s   | sd S t jj| g|R  S r+   )r#   r$   r%   )r$   r9   r   r   r   r   V   s    r   c                  C  sD   t jdkrtd} n*tjdkr&d} nt jdkr<t jr<d} nd} | S )N)   
   userntnt_userdarwinosx_framework_user
posix_user)r   version_infor   Zget_preferred_schemer#   namer   
_framework)Zuser_schemer   r   r   r!   \   s    

r!   )
__future__r   r#   r   r   FileNotFoundErrorr   r*   r    r   r   r!   r   r   r   r   <module>   s   ,