o
    ڷi                     @  sj   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Zdd
dZdddZ	dddZ
dddZdS )    )annotationsNc                   @  s   e Zd ZdS )RuffNotFoundN)__name__
__module____qualname__ r   r   E/home/ubuntu/vllm_env/lib/python3.10/site-packages/ruff/_find_ruff.pyr      s    r   returnstrc                  C  s   dt d } t dt jddtjidtjdkr"ttt ddnttt d	d
ttt dd
t jdt	 dg}g }|D ] }|sDq?||v rIq?|
| tj|| }tj|r_|  S q?ddd |D }td| d)zReturn the ruff binary path.ruffEXEscriptsbase)varswin32zLib/site-packages/ruffScriptszlib/python*/site-packages/ruffbin)scheme
c                 s  s    | ]}d | V  qdS )z - Nr   ).0targetr   r   r   	<genexpr>4   s    z find_ruff_bin.<locals>.<genexpr>zBCould not find the ruff binary in any of the following locations:
)	sysconfigget_config_varget_pathsysbase_prefixplatform_join_matching_parents_module_path_user_schemeappendospathjoinisfiler   )ruff_exetargetsseenr   r$   	locationsr   r   r   find_ruff_bin   s:   



r+   
str | Nonec                  C  s   t jt} | S N)r#   r$   dirname__file__)r$   r   r   r   r    :   s   r    r$   matchc                   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 s3d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   part
match_partr1   r   r   r   P   s
    
z$_matching_parents.<locals>.<genexpr>)	r2   splitr#   seplenallzipreversedr%   )r$   r0   partsmatch_partsr   r1   r   r   ?   s   
r   r<   c                 G  s   | sd S t jj| g|R  S r-   )r#   r$   r%   )r$   r<   r   r   r   r   Y   s   r   c                  C  sJ   t jdkrtd} | S tjdkrd} | S t jdkr!t jr!d} | S d} | S )N)   
   userntnt_userdarwinosx_framework_user
posix_user)r   version_infor   get_preferred_schemer#   namer   
_framework)user_schemer   r   r   r!   _   s   


r!   )r	   r
   )r	   r,   )r$   r,   r0   r
   r	   r,   )r$   r,   r<   r
   r	   r,   )
__future__r   r#   r   r   FileNotFoundErrorr   r+   r    r   r   r!   r   r   r   r   <module>   s    

/

