3
Ug*&              
   @   s0  d dl Z d dlZd dlZd dl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 d dlmZ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 ejeZG d
d de	Z ddddddf fe
ee!  e"e"e
ee!  e"e"ee! ee! dddZ#ee!dddZ$ee dddZ%G dd dZ&dS )    N)	ContainerDictIterableIteratorList
NamedTupleOptionalSet)canonicalize_name)Version)
BadCommandInstallationError)BaseDistributionget_environment)install_req_from_editableinstall_req_from_line)
COMMENT_RE)%direct_url_as_pep440_direct_referencec               @   s   e Zd ZU eee dS )_EditableInfoN)__name__
__module____qualname__strrequirementr   comments r   r   C/tmp/pip-unpacked-wheel-0ht26j5g/pip/_internal/operations/freeze.pyr      s   
r   F)r   
local_only	user_onlypathsisolatedexclude_editableskipreturnc             c   st  i }t |j|f |d}x,|D ]$}	tj|	}
|r8|
jr8q|
||
j< qW | r6t }tjt	}x| D ]}t
|p}xf|D ]\}|j  s|j jd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sbtjd||j  tjd q~t|j}||kr||j stjd|tjd|j |j n||j j| q~t|| j V  ||= ||j j| q~W W d Q R X qdW x@|j D ]4\}}t|dkrtjd|djtt| qW dV  x8t|j dd dD ] }|j|krLt|j V  qLW d S )N)r   r"   r   #-r--requirement-f--find-links-i--index-url--pre--trusted-host--process-dependency-links--extra-index-url--use-featurez-ez
--editable   =)r     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)xr   r   r   <lambda>   s    zfreeze.<locals>.<lambda>)key)r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   ) r   Ziter_installed_distributionsFrozenRequirement	from_disteditablecanonical_namesetcollectionsdefaultdictlistopenstrip
startswithrstripaddlenlstripr   r   r   subr4   loggerinfor
   warningappendr   itemsjoinsortedvalues)r   r   r   r   r    r!   r"   ZinstallationsdistsdistreqZemitted_optionsZ	req_filesZreq_file_pathreq_filelineZline_reqZline_req_canonical_namer4   filesZinstallationr   r   r   freeze   s    	




          





"rW   )rR   r#   c             C   s0   t | jtr| j d| j S | j d| j S )Nz==z===)
isinstanceversionr   raw_name)rR   r   r   r   _format_as_name_version   s    r[   c             C   s  | j }|sttjjtjj|}ddlm}m}m	} |j
|}|dkrtt| }tjd|| t|d| dgdS t|j}y|j|| j}	W n |k
r   t| }t|d| d	| dgdS  |k
r }
 z0t| }t|d| d
| dd|
j dgdS d}
~
X nh tk
r<   tjd||j t|g dS  tk
rj } ztjd| W Y dd}~X nX t|	g dS tjd| t|dgdS )za
    Compute and return values (req, comments) for use in
    FrozenRequirement.from_dist().
    r   )RemoteNotFoundErrorRemoteNotValidErrorvcsNz1No VCS found for editable requirement "%s" in: %rz,# Editable install with no version control ())r   r   z# Editable z install with no remote (z
 install (z4) with either a deleted local remote or invalid URI:z# ''zPcannot determine version of editable source in %s (%s command not found in path)z6Error when trying to get requirement for VCS system %sz-Could not determine repository location of %sz-## !! Could not determine repository location)editable_project_locationAssertionErrorospathnormcaseabspathpip._internal.vcsr\   r]   r^   get_backend_for_dirr[   rI   debugr   typer   get_src_requirementrZ   urlr   rK   r4   r   )rR   ra   locationr\   r]   r^   vcs_backendZdisplayZvcs_namerS   exexcr   r   r   _get_editable_info   sR    

rq   c               @   sL   e Zd Zf feeeee ddddZeed dddZ	edd	d
Z
dS )r9   N)r4   rS   r;   r   r#   c             C   s&   || _ t|| _|| _|| _|| _d S )N)r4   r
   r<   rS   r;   r   )selfr4   rS   r;   r   r   r   r   __init__   s
    
zFrozenRequirement.__init__)rR   r#   c             C   sN   |j }|rt|\}}n$g }|j}|r4t||j}nt|}| |j|||dS )N)r   )r;   rq   
direct_urlr   rZ   r[   )clsrR   r;   rS   r   rt   r   r   r   r:      s    zFrozenRequirement.from_dist)r#   c             C   s4   | j }| jrd| }djt| jt|g d S )Nz-e 
)rS   r;   rN   r@   r   r   )rr   rS   r   r   r   __str__   s    
zFrozenRequirement.__str__)r   r   r   r   boolr   rs   classmethodr   r:   rw   r   r   r   r   r9      s
   r9   )'r>   loggingrc   typingr   r   r   r   r   r   r   r	   pip._vendor.packaging.utilsr
   Zpip._vendor.packaging.versionr   pip._internal.exceptionsr   r   Zpip._internal.metadatar   r   pip._internal.req.constructorsr   r   Zpip._internal.req.req_filer   Z&pip._internal.utils.direct_url_helpersr   	getLoggerr   rI   r   r   rx   rW   r[   rq   r9   r   r   r   r   <module>   s.   (
&qB