a
    Žù»jJ  ã                	   @   sº   d Z ddlZddlZddlZddlmZ ddlmZ G dd„ dƒZG dd„ deƒZ	zddl
Zddd„ZW n ey„   ddd„ZY n0 ejdkrªdZddlmZ dd„ ZnddlmZ dS )z,
Backports of fixes for joblib dependencies
é    N)Úutil)Úbasenamec                   @   sJ   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )ÚVersionúþBackport from deprecated distutils

    We maintain this backport to avoid introducing a new dependency on
    `packaging`.

    We might rexplore this choice in the future if all major Python projects
    introduce a dependency on packaging anyway.
    Nc                 C   s   |r|   |¡ d S ©N©Úparse©ÚselfÚvstring© r   ú6E:\soccer\ml_env\Lib\site-packages\joblib/backports.pyÚ__init__   s    zVersion.__init__c                 C   s   d| j jt| ƒf S )Nz	%s ('%s'))Ú	__class__Ú__name__Ústr©r
   r   r   r   Ú__repr__   s    zVersion.__repr__c                 C   s   |   |¡}|tu r|S |dkS ©Nr   ©Ú_cmpÚNotImplemented©r
   ÚotherÚcr   r   r   Ú__eq__   s    
zVersion.__eq__c                 C   s   |   |¡}|tu r|S |dk S r   r   r   r   r   r   Ú__lt__#   s    
zVersion.__lt__c                 C   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r   Ú__le__)   s    
zVersion.__le__c                 C   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r   Ú__gt__/   s    
zVersion.__gt__c                 C   s   |   |¡}|tu r|S |dkS r   r   r   r   r   r   Ú__ge__5   s    
zVersion.__ge__)N)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   r   r      s   	
r   c                   @   sH   e Zd ZdZe dej¡Zddd„Zdd„ Z	dd	„ Z
d
d„ Zdd„ ZdS )ÚLooseVersionr   z(\d+ | [a-z]+ | \.)Nc                 C   s   |r|   |¡ d S r   r   r	   r   r   r   r   H   s    zLooseVersion.__init__c              	   C   s\   || _ dd„ | j |¡D ƒ}t|ƒD ],\}}zt|ƒ||< W q$ tyN   Y q$0 q$|| _d S )Nc                 S   s   g | ]}|r|d kr|‘qS )Ú.r   )Ú.0Úxr   r   r   Ú
<listcomp>Q   ó    z&LooseVersion.parse.<locals>.<listcomp>)r   Úcomponent_reÚsplitÚ	enumerateÚintÚ
ValueErrorÚversion)r
   r   Ú
componentsÚiÚobjr   r   r   r   L   s    zLooseVersion.parsec                 C   s   | j S r   )r   r   r   r   r   Ú__str__Z   s    zLooseVersion.__str__c                 C   s   dt | ƒ S )NzLooseVersion ('%s'))r   r   r   r   r   r   ]   s    zLooseVersion.__repr__c                 C   sV   t |tƒrt|ƒ}nt |tƒs"tS | j|jkr2dS | j|jk rBdS | j|jkrRdS d S )Nr   éÿÿÿÿé   )Ú
isinstancer   r#   r   r.   )r
   r   r   r   r   r   `   s    


zLooseVersion._cmp)N)r   r    r!   r"   ÚreÚcompileÚVERBOSEr)   r   r   r2   r   r   r   r   r   r   r#   <   s   	
r#   Úuint8úr+ÚCFc           	      C   sb   t  d |t| ƒt ¡ ¡¡ tj| |||||d�}ttj	ƒdk rF||_
|r^ddlm} ||ƒ |S )ab  Custom memmap constructor compatible with numpy.memmap.

        This function:
        - is a backport the numpy memmap offset fix (See
          https://github.com/numpy/numpy/pull/8443 for more details.
          The numpy fix is available starting numpy 1.13)
        - adds ``unlink_on_gc_collect``, which specifies  explicitly whether
          the process re-constructing the memmap owns a reference to the
          underlying file. If set to True, it adds a finalizer to the
          newly-created memmap that sends a maybe_unlink request for the
          memmaped file to resource_tracker.
        z?[MEMMAP READ] creating a memmap (shape {}, filename {}, pid {}))ÚdtypeÚmodeÚoffsetÚshapeÚorderz1.13r4   )Úadd_maybe_unlink_finalizer)r   ÚdebugÚformatr   ÚosÚgetpidÚnpZmemmapr#   Ú__version__r>   Z_memmapping_reducerrA   )	Úfilenamer<   r=   r>   r?   r@   Úunlink_on_gc_collectÚmmrA   r   r   r   Úmake_memmapq   s    ÿÿÿrK   c                 C   s   t dƒ‚d S )NzL'joblib.backports.make_memmap' should not be used if numpy is not installed.)ÚNotImplementedError)rH   r<   r=   r>   r?   r@   rI   r   r   r   rK   ˜   s    	ÿÚnt)é   é   )Úreplacec              
   C   s‚   d}d}d}||k r|zt | |ƒ W q~W q tyx } z:t|ddƒtv rbt |¡ ||7 }|d9 }n‚ W Y d}~qd}~0 0 q‚ dS )z²Renames ``src`` into ``dst`` overwriting ``dst`` if it exists.

        On Windows os.replace can yield permission errors if executed by two
        different processes.
        r4   r   gü©ñÒMbP?ÚwinerrorNé   )rP   Ú	ExceptionÚgetattrÚaccess_denied_errorsÚtimeÚsleep)ÚsrcÚdstZmax_sleep_timeZtotal_sleep_timeZ
sleep_timeÚexcr   r   r   Úconcurrency_safe_rename¬   s    


r[   )r9   r:   r   Nr;   F)r9   r:   r   Nr;   F)r"   rD   r6   rV   Úmultiprocessingr   Úos.pathr   r   r#   ÚnumpyrF   rK   ÚImportErrorÚnamerU   rP   r[   r   r   r   r   Ú<module>   s:   02      ù%      ù

