a
    ü`7  ã                   @   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 d dlmZmZmZ d d	lmZ d d
lmZ er¤d dl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)ÚSUCCESS)Úget_requirement_tracker)Ú
ensure_dirÚnormalize_pathÚwrite_output)ÚTempDirectory)ÚMYPY_CHECK_RUNNING)ÚValues)ÚListc                   @   s(   e Zd ZdZdZdd„ Ze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> ...c              
   C   sL  | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t 	¡ ¡ | j  t 
¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j jddddddtjdd t | j ¡ t tj| j¡}| j d	|¡ | j d	| j ¡ d S )
Nz-dz--destz--destination-dirz--destination-directoryÚdownload_dirÚdirzDownload packages into <dir>.)ÚdestÚmetavarÚdefaultÚhelpr   )Zcmd_optsZ
add_optionr   ÚconstraintsÚrequirementsZ	build_dirZno_depsZglobal_optionsZ	no_binaryZonly_binaryZprefer_binaryÚsrcZpreZrequire_hashesZprogress_barZno_build_isolationZ
use_pep517Zno_use_pep517ÚosÚcurdirZadd_target_python_optionsZmake_option_groupZindex_groupÚparserZinsert_option_group)ÚselfZ
index_opts© r   úA/usr/lib/python3/dist-packages/pip/_internal/commands/download.pyÚadd_options*   s:    ûþzDownloadCommand.add_optionsc              	   C   s  d|_ g |_t |¡ t|jƒ|_t|jƒ |  |¡}t|ƒ}| j	|||d}|  
tƒ ¡}t|j ddd}|  ||||¡}| j||||||jdd}	| j|	|||jd}
|  |¡ |
j|dd}g }|j ¡ D ]2}|jd u rÐ|jd usìJ ‚|	 |¡ | |j¡ qÐ|rtd	d
 |¡ƒ tS )NT)ÚoptionsÚsessionÚtarget_pythonZdownload)ÚdeleteÚkindZglobally_managedF)Ztemp_build_dirr!   Úreq_trackerr"   Úfinderr   Zuse_user_site)Úpreparerr'   r!   Zpy_version_info)Zcheck_supported_wheelszSuccessfully downloaded %sú )Zignore_installedZ	editablesr   Zcheck_dist_restrictionr
   r   r	   Zget_default_sessionr   Z_build_package_finderÚenter_contextr   r   Zno_cleanZget_requirementsZmake_requirement_preparerZmake_resolverZpython_versionZtrace_basic_infoZresolver   ÚvaluesZsatisfied_byÚnameZsave_linked_requirementÚappendr   Újoinr   )r   r!   Úargsr"   r#   r'   r&   Z	directoryZreqsr(   ZresolverZrequirement_setZ
downloadedZreqr   r   r   ÚrunN   s^    


ýýù
ü
ÿ

zDownloadCommand.runN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Zusager    r   r0   r   r   r   r   r      s
   $r   )Z
__future__r   Zloggingr   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Zpip._internal.cli.req_commandr   r   Zpip._internal.cli.status_codesr   Zpip._internal.req.req_trackerr   Zpip._internal.utils.miscr	   r
   r   Zpip._internal.utils.temp_dirr   Zpip._internal.utils.typingr   Zoptparser   Útypingr   Z	getLoggerr1   Zloggerr   r   r   r   r   Ú<module>   s   
