o
    5‘ði   ã                   @  sÂ   U d dl mZ d dlZd dlZd dlZd dlmZmZmZ d dl	m
Z
 er+d dlmZ eeeje f Zded< edeeeje f d	�Zd
d„ Zddd„Zddd„Zddd„Zejdd„ ƒZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚTypeVarÚUnion)Úunique_everseen)Ú	TypeAliasr   ÚStrPathÚStrPathT)Úboundc                 C  s   t j | ¡}t j|dd� dS )z1Ensure that the parent directory of `path` existsT)Úexist_okN)ÚosÚpathÚdirnameÚmakedirs)r   r   © r   úO/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_path.pyÚensure_directory   s   r   Úp1Úp2ÚreturnÚboolc                 C  s   t | ƒt |ƒkS )a‘  Differs from os.path.samefile because it does not require paths to exist.
    Purely string based (no comparison between i-nodes).
    >>> same_path("a/b", "./a/b")
    True
    >>> same_path("a/b", "a/./b")
    True
    >>> same_path("a/b", "././a/b")
    True
    >>> same_path("a/b", "./a/b/c/..")
    True
    >>> same_path("a/b", "../a/b/c")
    False
    >>> same_path("a", "a/b")
    False
    )Únormpath)r   r   r   r   r   Ú	same_path   s   r   Úfilenamec                 C  s   t jdkrtj | ¡S | S )a  
    Contrary to POSIX 2008, on Cygwin, getcwd (3) contains
    symlink components. Using
    os.path.abspath() works around this limitation. A fix in os.getcwd()
    would probably better, in Cygwin even more so, except
    that this seems to be by design...
    Úcygwin)ÚsysÚplatformr   r   Úabspath©r   r   r   r   Ú_cygwin_patch*   s   r   Ústrc                 C  s    t j t j t j t| ƒ¡¡¡S )z2Normalize a file/dir name for comparison purposes.)r   r   ÚnormcaseÚrealpathr   r   r   r   r   r   r   5   s    r   c              
   c  s²   � t ƒ }tj d|¡}tj dd¡}z4tj t| ƒ¡}td||gƒ}tj |¡}|r/|tjd< dV  W ||u r@tj dd¡ dS |tjd< dS ||u rStj dd¡ w |tjd< w )a°  
    Add the indicated paths to the head of the PYTHONPATH environment
    variable so that subprocesses will also see the packages at
    these paths.

    Do this in a context that restores the value on exit.

    >>> getfixture('monkeypatch').setenv('PYTHONPATH', 'anything')
    >>> with paths_on_pythonpath(['foo', 'bar']):
    ...     assert 'foo' in os.environ['PYTHONPATH']
    ...     assert 'anything' in os.environ['PYTHONPATH']
    >>> os.environ['PYTHONPATH']
    'anything'

    >>> getfixture('monkeypatch').delenv('PYTHONPATH')
    >>> with paths_on_pythonpath(['foo', 'bar']):
    ...     assert 'foo' in os.environ['PYTHONPATH']
    >>> os.environ.get('PYTHONPATH')
    Ú
PYTHONPATHÚ N)	Úobjectr   ÚenvironÚgetÚpathsepÚjoinr   ÚfilterÚpop)ÚpathsÚnothingÚorig_pythonpathÚcurrent_pythonpathÚprefixÚto_joinÚnew_pathr   r   r   Úpaths_on_pythonpath:   s"   €
ýr3   )r   r   r   r   r   r   )r   r   )r   r   r   r    )Ú
__future__r   Ú
contextlibr   r   Útypingr   r   r   Úmore_itertoolsr   Útyping_extensionsr   r    ÚPathLiker   Ú__annotations__r	   r   r   r   r   Úcontextmanagerr3   r   r   r   r   Ú<module>   s     


