U ��.e{ �@s�ddlmZddlZddlZddlZddlZddlZddlmZddl m Z e r�ddl m Z ddl mZmZmZmZddlmZddlmZe�e�ZGd d �d e�ZdS) �)�absolute_importN)� TempDirectory)�MYPY_CHECK_RUNNING)� TracebackType)�Iterator�Optional�Set�Type)�InstallRequirement)�Linkc@sReZdZdd�Zdd�Zdd�Zdd�Zd d �Zd d �Zd d�Z e j dd��Z dS)�RequirementTrackercCsjtj�d�|_|jdkrJtddd�|_|jj|_tjd<t�d|j�nd|_t�d|j�t �|_ dS)NZPIP_REQ_TRACKERFz req-tracker)�deleteZkindzCreated requirements tracker %rz Re-using requirements tracker %r) �os�environ�get�_rootr� _temp_dir�path�logger�debug�set�_entries��self�r�A/usr/lib/python3.8/site-packages/pip/_internal/req/req_tracker.py�__init__s zRequirementTracker.__init__cCs|S�Nrrrrr� __enter__&szRequirementTracker.__enter__cCs |��dSr)�cleanup)r�exc_typeZexc_valZexc_tbrrr�__exit__*szRequirementTracker.__exit__cCs$t�|j�����}tj�|j|�Sr) �hashlibZsha224Zurl_without_fragment�encodeZ hexdigestrr�joinr)r�linkZhashedrrr� _entry_path3szRequirementTracker._entry_pathc Cs�|j}t|�}|�|�}z,t|��}td||��f��W5QRXWnltk r�}zN|jtjkrd�t|d��}|� |�W5QRX|j � |�t � d||j�W5d}~XYnXdS)Nz%s is already being built: %s�wzAdded %s to build tracker %r)r%�strr&�open� LookupError�read�IOError�errnoZENOENT�writer�addrrr)r�reqr%�infoZ entry_path�fp�errrr/8s   �   zRequirementTracker.addcCs6|j}|j�|�t�|�|��t�d||j�dS)Nz Removed %s from build tracker %r) r%r�remover�unlinkr&rrr)rr0r%rrrr4Ks zRequirementTracker.removecCsNt|j�D]}|�|�q |jdk }|r2|j��t�d|r@dnd|j�dS)Nz%s build tracker %rZRemovedZCleaned)rrr4rrrrr)rr0r4rrrrRs    �zRequirementTracker.cleanupccs|�|�dV|�|�dSr)r/r4)rr0rrr�track]s zRequirementTracker.trackN) �__name__� __module__� __qualname__rrr!r&r/r4r� contextlib�contextmanagerr6rrrrr s   r )Z __future__rr:r-r"ZloggingrZpip._internal.utils.temp_dirrZpip._internal.utils.typingr�typesr�typingrrrr Zpip._internal.req.req_installr Zpip._internal.models.linkr Z getLoggerr7r�objectr rrrr�s