o
    ^i                     @   sF   d dl Z d dlmZ dd Zdd ZdddZdd	d
ZdddZdS )    N)versionc                 C   s   z?|dkrt | t |kW S |dkrt | t |kW S |dkr.t | t |kW S |dkr=t | t |k W S W dS  tyI   Y dS w )a)  
    Check version string of an active module against a required version.

    If dev/prerelease tags result in TypeError for string-number comparison,
    it is assumed that the dependency is satisfied.
    Users on dev branches are responsible for keeping their own packages up to
    date.
    >>==<FT)_versionparse	TypeError)actverr   cmp_op r   _/var/www/html/RAG/RAG_venv/lib/python3.10/site-packages/skimage/_shared/version_requirements.py_check_version   s   	r   c                 C   s,   t | | dd gd}t|dt|ddS )z<Return module version or None if version can't be retrieved..fromlist__version__VERSIONN)
__import__
rpartitiongetattr)module_namemodr   r   r   get_module_version   s   r   c                 C   s   |   dkrtjdd }nzt| }W n
 ty   Y dS w |du r%dS ddl}|d|}|dus7J d|d|  }|sCd	}|d
v sOJ d| d|| d }t|||S )a  Test if *name* is installed.

    Parameters
    ----------
    name : str
        Name of module or "python"
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    out : bool
        True if `name` is installed matching the optional version.
    pythonN   FTr   z[0-9]zInvalid version numberr   )r   r   r   r   zInvalid version condition '')	lowersysr   r   ImportErrorresearchstartr   )namer   r
   r!   matchsymbr   r   r   is_installed$   s$   r'   c                    s   ddl   fdd}|S )a@  Return decorator that forces a requirement for a function or class.

    Parameters
    ----------
    name : str
        Name of module or "python".
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    func : function
        A decorator that raises an ImportError if a function is run
        in the absence of the input dependency.
    r   Nc                    s      fdd}|S )Nc                     sR   t  r| i |S d dj d  }d ur#|d 7 }t|d )N"z" in "z" requires " )r'   
__module__r    )argskwargsmsg)r$   objr   r   r   func_wrappedf   s   
z0require.<locals>.decorator.<locals>.func_wrapped)wraps)r.   r/   	functoolsr$   r   )r.   r   	decoratore   s   	zrequire.<locals>.decorator)r2   )r$   r   r3   r   r1   r   requireN   s   r4   c                 C   s&   t | |sdS t| | dd gdS )a)  Return a module object of name *module_name* if installed.

    Parameters
    ----------
    module_name : str
        Name of module.
    version : str, optional
        Version string to test against.
        If version is not None, checking version
        (must have an attribute named '__version__' or 'VERSION')
        Version may start with =, >=, > or < to specify the exact requirement

    Returns
    -------
    mod : module or None
        Module if *module_name* is installed matching the optional version
        or None otherwise.
    Nr   r   r   )r'   r   r   )r   r   r   r   r   
get_moduleu   s   
r5   )N)	r   	packagingr   r   r   r   r'   r4   r5   r   r   r   r   <module>   s    

*'