U
    E¸Öh  ã                   @   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_optsZ
add_optionr   ZconstraintsZrequirementsÚ	build_dirZno_depsZglobal_optionsZ	no_binaryZonly_binaryZprefer_binaryÚsrcZpreÚno_cleanZ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)ÚselfÚargsÚkwr   Z
index_opts©Ú	__class__© úE./venv/lib/python3.8/site-packages/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_pythonZdownload)ÚdeleteÚkindF)Ztemp_build_dirr#   Úreq_trackerr$   Úfinderr   Zuse_user_site)Úpreparerr)   r#   Zpy_version_infoú c                 S   s   g | ]
}|j ‘qS r!   )Úname)Ú.0Zreqr!   r!   r"   Ú
<listcomp>‰   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)Zignore_installedZ	editablesr   Zcheck_dist_restrictionr	   r   r   Zget_default_sessionr   Z_build_package_finderr   r   r   r   r   Zpopulate_requirement_setZmake_requirement_preparerZmake_resolverZpython_versionZtrace_basic_infoZresolveÚjoinZsuccessfully_downloadedr
   Zcleanup_files)r   r#   r   r$   r%   r)   Zbuild_deleter(   Z	directoryZrequirement_setr*   ZresolverZ
downloadedr!   r!   r"   ÚrunP   sj    


ý
  ÿú	ù
ü


ÿ
zDownloadCommand.run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager   r0   Ú__classcell__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   Zpip._internal.reqr   Zpip._internal.req.req_trackerr   Zpip._internal.utils.miscr   r	   r
   Zpip._internal.utils.temp_dirr   Z	getLoggerr1   Úloggerr   r!   r!   r!   r"   Ú<module>   s   
