3
[r                 @   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	 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 ejeZG dd deZdS )    )absolute_importN)
cmdoptions)RequirementCommand)RequirementPreparer)RequirementSet)RequirementTracker)Resolver)check_path_owner)
ensure_dirnormalize_path)TempDirectoryc                   s4   e Zd ZdZdZdZdZ fddZdd Z  Z	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.
    downloada  
      %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> ...zDownload packages.c          
      s`  t t| j|| | j}|jtj  |jtj  |jtj  |jtj	  |jtj
  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jtj  |jddddddtjdd |jtj  |jtj  |jtj  |jtj  tjtj| j}| jjd	| | jjd	| d S )
Nz-dz--destz--destination-dirz--destination-directorydownload_dirdirzDownload packages into <dir>.)destmetavardefaulthelpr   )superr   __init__cmd_opts
add_optionr   constraintsrequirements	build_dirno_depsglobal_options	no_binaryonly_binaryZprefer_binarysrcpreno_cleanrequire_hashesprogress_barno_build_isolationoscurdirplatformpython_versionimplementationabimake_option_groupindex_groupparserinsert_option_group)selfargskwr   
index_opts)	__class__ @/tmp/pip-install-65viz3iy/pip/pip/_internal/commands/download.pyr   *   s>    zDownloadCommand.__init__c          "   C   s  d|_ g |_|jr|jg}nd }tj| tjj|j|_t	|j
|_
t|j
 | j|,}| j|||j||j|jd}|jp|j }|jrt|j rtjd|j d |_t }t|j|dd}t|jd}	| j|	||||| jd  t|j|j|j
d |j|j|d}
t |
||d dd	d|j!dd|j"d
}|j#|	 dj$dd |	j%D }|r`tj&d| |jsp|	j'  W d Q R X W d Q R X W d Q R X |	S )NT)optionssessionr(   python_versionsr+   r*   zThe directory '%s' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.r   )deletekind)r#   )r   src_dirr   wheel_download_dirr$   build_isolationreq_trackerFzto-satisfy-only)preparerfinderr8   wheel_cacheuse_user_siteupgrade_strategyforce_reinstallignore_dependenciesignore_requires_pythonignore_installedisolated c             S   s   g | ]
}|j qS r5   )name).0reqr5   r5   r6   
<listcomp>   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)(rH   	editablesr)   r   Zcheck_dist_restrictionr&   pathabspathr<   r   r   r
   _build_session_build_package_finderr(   r+   r*   r"   r   	cache_dirr	   loggerwarningr   r   r   r#   populate_requirement_setrK   r   r$   r>   r   rF   isolated_moderesolvejoinsuccessfully_downloadedinfocleanup_files)r0   r7   r1   r9   r8   rA   build_deleter?   	directoryrequirement_setr@   resolver
downloadedr5   r5   r6   runS   s    







&zDownloadCommand.run)
__name__
__module____qualname____doc__rK   usagesummaryr   rc   __classcell__r5   r5   )r4   r6   r      s   )r   )
__future__r   loggingr&   Zpip._internal.clir   Zpip._internal.cli.base_commandr    pip._internal.operations.preparer   Zpip._internal.reqr   Zpip._internal.req.req_trackerr   pip._internal.resolver   pip._internal.utils.filesystemr	   pip._internal.utils.miscr
   r   pip._internal.utils.temp_dirr   	getLoggerrd   rU   r   r5   r5   r5   r6   <module>   s   
