3
LY                 @   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mZ d d	lmZ d d
lmZ ejeZG dd deZdS )    )absolute_importN)CommandError)FormatControl)RequirementSet)RequirementCommand)
cmdoptions)
ensure_dirnormalize_path)BuildDirectory)check_path_ownerc                   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] [-e] <vcs project url> ...
      %prog [options] [-e] <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ddddddtjdd |jd	d
d
d dd |jdddd dd |jdddd dd |jdddd dd 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helpz
--platformplatformz`Only download wheels compatible with <platform>. Defaults to the platform of the running system.z--python-versionpython_versiona&  Only download wheels compatible with Python interpreter version <version>. If not specified, then the current system interpreter minor version is used. A major version (e.g. '2') can be specified to match all minor revs of that major version.  A minor version (e.g. '34') can also be specified.z--implementationimplementationzOnly download wheels compatible with Python implementation <implementation>, e.g. 'pp', 'jy', 'cp',  or 'ip'. If not specified, then the current interpreter implementation is used.  Use 'py' to force implementation-agnostic wheels.z--abiabizOnly download wheels compatible with Python abi <abi>, e.g. 'pypy_41'.  If not specified, then the current interpreter abi tag is used.  Generally you will need to specify --implementation, --platform, and --python-version when using this option.r   )superr   __init__cmd_opts
add_optionr   constraintseditablerequirements	build_dirno_depsglobal_options	no_binaryonly_binarysrcpreno_cleanrequire_hashesoscurdirmake_option_groupnon_deprecated_index_groupparserinsert_option_group)selfargskwr   
index_opts)	__class__ h/private/var/folders/7d/20zwc49s3kn54d3vgq8bd4640000gn/T/pip-build-an2lx5zf/pip/pip/commands/download.pyr   *   sb    zDownloadCommand.__init__c             C   s  d|_ |jr|jg}nd }t|j|j|j|jg}tt tdg}|rZ|j|krZt	d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|j|d}	t|	|j|jd|j||j|jd}
| j|
||||| jd  |
j s2d S |
j!| dj"d	d
 |
j#D }|rdtj$d| |jst|
j%  W d Q R X W d Q R X |
S )NTz:all:z--only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:) when restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation.)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.)delete)r   src_dirr   ignore_installedignore_dependenciesr6   isolatedr'    c             S   s   g | ]
}|j qS r3   )name).0reqr3   r3   r4   
<listcomp>   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)&r:   r   anyr   r   r   r   setformat_controlr   r(   pathabspathr9   r	   r   r   _build_session_build_package_finderr&   r   	cache_dirr   loggerwarningr
   r   r;   isolated_moder'   populate_requirement_setr>   has_requirementsprepare_filesjoinsuccessfully_downloadedinfocleanup_files)r.   r5   r/   r7   dist_restriction_setbinary_onlyr6   finderbuild_deleter   requirement_set
downloadedr3   r3   r4   run{   sx    






zDownloadCommand.run)
__name__
__module____qualname____doc__r>   usagesummaryr   rZ   __classcell__r3   r3   )r2   r4   r      s   Qr   )
__future__r   loggingr(   pip.exceptionsr   	pip.indexr   pip.reqr   pip.basecommandr   pipr   	pip.utilsr   r	   pip.utils.buildr
   pip.utils.filesystemr   	getLoggerr[   rJ   r   r3   r3   r3   r4   <module>   s   
