a
    û"©b6  ã                   @   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   )Ú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Ú
index_opts© r1   úh/home/yuhw/wc/wire-cell-python-pr-11/pr11/lib/python3.9/site-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�}|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|ƒ t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 r1   )Úsuccessfully_downloadedÚname)Ú.0Úreqr1   r1   r2   Ú
<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   )r/   r4   Úargsr5   r6   r=   Úbuild_deleter<   Ú	directoryÚreqsr?   ÚresolverÚrequirement_setÚ
downloadedr1   r1   r2   ÚrunN   s\    


ýüù
ü
ÿ
ÿ
zDownloadCommand.runN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager3   r   r^   r1   r1   r1   r2   r      s
   $r   )Ú
__future__r   Úloggingr(   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Ú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   Úpip._internal.utils.typingr   Úoptparser   Útypingr   Ú	getLoggerr_   Úloggerr   r1   r1   r1   r2   Ú<module>   s   
