B
    `’»d„  ã               @   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	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Úwith_cleanup)Úget_requirement_tracker)Ú
ensure_dirÚnormalize_pathÚwrite_output)ÚTempDirectoryc                   s0   e Zd ZdZdZ‡ fdd„Ze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          
      s@  t t| ƒj||Ž | j}| 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Ú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-hu9qqap1/pip/_internal/commands/download.pyr   '   s:    
zDownloadCommand.__init__c          	   C   sü   d|_ g |_t |¡ t|jƒ|_t|jƒ |  |¡}t|ƒ}| j	|||d}|j
pX|j }|  tƒ ¡}t|j|ddd}|  ||||¡}	| j||||||jdd}
| j|
|||jd}|  |¡ |j|	dd}d	 d
d„ |j ¡ D ƒ¡}|røtd|ƒ |S )NT)ÚoptionsÚsessionÚtarget_pythonÚdownload)ÚdeleteÚkindÚglobally_managedF)Útemp_build_dirr4   Úreq_trackerr5   Úfinderr   Úuse_user_site)Úpreparerr=   r4   Úpy_version_info)Úcheck_supported_wheelsú c             S   s   g | ]}|j r|j‘qS r2   )Úsuccessfully_downloadedÚname)Ú.0Úreqr2   r2   r3   ú
<listcomp>ˆ   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)Úignore_installedÚ	editablesr   Úcheck_dist_restrictionr	   r   r   Úget_default_sessionr   Ú_build_package_finderÚno_cleanr   Úenter_contextr   r   Úget_requirementsÚmake_requirement_preparerÚmake_resolverÚpython_versionÚtrace_basic_infoÚresolveÚjoinr   Úvaluesr
   )r-   r4   r.   r5   r6   r=   Úbuild_deleter<   Ú	directoryÚreqsr?   ÚresolverÚrequirement_setÚ
downloadedr2   r2   r3   ÚrunN   sP    






zDownloadCommand.run)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager   r   r]   Ú__classcell__r2   r2   )r1   r3   r      s   'r   )Ú
__future__r   Úloggingr&   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Úpip._internal.cli.req_commandr   r   Úpip._internal.req.req_trackerr   Úpip._internal.utils.miscr   r	   r
   Úpip._internal.utils.temp_dirr   Ú	getLoggerr^   Úloggerr   r2   r2   r2   r3   Ú<module>   s   
