3
[(              	   @   s   d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZmZmZ ejeZddddddddf f	ddZG dd deZdS )    )absolute_importN)pkg_resourcessix)canonicalize_name)RequirementParseError)InstallationError)install_req_from_editableinstall_req_from_line)
COMMENT_RE)
deprecated)dist_is_editableget_installed_distributionsmake_vcs_requirement_urlFc	             c   s:  |pg }d }	|rt j|j}	g }
x(tjD ]}|jdr(|
j|jd q(W x|D ]}d|krP|
j| qPW x|D ]}d| V  qpW i }xbt	|f |dD ]P}yt
j||
}W n$ tk
r   tjd|j wY nX |r|jrq|||j< qW | rt }tjt}x| D ]}t|}x|D ]v}|j  s`|j jds`|	rT|	|s`|jd#r|j }||kr"|j| |V  q"|jds|jdr|jdr|dd  j }n|tdd  j jd}t|||d}nttj d|j ||d}|js&tj!d||j  tj!d nr|j|krl||j sZtjd|tj d|j  n||j j| n,t"||j j V  ||j= ||j j| q"W W d Q R X qW xBt#j$|D ]4\}}t|dkrtjd|dj%t&t| qW dV  x<t&|j' d d! d"D ]$}t(|j|krt"|j V  qW d S )$Nzdependency_links.txtz#egg=z-f %s)
local_onlyskip	user_onlyzCould not parse requirement: %s#-r--requirement-Z--always-unzip-f--find-links-i--index-url--pre--trusted-host--process-dependency-links--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)zDRequirement file [%s] contains %s, but that package is not installed   z+Requirement %s included multiple times [%s]z, z7## The following requirements were added by pip freeze:c             S   s
   | j j S )N)namelower)x r(   @/tmp/pip-install-65viz3iy/pip/pip/_internal/operations/freeze.py<lambda>   s    zfreeze.<locals>.<lambda>)key)r   r   r   r   r   r   r   r   r   r   r   r   ))recompilesearchr   working_sethas_metadataextendget_metadata_linesappendr   FrozenRequirement	from_distr   loggerwarningproject_nameeditabler%   setcollectionsdefaultdictlistopenstrip
startswithrstripaddlenlstripr   r	   r
   subinfostrr   	iteritemsjoinsortedvaluesr   )requirement
find_linksr   r   
skip_regexr!   r"   exclude_editabler   
skip_matchdependency_linksdistlinkinstallationsreqemitted_options	req_filesreq_file_pathreq_filelineline_reqr%   filesinstallationr(   r(   r)   freeze   s    





       


&r^   c               @   sX   e Zd Zf fddZejdZejdZedd Z	edd Z
ed	d
 Zdd ZdS )r4   c             C   s   || _ || _|| _|| _d S )N)r%   rU   r9   comments)selfr%   rU   r9   r_   r(   r(   r)   __init__   s    zFrozenRequirement.__init__z-r(\d+)$z-(20\d\d\d\d\d\d)$c             C   s  t jjt jj|j}g }ddlm}m} t|r|j	|rd}y|||}W n2 t
k
r }	 ztjd|	 d}W Y dd}	~	X nX |dkrtjd| |jd |j }d}nd}|j }|j}
t|
d	kr|
d d dkstd|
|f |
d d	 }| jj|}| jj|}|s|r|jd}|r<| j||}|sZtjd| |jd nXtddddd |jd|  |r|jd	}nd|jd	 }d}| j|}t|||}|||fS )z
        Compute and return arguments (req, editable, comments) to pass to
        FrozenRequirement.__init__().

        This method is for use in FrozenRequirement.from_dist().
        r   )vcsget_src_requirementTzYError when trying to get requirement for VCS system %s, falling back to uneditable formatNz-Could not determine repository location of %sz-## !! Could not determine repository locationFr$   =====z5Expected 1 spec with == or ===; specs = %r; dist = %rsvnz(Warning: cannot find svn location for %szF## FIXME: could not find svn URL in dependency_links for this package:zOSVN editable detection based on dependency links will be dropped in the future.z18.2i[  )replacementZgone_inZissuez3# Installing as editable to satisfy requirement %s:z{%s})rd   re   )ospathnormcaseabspathlocationpip._internal.vcsrb   rc   r   get_backend_namer   r6   r7   r3   as_requirementspecsrC   AssertionError_rev_rer.   _date_reget_backendget_locationr   groupegg_namer   )clsrR   rQ   rl   r_   rb   rc   r9   rU   excrp   version	ver_match
date_matchsvn_backendsvn_locationrevrw   r(   r(   r)   _init_args_from_dist   sl    

z&FrozenRequirement._init_args_from_distc             C   s   | j ||}| |jf| S )N)r   r8   )rx   rR   rQ   argsr(   r(   r)   r5      s    zFrozenRequirement.from_distc             C   s,   | j  }tjd|}|r(|d |j  }|S )Nz
-py\d\.\d$)rw   r,   r.   start)rR   r%   matchr(   r(   r)   rw      s
    zFrozenRequirement.egg_namec             C   s2   | j }| jrd| }djt| jt|g d S )Nz-e %s
)rU   r9   rI   r=   r_   rG   )r`   rU   r(   r(   r)   __str__  s    zFrozenRequirement.__str__N)__name__
__module____qualname__ra   r,   r-   rr   rs   classmethodr   r5   staticmethodrw   r   r(   r(   r(   r)   r4      s   

Mr4   ) 
__future__r   r;   loggingrh   r,   pip._vendorr   r   pip._vendor.packaging.utilsr   Zpip._vendor.pkg_resourcesr   pip._internal.exceptionsr   Zpip._internal.req.constructorsr   r	   Zpip._internal.req.req_filer
   pip._internal.utils.deprecationr   pip._internal.utils.miscr   r   r   	getLoggerr   r6   r^   objectr4   r(   r(   r(   r)   <module>   s*   
 