3

g'              
   @   sH  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 d dlm	Z	 d dl
mZ d dlmZmZ d dlmZmZ d dlmZ d d	lmZmZ d d
lmZ erd dlmZmZmZmZmZmZm Z m!Z!m"Z" d dl#m$Z$ d dl
m%Z%m&Z& e ee"e'e&f  e(ee' f Z)ej*e+Z,dddddddddf f
ddZ-dd Z.G dd de/Z0dS )    )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RequirementFc
             c   s  |pg }d }
|rt j|j}
x|D ]}d| V  q"W i }xpt|f ||dD ]\}ytj|}W n2 tk
r } ztjd|| wJW Y d d }~X nX |r|j	rqJ|||j
< qJW | rt }tjt}x| D ]}t|}x|D ]x}|j  s |j jds |
r|
|s |jd!rB|j }||kr|j| |V  q|jdsZ|jdr|jdrx|dd  j }n|tdd  j jd}t|||d}nttjd|j ||d}|jstjd||j  tjd qt|j}||kr4||j s"tjd|tjd|j |j n||j j| qt|| j V  ||= ||j j| qW W d Q R X qW xBtj |D ]4\}}t|dkrztjd|dj!t"t| qzW dV  x8t"|j# dd d D ] }|j
|	krt|j V  qW d S )"Nz-f %s)
local_onlyskip	user_onlypathsz6Could not generate requirement for distribution %r: %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)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:c             S   s
   | j j S )N)namelower)x r4   C/tmp/pip-unpacked-wheel-v59g9nu1/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   FrozenRequirement	from_distr   loggerwarningeditablecanonical_namesetcollectionsdefaultdictlistopenstrip
startswithrstripaddlenlstripr   r	   r
   subr1   infor   appendstrr   	iteritemsjoinsortedvalues)requirement
find_linksr   r   r   
skip_regexr-   r.   Zexclude_editabler   Z
skip_matchlinkZinstallationsdistreqexcZemitted_optionsZ	req_filesZreq_file_pathreq_filelineZline_reqZline_req_canonical_namer1   filesZinstallationr4   r4   r5   freeze+   s    


       



"r^   c             C   sF  t | sddg fS tjjtjj| j}ddlm}m} |j	|}|dkrv| j
 }tjd|| dj|g}|d|fS y|j|| j}W n |k
r   | j
 }djt|j|g}|d|fS  tk
r   tjd	||j ddg fS  tk
r } ztjd
| W Y dd}~X nX |dk	r*|dg fS tjd| dg}dd|fS )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locationpip._internal.vcsr_   r`   get_backend_for_diras_requirementr=   debugformatget_src_requirementproject_nametype__name__r   r>   r1   r   )rX   re   r_   r`   vcs_backendrY   commentsrZ   r4   r4   r5   get_requirement_info   sF    






rq   c               @   s,   e Zd Zf fddZedd Zdd ZdS )r;   c             C   s&   || _ t|| _|| _|| _|| _d S )N)r1   r   r@   rY   r?   rp   )selfr1   rY   r?   rp   r4   r4   r5   __init__   s
    
zFrozenRequirement.__init__c             C   s0   t |\}}}|d kr|j }| |j|||dS )N)rp   )rq   rh   rl   )clsrX   rY   r?   rp   r4   r4   r5   r<      s    zFrozenRequirement.from_distc             C   s2   | j }| jrd| }djt| jt|g d S )Nz-e %s
)rY   r?   rQ   rD   rp   rO   )rr   rY   r4   r4   r5   __str__  s    zFrozenRequirement.__str__N)rn   
__module____qualname__rs   classmethodr<   rv   r4   r4   r4   r5   r;      s   	r;   )1
__future__r   rB   loggingra   r8   pip._vendorr   pip._vendor.packaging.utilsr   Zpip._vendor.pkg_resourcesr   pip._internal.exceptionsr   r   pip._internal.req.constructorsr   r	   Zpip._internal.req.req_filer
   pip._internal.utils.miscr   r   pip._internal.utils.typingr   typingr   r   r   r   r   r   r   r   r   pip._internal.cacher   r   r   rO   boolZRequirementInfo	getLoggerrn   r=   r^   rq   objectr;   r4   r4   r4   r5   <module>   s>   ,
 >