B
    =)H[%(  ã            	   @   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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 d dlmZ d d	lmZ d d
lmZmZ e e¡Zddd„ZG dd„ deƒZdS )é    )Úabsolute_importN)Úpkg_resourcesÚsix)Úcanonicalize_name)ÚRequirementParseError)ÚInstallationError)ÚInstallRequirement)Ú
COMMENT_RE)ÚRemovedInPip11Warning)Údist_is_editableÚget_installed_distributionsF© c	             c   s<  |pg }d }	|rt  |¡j}	g }
x(tjD ]}| d¡r(|
 | d¡¡ q(W x|D ]}d|krP|
 |¡ qPW x|D ]}d| V  qpW i }xbt	|d|d�D ]P}yt
 ||
¡}W n$ tk
rÎ   t d|j¡ w–Y nX |rÜ|jrÜq–|||j< q–W | �rútƒ }t t¡}�x¬| D �]¢}t|ƒ��Œ}�x‚|D �]x}| ¡ �r^| ¡  d¡�s^|	�rR|	|ƒ�s^| d¡�r„| ¡ }||k�r"| |¡ |V  �q"| d	¡�sœ| d
¡�ræ| d	¡�rº|dd …  ¡ }n|td
ƒd …  ¡  d¡}tj|||d�}ntjt  !d|¡ ¡ ||d�}|j�s(t "d|| ¡ ¡ t "d¡ nr|j|k�rn||j �s\t d|t  !d|¡ ¡ ¡ n||j  |¡ n,t#||j ƒ ¡ V  ||j= ||j  |¡ �q"W W d Q R X �qW xBt$ %|¡D ]4\}}t|ƒdk�r¼t d|d &t't|ƒƒ¡¡ �q¼W dV  x<t'| (¡ dd„ d�D ]$}t)|jƒ|k�rt#|ƒ ¡ V  �qW d S )Nzdependency_links.txtz#egg=z-f %sr   )Ú
local_onlyÚskipÚ	user_onlyzCould not parse requirement: %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)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  ¡ S )N)ÚnameÚlower)Úxr   r   ú`C:\Users\HIRONO~1\AppData\Local\Temp\pip-install-qz7kpjmn\pip\pip\_internal\operations\freeze.pyÚ<lambda>š   s    zfreeze.<locals>.<lambda>)Úkey)*Ú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   Úfrom_editableÚ	from_liner	   Ú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¦    









&rR   c               @   sJ   e Zd Zddd„Ze d¡Ze d¡Zedd„ ƒZ	e
dd	„ ƒZd
d„ ZdS )r&   r   c             C   s   || _ || _|| _|| _d S )N)r   rI   r+   Úcomments)Úselfr   rI   r+   rS   r   r   r   Ú__init__    s    zFrozenRequirement.__init__z-r(\d+)$z-(20\d\d\d\d\d\d)$c          
   C   sº  t j t j |j¡¡}g }ddlm}m} t|ƒr®| 	|¡r®d}y|||ƒ}W n2 t
k
r€ }	 zt d|	¡ d }W d d }	~	X Y nX |d kr¬t d|¡ | d¡ | ¡ }d}nüd}| ¡ }|j}
t|
ƒdkrÜ|
d d d	ksìtd
|
|f ƒ‚|
d d }| j |¡}| j |¡}|�s|�rª| d¡}|�r:|ƒ  ||¡}|�sXt d|¡ | d¡ nRt dt¡ | d| ¡ |�r„| d¡}nd| d¡ }d}d|||  |¡f }| |j|||ƒS )Nr   )ÚvcsÚget_src_requirementTzYError 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 locationFr   )z==z===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.z3# Installing as editable to satisfy requirement %s:z{%s}z%s@%s#egg=%s)ÚosÚpathÚnormcaseÚabspathÚlocationÚpip._internal.vcsrV   rW   r   Úget_backend_namer   r(   r)   r%   Úas_requirementÚspecsr5   ÚAssertionErrorÚ_rev_rer    Ú_date_reÚget_backendÚget_locationÚwarningsÚwarnr
   ÚgroupÚegg_namer*   )ÚclsrF   rE   r]   rS   rV   rW   r+   rI   Úexcra   ÚversionÚ	ver_matchÚ
date_matchÚsvn_backendÚsvn_locationÚrevr   r   r   r'   ©   sl    
zFrozenRequirement.from_distc             C   s,   |   ¡ }t d|¡}|r(|d | ¡ … }|S )Nz
-py\d\.\d$)rj   r   r    Ústart)rF   r   Úmatchr   r   r   rj   ð   s
    zFrozenRequirement.egg_namec             C   s2   | j }| jrd| }d t| jƒt|ƒg ¡d S )Nz-e %sÚ
)rI   r+   r=   r/   rS   r;   )rT   rI   r   r   r   Ú__str__ø   s    zFrozenRequirement.__str__N)r   )Ú__name__Ú
__module__Ú__qualname__rU   r   r   rc   rd   Úclassmethodr'   Ústaticmethodrj   rv   r   r   r   r   r&   Ÿ   s   


Gr&   )	NNNNNFNFr   )Ú
__future__r   r-   ÚloggingrY   r   rg   Úpip._vendorr   r   Úpip._vendor.packaging.utilsr   Zpip._vendor.pkg_resourcesr   Úpip._internal.exceptionsr   Zpip._internal.reqr   Zpip._internal.req.req_filer	   Úpip._internal.utils.deprecationr
   Úpip._internal.utils.miscr   r   Ú	getLoggerrw   r(   rR   Úobjectr&   r   r   r   r   Ú<module>   s,   
     
 