o
    ¾ÔiÓ  ã                   @   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	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 )é    N)ÚValues)Ú
cmdoptions)Úmake_target_python)ÚRequirementCommandÚwith_cleanup)ÚSUCCESS)Úget_build_tracker)Ú
ensure_dirÚnormalize_pathÚwrite_output)ÚTempDirectoryc                   @   s<   e Zd ZdZdZddd„Zededee	 de
f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> ...ÚreturnNc              
   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   ZconstraintsZbuild_constraintsÚrequirementsZno_depsZ	no_binaryZonly_binaryZprefer_binaryÚsrcZpreZrequire_hashesZprogress_barZno_build_isolationZ
use_pep517Zcheck_build_depsÚignore_requires_pythonÚosÚcurdirZadd_target_python_optionsZmake_option_groupZindex_groupÚparserZinsert_option_group)ÚselfZ
index_opts© r   ú?lib/python3.10/site-packages/pip/_internal/commands/download.pyÚadd_options$   s@   øþzDownloadCommand.add_optionsÚoptionsÚargsc              
   C   sB  d|_ g |_t |¡ t |¡ t|jƒ|_t|jƒ |  |¡}t	|ƒ}| j
||||jd}|  tƒ ¡}t|j ddd}|  ||||¡}| j||||||jd| jd}	| j|	|||j|jd}
|  |¡ |
j|dd}|	 |j ¡ ¡ g }|j ¡ D ]}|jd u r”|jd us‰J ‚|	 |¡ | |j¡ q{|rŸtd	d
 |¡ƒ t S )NT)r   ÚsessionÚtarget_pythonr   Zdownload)ÚdeleteÚkindZglobally_managedF)Ztemp_build_dirr   Úbuild_trackerr!   Úfinderr   Zuse_user_siteÚ	verbosity)Úpreparerr&   r   r   Zpy_version_info)Zcheck_supported_wheelszSuccessfully downloaded %sú )!Zignore_installedZ	editablesr   Zcheck_dist_restrictionZcheck_build_constraintsr
   r   r	   Zget_default_sessionr   Z_build_package_finderr   Úenter_contextr   r   Zno_cleanZget_requirementsZmake_requirement_preparerr'   Zmake_resolverZpython_versionZtrace_basic_infoÚresolveZ prepare_linked_requirements_morer   ÚvaluesZsatisfied_byÚnameZsave_linked_requirementÚappendr   Újoinr   )r   r   r    r!   r"   r&   r%   Z	directoryZreqsr(   ZresolverZrequirement_setZ
downloadedZreqr   r   r   ÚrunJ   sf   



üýøû


€zDownloadCommand.run)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager   r   r   ÚlistÚstrÚintr0   r   r   r   r   r      s    
& r   )Zloggingr   Zoptparser   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.operations.build.build_trackerr   Zpip._internal.utils.miscr	   r
   r   Zpip._internal.utils.temp_dirr   Z	getLoggerr1   Úloggerr   r   r   r   r   Ú<module>   s    
