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   )Úcmd_optsÚ
add_optionr   ÚconstraintsÚbuild_constraintsÚrequirementsÚno_depsÚ	no_binaryÚonly_binaryÚprefer_binaryÚsrcÚpreÚrequire_hashesÚprogress_barÚno_build_isolationÚ
use_pep517Úcheck_build_depsÚignore_requires_pythonÚosÚcurdirÚadd_target_python_optionsÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r/   ú[/var/www/html/ocr-read/venv/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)r2   ÚsessionÚtarget_pythonr%   Údownload)ÚdeleteÚkindÚglobally_managedF)Útemp_build_dirr2   Úbuild_trackerr4   Úfinderr   Úuse_user_siteÚ	verbosity)Úpreparerr<   r2   r%   Úpy_version_info)Úcheck_supported_wheelszSuccessfully downloaded %sú )!Úignore_installedÚ	editablesr   Úcheck_dist_restrictionÚcheck_build_constraintsr
   r   r	   Úget_default_sessionr   Ú_build_package_finderr%   Úenter_contextr   r   Úno_cleanÚget_requirementsÚmake_requirement_preparerr>   Úmake_resolverÚpython_versionÚtrace_basic_infoÚresolveÚ prepare_linked_requirements_morer   ÚvaluesÚsatisfied_byÚnameÚsave_linked_requirementÚappendr   Újoinr   )r-   r2   r3   r4   r5   r<   r;   Ú	directoryÚreqsr?   ÚresolverÚrequirement_setÚ
downloadedÚreqr/   r/   r0   ÚrunJ   sf   



üýøû


€zDownloadCommand.run)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager1   r   r   ÚlistÚstrÚintr^   r/   r/   r/   r0   r      s    
& r   )Úloggingr&   Úoptparser   Úpip._internal.clir   Úpip._internal.cli.cmdoptionsr   Úpip._internal.cli.req_commandr   r   Úpip._internal.cli.status_codesr   Ú,pip._internal.operations.build.build_trackerr   Úpip._internal.utils.miscr	   r
   r   Úpip._internal.utils.temp_dirr   Ú	getLoggerr_   Úloggerr   r/   r/   r/   r0   Ú<module>   s    
