U
    @v¨g  ã                   @   s–   d dl m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 d dlmZ d dlmZmZmZ d d	lmZ e e¡ZG d
d„ de	ƒZdS )é    )Úabsolute_importN)Ú
cmdoptions)Úmake_target_python)ÚRequirementCommand)ÚRequirementSet)Úget_requirement_tracker)Ú
ensure_dirÚnormalize_pathÚwrite_output)ÚTempDirectoryc                       s,   e Zd ZdZdZ‡ fdd„Zdd„ Z‡  ZS )ÚDownloadCommandaL  
    Download packages from:

    - PyPI (and other indexes) using requirement specifiers.
    - VCS project urls.
    - Local project directories.
    - Local or remote source archives.

    pip also supports downloading from "requirements files", which provide
    an easy way to specify a whole environment to be downloaded.
    a  
      %prog [options] <requirement specifier> [package-index-options] ...
      %prog [options] -r <requirements file> [package-index-options] ...
      %prog [options] <vcs project url> ...
      %prog [options] <local project path> ...
      %prog [options] <archive url/path> ...c              
      sN  t t| ƒj||Ž | j}| t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t 	¡ ¡ | t 
¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ |jddddddtjdd t |¡ t tj| j¡}| j d	|¡ | j d	|¡ d S )
Nz-dz--destz--destination-dirz--destination-directoryÚdownload_dirÚdirzDownload packages into <dir>.)ÚdestÚmetavarÚdefaultÚhelpr   )Úsuperr   Ú__init__Úcmd_optsÚ
add_optionr   ÚconstraintsÚrequirementsÚ	build_dirÚno_depsÚglobal_optionsÚ	no_binaryÚonly_binaryÚprefer_binaryÚsrcÚpreÚno_cleanÚrequire_hashesÚprogress_barÚno_build_isolationÚ
use_pep517Úno_use_pep517ÚosÚcurdirÚadd_target_python_optionsÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚargsÚkwr   Ú
index_opts©Ú	__class__© úC/tmp/pip-unpacked-wheel-gw11q0wt/pip/_internal/commands/download.pyr   (   sF       û
þzDownloadCommand.__init__c                 C   s  d|_ g |_t |¡ t|jƒ|_t|jƒ |  |¡}t|ƒ}| j	|||d}|j
pX|j }tƒ ²}t|j|dd–}tƒ }	|  |	||||d ¡ | j||||||jdd}
| j|
|||jd}|  |¡ | |	¡ d d	d
„ |	jD ƒ¡}|rötd|ƒ |j
s|	 ¡  W 5 Q R X W 5 Q R X |	S )NT)ÚoptionsÚsessionÚtarget_pythonÚdownload)ÚdeleteÚkindF)Útemp_build_dirr6   Úreq_trackerr7   Úfinderr   Úuse_user_site)Úpreparerr>   r6   Úpy_version_infoú c                 S   s   g | ]
}|j ‘qS r4   )Úname)Ú.0Úreqr4   r4   r5   Ú
<listcomp>‰   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)Úignore_installedÚ	editablesr   Úcheck_dist_restrictionr	   r   r   Úget_default_sessionr   Ú_build_package_finderr!   r   r   r   r   Úpopulate_requirement_setÚmake_requirement_preparerÚmake_resolverÚpython_versionÚtrace_basic_infoÚresolveÚjoinÚsuccessfully_downloadedr
   Úcleanup_files)r.   r6   r/   r7   r8   r>   Úbuild_deleter=   Ú	directoryÚrequirement_setr@   ÚresolverÚ
downloadedr4   r4   r5   ÚrunP   sj    


ý
  ÿú	ù
ü


ÿ
zDownloadCommand.run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager   rZ   Ú__classcell__r4   r4   r2   r5   r      s   (r   )Ú
__future__r   Úloggingr'   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Úpip._internal.cli.req_commandr   Zpip._internal.reqr   Úpip._internal.req.req_trackerr   Úpip._internal.utils.miscr   r	   r
   Úpip._internal.utils.temp_dirr   Ú	getLoggerr[   Úloggerr   r4   r4   r4   r5   Ú<module>   s   
