o
    ¦ôjñ  ã                   @   sŠ   d Z ddlZddlZddlZddlZddlmZ ddlm	Z	 ej
ejejejejejdœZdd„ Zdded	ee d
dfdd„Zdd„ ZdS )z-
Utilities for working with package versions
é    N)ÚOptional)Úversion)ú<z<=ú==z!=z>=ú>c              
   C   sn   |d u s|d u rt d|› d|› d|› d|› d�	ƒ‚t|  t |¡t |¡ƒs5t|› d|› d|› d|› �ƒ‚d S )NzUnable to compare versions for z: need=z found=z). This is unusual. Consider reinstalling Ú.z@ is required for a normal functioning of this module, but found r   )Ú
ValueErrorÚopsr   ÚparseÚImportError)ÚopÚgot_verÚwant_verÚrequirementÚpkgÚhint© r   úl/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/transformers/utils/versions.pyÚ_compare_versions%   s   ÿÿÿÿr   r   r   Úreturnc              	   C   sŽ  |dur	d|› �nd}t  d| ¡r| dd}}}nNt  d| ¡}|s)td| › �ƒ‚|d \}}| d¡}i }|D ]/}	t  d	|	¡}|sItd| › �ƒ‚|d \}}|||< |tvrgt| › d
tt ¡ ƒ› d|› �ƒ‚q8|dkr�d dd„ t	j
dd… D ƒ¡}
| ¡ D ]\}}t||
|| ||ƒ qdS ztj |¡}
W n tjjy¬   tj d| › d|› �¡‚w |durÃ| ¡ D ]\}}t||
|| ||ƒ qµdS dS )a/  
    Perform a runtime check of the dependency versions, using the exact same syntax used by pip.

    The installed module version comes from the *site-packages* dir via *importlib.metadata*.

    Args:
        requirement (`str`): pip style definition, e.g.,  "tokenizers==0.9.4", "tqdm>=4.27", "numpy"
        hint (`str`, *optional*): what suggestion to print in case of requirements not being met

    Example:

    ```python
    require_version("pandas>1.1.2")
    require_version("numpy>1.18.5", "this is important to have for whatever reason")
    ```NÚ
Ú z^[\w_\-\d]+$z^([^!=<>\s]+)([\s!=<>]{1,2}.+)zgrequirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but got r   ú,z^([\s!=<>]{1,2})(.+)z: need one of z
, but got Úpythonr   c                 S   s   g | ]}t |ƒ‘qS r   )Ústr)Ú.0Úxr   r   r   Ú
<listcomp>_   s    z#require_version.<locals>.<listcomp>é   zThe 'zB' distribution was not found and is required by this application. )ÚreÚmatchÚfindallr   Úsplitr	   ÚlistÚkeysÚjoinÚsysÚversion_infoÚitemsr   Ú	importlibÚmetadatar   ÚPackageNotFoundError)r   r   r   r   r   r    Z	want_fullZ
want_rangeÚwantedÚwr   r   r   r   Úrequire_version1   sV   ÿÿ
ÿÿ ÿÿÿþr.   c                 C   s   d}t | |ƒS )zCrequire_version wrapper which emits a core-specific hint on failurez_Try: `pip install transformers -U` or `pip install -e '.[dev]'` if you're working with git main)r.   )r   r   r   r   r   Úrequire_version_corer   s   
r/   )N)Ú__doc__Úimportlib.metadatar)   Úoperatorr   r&   Útypingr   Ú	packagingr   ÚltÚleÚeqÚneÚgeÚgtr	   r   r   r.   r/   r   r   r   r   Ú<module>   s"   ú
A