U ��.eb&� @s4ddlmZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z mZddlmZmZddlmZdd lmZmZdd lmZe�rdd lmZmZmZmZmZmZm Z m!Z!m"Z"dd l#m$Z$dd l m%Z%m&Z&e ee"e'e&fe(ee'fZ)e�*e+�Z,ddd�Z-dd�Z.Gdd�de/�Z0dS)�)�absolute_importN)�six)�canonicalize_name)�RequirementParseError)� BadCommand�InstallationError)�install_req_from_editable�install_req_from_line)� COMMENT_RE)�dist_is_editable�get_installed_distributions)�MYPY_CHECK_RUNNING) �Iterator�Optional�List� Container�Set�Dict�Tuple�Iterable�Union)� WheelCache)� Distribution� RequirementF�c  cs�|pg}d} |rt�|�j} |D]} d| Vq i} t|d||d�D]b} zt�| �}Wn8tk r�}zt�d| |�WY�qDW5d}~XYnX|r�|j r�qD|| |j <qD|�r�t �}t � t�}|D�]�}t|����}|D�]r}|���r|���d��s| �r| |��s|�d��r6|��}||kr�|�|�|Vq�|�d��sN|�d��r�|�d��rl|d d���}n|td�d����d �}t|||d �}ntt�d |���||d �}|j �s�t�d ||���t�d�q�|j | k�r ||j �st�d|t�d |���|j �n||j �|�q�t| |j ���V| |j =||j �|�q�W5QRXq�t�|�D]4\}}t|�dk�rdt�d|d�t t |�����qddVt | �!�dd�d�D]$}t"|j �| k�r�t|���V�q�dS)Nz-f %sr)� local_only�skip� user_only�pathsz6Could not generate requirement for distribution %r: %s�#) z-rz --requirementz-Zz--always-unzipz-fz --find-linksz-iz --index-urlz--prez--trusted-hostz--process-dependency-linksz--extra-index-urlz-ez --editable��=)�isolated� wheel_cache�zWSkipping line in requirement file [%s] because it's not clear what it would install: %sz9 (add #egg=PackageName to the URL to avoid this warning)zBRequirement file [%s] contains %s, but package %r is not installed�z+Requirement %s included multiple times [%s]z, z7## The following requirements were added by pip freeze:cSs |j��S�N)�name�lower)�xrr�C/usr/lib/python3.8/site-packages/pip/_internal/operations/freeze.py���zfreeze..)�key)#�re�compile�searchr �FrozenRequirement� from_distr�logger�warning�editabler'�set� collections� defaultdict�list�open�strip� startswith�rstrip�add�len�lstriprr r �sub�info�append�strrZ iteritems�join�sorted�valuesr)Z requirementZ find_linksrrrZ skip_regexr"r#Zexclude_editablerZ skip_match�linkZ installations�dist�req�excZemitted_optionsZ req_filesZ req_file_pathZreq_file�lineZline_reqr'�filesZ installationrrr*�freeze+s�   � �        ����   ����  ���� rNc CsNt|�sddgfStj�tj�|j��}ddlm}m}|� |�}|dkrv|� �}t � d||�d� |�g}|d|fSz|�||j�}Wn�|k r�|� �}d� t|�j|�g}|d|fYStk r�t �d ||j�ddgfYStk �r}zt �d |�W5d}~XYnX|dk �r2|dgfSt �d |�d g}dd|fS) zk Compute and return values (req, editable, comments) for use in FrozenRequirement.from_dist(). NFr)�vcs�RemoteNotFoundErrorz1No VCS found for editable requirement "%s" in: %rz/# Editable install with no version control ({})Tz)# Editable {} install with no remote ({})zPcannot determine version of editable source in %s (%s command not found in path)zYError when trying to get requirement for VCS system %s, falling back to uneditable formatz-Could not determine repository location of %sz-## !! Could not determine repository location)r �os�path�normcase�abspath�locationZpip._internal.vcsrOrPZget_backend_for_dir�as_requirementr3�debug�formatZget_src_requirement� project_name�type�__name__rr4r'r)rIrUrOrPZ vcs_backendrJ�commentsrKrrr*�get_requirement_info�sZ  �� ����  �r]c@s*eZdZd dd�Zedd��Zdd�ZdS) r1rcCs||_||_||_||_dSr&)r'rJr5r\)�selfr'rJr5r\rrr*�__init__�szFrozenRequirement.__init__cCs0t|�\}}}|dkr|��}||j|||d�S)N)r\)r]rVrY)�clsrIrJr5r\rrr*r2�szFrozenRequirement.from_distcCs2|j}|jrd|}d�t|j�t|�g�dS)Nz-e %s� )rJr5rEr9r\rD)r^rJrrr*�__str__�szFrozenRequirement.__str__N)r)r[� __module__� __qualname__r_� classmethodr2rbrrrr*r1�s  r1) NNNNNNFNFr)1Z __future__rr7ZloggingrQr.Z pip._vendorrZpip._vendor.packaging.utilsrZpip._vendor.pkg_resourcesrZpip._internal.exceptionsrrZpip._internal.req.constructorsrr Zpip._internal.req.req_filer Zpip._internal.utils.miscr r Zpip._internal.utils.typingr �typingrrrrrrrrrZpip._internal.cacherrrrD�boolZRequirementInfoZ getLoggerr[r3rNr]�objectr1rrrr*�s@      ,  � >