3

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j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}|jtj  |jtj  |jtj  |jtj	  |jtj
  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jddddddtjdd tj| tjtj| j}| jjd	| | j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-v59g9nu1/pip/_internal/commands/download.pyr   (   s<    
zDownloadCommand.__init__c             C   s  d|_ g |_tj| t|j|_t|j | j|}t|}| j	|||d}|j
pX|j }t }t|j|dd}t }	| j|	||||d  | j||||||jdd}
| j|
|||jd}| j| |j|	 djd	d
 |	jD }|rtd| |j
s|	j  W d Q R X W d Q R X |	S )NT)optionssessiontarget_pythondownload)deletekindF)temp_build_dirr5   req_trackerr6   finderr   use_user_site)preparerr=   r5   py_version_info c             S   s   g | ]
}|j qS r3   )name).0reqr3   r3   r4   
<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.   r5   r/   r6   r7   r=   build_deleter<   	directoryrequirement_setr?   resolver
downloadedr3   r3   r4   runP   sZ    







zDownloadCommand.run)__name__
__module____qualname____doc__usager   rY   __classcell__r3   r3   )r2   r4   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   	getLoggerrZ   loggerr   r3   r3   r3   r4   <module>   s   
