3
ûâde(  ã               @   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	 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 jeƒZG dd„ deƒZdS )é    N)ÚValues)ÚList)Ú
cmdoptions)Úmake_target_python)ÚRequirementCommandÚwith_cleanup)ÚSUCCESS)Úget_requirement_tracker)Ú
ensure_dirÚnormalize_pathÚwrite_output)ÚTempDirectoryc               @   s<   e Zd ZdZdZddœdd„Zeeee	 e
dœ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> ...N)Úreturnc          
   C   sL  | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtj	ƒ ƒ | j jtj
ƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jddddddtjdd� tj| j ƒ tjtj| jƒ}| jjd	|ƒ | j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Úno_depsÚglobal_optionsÚ	no_binaryÚonly_binaryZprefer_binaryÚsrcÚpreÚrequire_hashesZprogress_barZno_build_isolationZ
use_pep517Zno_use_pep517Úignore_requires_pythonÚosÚcurdirZadd_target_python_optionsÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r*   ú>/tmp/pip-build-red6nood/pip/pip/_internal/commands/download.pyÚadd_options%   s<    zDownloadCommand.add_options)ÚoptionsÚargsr   c          	   C   s*  d|_ g |_tj|ƒ t|jƒ|_t|jƒ | j|ƒ}t|ƒ}| j	||||j
d�}| jtƒ ƒ}t|j ddd�}| j||||ƒ}| j||||||jdd�}	| j|	|||j
|jd�}
| j|ƒ |
j|dd�}g }x@|jjƒ D ]2}|jd krÚ|jd k	söt‚|	j|ƒ |j|jƒ qÚW |�r&td	d
j|ƒƒ tS )NT)r-   ÚsessionÚtarget_pythonr!   Údownload)ÚdeleteÚkindZglobally_managedF)Ztemp_build_dirr-   Úreq_trackerr/   Úfinderr   Úuse_user_site)Úpreparerr5   r-   r!   Zpy_version_info)Zcheck_supported_wheelszSuccessfully downloaded %sú )Úignore_installedÚ	editablesr   Zcheck_dist_restrictionr   r   r
   Zget_default_sessionr   Ú_build_package_finderr!   Úenter_contextr	   r   Úno_cleanZget_requirementsZmake_requirement_preparerZmake_resolverÚpython_versionZtrace_basic_infoÚresolver   ÚvaluesÚsatisfied_byÚnameÚAssertionErrorZsave_linked_requirementÚappendr   Újoinr   )r(   r-   r.   r/   r0   r5   r4   Ú	directoryÚreqsr7   ÚresolverÚrequirement_setÚ
downloadedÚreqr*   r*   r+   ÚrunK   sV    







zDownloadCommand.run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager,   r   r   r   ÚstrÚintrL   r*   r*   r*   r+   r      s
   &r   )Úloggingr"   Úoptparser   Útypingr   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   Ú	getLoggerrM   Úloggerr   r*   r*   r*   r+   Ú<module>   s   
