3
v,h(                 @   s   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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 )    N)Values)List)
cmdoptions)make_target_python)RequirementCommandwith_cleanup)SUCCESS)get_requirement_tracker)
ensure_dirnormalize_pathwrite_output)TempDirectoryc               @   s<   e Zd ZdZdZddddZeeee	 e
ddd	Zd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> ...N)returnc          
   C   sL  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj	  | j jtj
  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jddddddtjdd tj| j  tjtj| j}| jjd	| | jjd	| j  d S )
Nz-dz--destz--destination-dirz--destination-directorydownload_dirdirzDownload packages into <dir>.)destmetavardefaulthelpr   )cmd_opts
add_optionr   constraintsrequirementsno_depsglobal_options	no_binaryonly_binaryprefer_binarysrcprerequire_hashesprogress_barno_build_isolation
use_pep517Zno_use_pep517ignore_requires_pythonoscurdirZadd_target_python_optionsmake_option_groupindex_groupparserinsert_option_group)self
index_opts r.   @/tmp/pip-install-dn9_u1zy/pip/pip/_internal/commands/download.pyadd_options%   s<    zDownloadCommand.add_options)optionsargsr   c          	   C   s*  d|_ g |_tj| t|j|_t|j | j|}t|}| j	||||j
d}| jt }t|j ddd}| j||||}| j||||||jdd}	| j|	|||j
|jd}
| j| |
j|dd}g }x@|jj D ]2}|jd kr|jd k	st|	j| |j|j qW |r&td	d
j| tS )NT)r1   sessiontarget_pythonr%   download)deletekindZglobally_managedF)Ztemp_build_dirr1   req_trackerr3   finderr   use_user_site)preparerr9   r1   r%   Zpy_version_info)check_supported_wheelszSuccessfully downloaded %s )ignore_installed	editablesr   check_dist_restrictionr   r   r
   Zget_default_sessionr   _build_package_finderr%   enter_contextr	   r   no_cleanZget_requirementsZmake_requirement_preparerZmake_resolverpython_versionZtrace_basic_inforesolver   valuessatisfied_bynameAssertionErrorZsave_linked_requirementappendr   joinr   )r,   r1   r2   r3   r4   r9   r8   	directoryreqsr;   resolverrequirement_set
downloadedreqr.   r.   r/   runK   sV    







zDownloadCommand.run)__name__
__module____qualname____doc__usager0   r   r   r   strintrR   r.   r.   r.   r/   r      s
   &r   )loggingr&   optparser   typingr   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Zpip._internal.cli.req_commandr   r   pip._internal.cli.status_codesr   pip._internal.req.req_trackerr	   pip._internal.utils.miscr
   r   r   pip._internal.utils.temp_dirr   	getLoggerrS   loggerr   r.   r.   r.   r/   <module>   s   
