U
    P^b&                  
   @   s4  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*e+Z,d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RequirementF c
                 c   s  |pg }d }
|rt |j}
|D ]}d| V  q i }t|d||dD ]b}zt|}W n8 tk
r } ztd|| W Y qDW 5 d }~X Y nX |r|j	rqD|||j
< qD| rt }tt}| D ]}t|}|D ]r}| r| ds|
r|
|s|dr6| }||kr|| |V  q|dsN|dr|drl|d	d   }n|tdd   d
}t|||d}nttd| ||d}|j
std||  td q|j
|kr ||j
 std|td| |j
 n||j
 | qt||j
  V  ||j
= ||j
 | qW 5 Q R X qt|D ]4\}}t|dkrdtd|dt t| qddV  t |! dd dD ]$}t"|j
|	krt| V  qd S )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:c                 S   s
   | j  S N)namelower)xr   r   @/tmp/pip-install-220asx0h/pip/pip/_internal/operations/freeze.py<lambda>       zfreeze.<locals>.<lambda>)key)#recompilesearchr   FrozenRequirement	from_distr   loggerwarningeditabler'   setcollectionsdefaultdictlistopenstrip
startswithrstripaddlenlstripr   r	   r
   subinfoappendstrr   	iteritemsjoinsortedvaluesr   )requirement
find_linksr   r   r   
skip_regexr"   r#   exclude_editabler   
skip_matchlinkinstallationsdistreqexcemitted_options	req_filesreq_file_pathreq_filelineline_reqr'   filesinstallationr   r   r*   freeze+   s    
 





    
r[   c              
   C   sN  t | sddg fS tjtj| j}ddlm}m} |	|}|dkrv| 
 }td|| d|g}|d|fS z||| j}W n |k
r   | 
 }dt|j|g}|d|f Y S  tk
r   td	||j ddg f Y S  tk
r } ztd
| W 5 d}~X Y nX |dk	r2|dg fS t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]   Zget_backend_for_diras_requirementr3   debugformatget_src_requirementproject_nametype__name__r   r4   r'   r   )rP   rb   r\   r]   vcs_backendrQ   commentsrR   r   r   r*   get_requirement_info   sZ    

 
 

 rm   c                   @   s*   e Zd Zd	ddZedd Zdd ZdS )
r1   r   c                 C   s   || _ || _|| _|| _d S r&   )r'   rQ   r5   rl   )selfr'   rQ   r5   rl   r   r   r*   __init__   s    zFrozenRequirement.__init__c                 C   s0   t |\}}}|d kr| }| |j|||dS )N)rl   )rm   rd   rh   )clsrP   rQ   r5   rl   r   r   r*   r2      s    zFrozenRequirement.from_distc                 C   s2   | j }| jrd| }dt| jt|g d S )Nz-e %s
)rQ   r5   rF   r9   rl   rD   )rn   rQ   r   r   r*   __str__   s    zFrozenRequirement.__str__N)r   )rj   
__module____qualname__ro   classmethodr2   rr   r   r   r   r*   r1      s   

r1   )
NNNNNNFNFr   )1
__future__r   r7   loggingr^   r.   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   rD   boolZRequirementInfo	getLoggerrj   r3   r[   rm   objectr1   r   r   r   r*   <module>   s@   ,
          
 >