a
    =b                     @   sN   d dl Z d dlmZ dd Zdd Zdd Zdd	d
ZdddZdddZ	dS )    N)versionc                 C   sL   t | ts| f} tj| k rHddlm} td| ddd | D f d S )Nr   )python_versiona   

You are running scikit-image on an unsupported version of Python.

Unfortunately, scikit-image 0.15 and above no longer work with your installed
version of Python (%s).  You therefore have two options: either upgrade to
Python %s, or install an older version of scikit-image.

For Python 2.7 or Python 3.4, use

 $ pip install 'scikit-image<0.15'

Please also consider updating `pip` and `setuptools`:

 $ pip install pip setuptools --upgrade

Newer versions of these tools avoid installing packages incompatible
with your version of Python.
.c                 S   s   g | ]}t |qS  )str).0vr   r   Clib/python3.9/site-packages/skimage/_shared/version_requirements.py
<listcomp>        z)ensure_python_version.<locals>.<listcomp>)
isinstancetuplesysversion_infoplatformr   ImportErrorjoin)Zmin_versionr   r   r   r	   ensure_python_version   s    

r   c                 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rzt | t |k W S W dS W n ty   Y dS 0 dS )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.

    Copyright (C) 2013  The IPython Development Team

    Distributed under the terms of the BSD License.
    >>==<FTN)_versionparse	TypeError)actverr   Zcmp_opr   r   r	   _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.r   fromlist__version__Z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 0 |du rJdS ddl}|d|}|dusnJ d|d|  }|sd	}|d
v sJ d| || d }t|||S d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.

    Notes
    -----
    Original Copyright (C) 2009-2011 Pierre Raybaut
    Licensed under the terms of the MIT License.
    ZpythonN   FTr   z[0-9]zInvalid version numberr   )r   r   r   r   zInvalid version condition '%s')	lowerr   r   r&   r   researchstartr   )namer   r   r)   matchZsymbr   r   r	   is_installedF   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                     sP   t  r| i |S d}|j f }d ur@|d 7 }t|d d S )Nz"%s" in "%s" requires "%sz %s")r.   
__module__r   )argskwargsmsg)r,   objr   r   r	   func_wrapped   s    
z0require.<locals>.decorator.<locals>.func_wrapped)wraps)r4   r5   	functoolsr,   r   )r4   r	   	decorator   s    	zrequire.<locals>.decorator)r8   )r,   r   r9   r   r7   r	   requirev   s    r:   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_module   s
    
r;   )N)N)N)
r   Z	packagingr   r   r   r   r&   r.   r:   r;   r   r   r   r	   <module>   s   
0
&