
0c@_(                 @   s  d  d l  m 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 m Z d  d l m Z e rm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 f  d d 	 Z/ d d   Z0 Gd d   d e1  Z2 d S)    )absolute_importN)six)canonicalize_name)RequirementParseError)
BadCommandInstallationError)install_req_from_editableinstall_req_from_line)
COMMENT_RE)%direct_url_as_pep440_direct_referencedist_get_direct_url)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  } x | D] }	 d j  |	  Vq Wi  }
 x t d | d f  d | d |  D]v } y t j |  } Wn; t k
 r } z t j d | |  wS WYd  d  } ~ Xn X| r | j r qS | |
 | j <qS W|  rSt	   } t
 j t  } x|  D]} t |  } x| D]} | j   sE| j   j d  sE| j d#  rr| 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 sHt j d | | j    t j d  qt | j  } | |
 k r| | j st j d | t j d |  j   | j  q| | j j |  qt |
 |  j   V|
 | =| | j j |  qWWd  QRXq WxW t j |  D]F \ } } t |  d k rt j d | d j t  t	 |     qWd VxF t  |
 j!   d  d! d"   D]& } | j | k rrt |  j   VqrWd  S)$Nz-f {}
local_onlyskip	user_onlypathsz6Could not generate requirement for distribution %r: %s#-r--requirement-f--find-links-i--index-url--pre--trusted-host--process-dependency-links--extra-index-url--use-featurez-ez
--editable   =isolated 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:keyc             S   s   |  j  j   S)N)namelower)x r5   >/tmp/pip-build-jynh7p1z/pip/pip/_internal/operations/freeze.py<lambda>   s    zfreeze.<locals>.<lambda>)r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   )"formatr   FrozenRequirement	from_distr   loggerwarningeditablecanonical_namesetcollectionsdefaultdictlistopenstrip
startswithrstripaddlenlstripr   r	   r
   subr2   infor   appendstrr   	iteritemsjoinsortedvalues)requirement
find_linksr   r   r   r.   wheel_cacheZexclude_editabler   linkinstallationsdistreqexcZemitted_optionsZ	req_filesZreq_file_pathreq_filelineline_reqZline_req_canonical_namer2   filesinstallationr5   r5   r6   freeze*   s    	
	       	%		
#	#r_   c             C   s  t  |   s d d g  f St j j t j j |  j   } d d l m } m } | j	 |  } | d k r |  j
   } t j d | |  d j |  g } | d | f Sy | j | |  j  } Wn | k
 r|  j
   } d j t |  j |  g } | d | f SYn t k
 rAt j d	 | | j  d d g  f SYnN t k
 ru} z t j d
 |  WYd d } ~ Xn X| d k	 r| d g  f St 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locationZpip._internal.vcsr`   ra   Zget_backend_for_diras_requirementr;   debugr8   get_src_requirementproject_nametype__name__r   r<   r2   r   )rW   rf   r`   ra   vcs_backendrX   commentsrY   r5   r5   r6   get_requirement_info   sF    !

	ro   c               @   s=   e  Z d  Z f  d d  Z e d d    Z d d   Z d S)r9   c             C   s7   | |  _  t |  |  _ | |  _ | |  _ | |  _ d  S)N)r2   r   r>   rX   r=   rn   )selfr2   rX   r=   rn   r5   r5   r6   __init__   s
    			zFrozenRequirement.__init__c             C   s   t  |  \ } } } | d  k rR | rR t |  } | rR t | | j  } g  } | d  k rj | j   } |  | j | | d | S)Nrn   )ro   r   r   rj   rg   )clsrW   rX   r=   rn   Z
direct_urlr5   r5   r6   r:      s    zFrozenRequirement.from_distc             C   sH   |  j  } |  j r! d j |  } d j t |  j  t |  g  d S)Nz-e {}
)rX   r=   r8   rO   rB   rn   rM   )rp   rX   r5   r5   r6   __str__  s    		zFrozenRequirement.__str__N)rl   
__module____qualname__rq   classmethodr:   rt   r5   r5   r5   r6   r9      s   r9   )3
__future__r   r@   loggingrb   Zpip._vendorr   pip._vendor.packaging.utilsr   Zpip._vendor.pkg_resourcesr   Zpip._internal.exceptionsr   r   Zpip._internal.req.constructorsr   r	   Zpip._internal.req.req_filer
   Z&pip._internal.utils.direct_url_helpersr   r   Zpip._internal.utils.miscr   r   Zpip._internal.utils.typingr   Ztypingr   r   r   r   r   r   r   r   r   Zpip._internal.cacher   r   r   rM   boolZRequirementInfo	getLoggerrl   r;   r_   ro   objectr9   r5   r5   r5   r6   <module>   s:   @%|>