
(°h7  ã               @   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 j e ƒ Z Gd 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   sÓ  |  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 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ÚdestÚdownload_dirÚmetavarÚdirÚdefaultÚhelpzDownload packages into <dir>.r   )Úcmd_optsÚ
add_optionr   ÚconstraintsÚrequirementsÚ	build_dirÚno_depsÚglobal_optionsÚ	no_binaryÚonly_binaryZprefer_binaryÚsrcÚpreÚrequire_hashesZprogress_barZno_build_isolationZ
use_pep517Zno_use_pep517ÚosÚcurdirZadd_target_python_optionsÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r+   ú>/tmp/pip-build-kmztzv_d/pip/pip/_internal/commands/download.pyÚadd_options*   s6    		zDownloadCommand.add_optionsc             C   sÃ  d | _  g  | _ t j | ƒ t | j ƒ | _ t | j ƒ |  j | ƒ } t | ƒ } |  j	 d | d | d | ƒ } |  j
 t ƒ  ƒ } t d | j d d d d ƒ } |  j | | | | ƒ } |  j d	 | d | d
 | d | d | d | j d d ƒ }	 |  j d |	 d | d | d | j ƒ }
 |  j | ƒ |
 j | d d ƒ} g  } xX | j j ƒ  D]G } | j d  k rX| j d  k	 s‚t ‚ |	 j | ƒ | j | j ƒ qXW| r¿t d d j | ƒ ƒ t S)NTÚoptionsÚsessionÚtarget_pythonÚdeleteÚkindÚdownloadZglobally_managedZtemp_build_dirÚreq_trackerÚfinderr   Úuse_user_siteFÚpreparerZpy_version_infoZcheck_supported_wheelszSuccessfully downloaded %sú )Úignore_installedÚ	editablesr   Zcheck_dist_restrictionr
   r   r	   Zget_default_sessionr   Ú_build_package_finderÚ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.   Úargsr/   r0   r5   r4   Ú	directoryÚreqsr7   ÚresolverÚrequirement_setÚ
downloadedÚreqr+   r+   r,   ÚrunN   sT    				
					zDownloadCommand.runN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager-   r   rM   r+   r+   r+   r,   r      s   $r   )Ú
__future__r   Úloggingr#   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   Zpip._internal.utils.typingr   Úoptparser   Ztypingr   Ú	getLoggerrN   Úloggerr   r+   r+   r+   r,   Ú<module>   s   