B
    =)H[„#  ã               @   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 d dlmZmZ d dlmZ e e¡ZG dd„ deƒZdS )é    )Úabsolute_importN)Ú
cmdoptions)ÚRequirementCommand)ÚCommandError)ÚFormatControl)ÚRequirementPreparer)ÚRequirementSet)Ú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          
      sj  t t| ƒj||Ž | j}| t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t 	¡ ¡ | t 
¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ |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 tj| j¡}| j d|¡ | 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ÚimplementationzçOnly 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ÚabizöOnly 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ÚrequirementsÚ	build_dirÚno_depsÚglobal_optionsÚ	no_binaryÚonly_binaryÚsrcÚpreÚno_cleanÚrequire_hashesÚprogress_barÚno_build_isolationÚosÚcurdirÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚargsÚkwr   Ú
index_opts)Ú	__class__© ú`C:\Users\HIRONO~1\AppData\Local\Temp\pip-install-qz7kpjmn\pip\pip\_internal\commands\download.pyr   +   sd    zDownloadCommand.__init__c             C   sº  d|_ g |_|jr|jg}nd }t|j|j|j|jgƒ}ttƒ dhƒ}|j	|koV|j
 }|rh|rhtdƒ‚tj |j¡|_t|jƒ|_t|jƒ |  |¡��}| j|||j||j|jd�}|jpÂ|j }	|jrêt|jƒsêt d|j¡ d |_t|j|	dd��¬}
t|jd�}|  |||||| jd ¡ t |
j|j|jd |j!|j"d	�}t#|||d d
dd
|j
d
d|j$d�}| %|¡ d &dd„ |j'D ƒ¡}|�r’t (d|¡ |j�s¢| )¡  W d Q R X W d Q R X |S )NTz:all:zòWhen restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).)ÚoptionsÚsessionr   Úpython_versionsr   r   zÝThe 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_isolationFzto-satisfy-only)ÚpreparerÚfinderr9   Úwheel_cacheÚuse_user_siteÚupgrade_strategyÚforce_reinstallÚignore_dependenciesÚignore_requires_pythonÚignore_installedÚisolatedú c             S   s   g | ]
}|j ‘qS r6   )Úname)Ú.0Úreqr6   r6   r7   ú
<listcomp>à   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)*rH   Ú	editablesr   Úanyr   r   r   r   ÚsetÚformat_controlrF   r   r+   ÚpathÚabspathr=   r   r   r   Ú_build_sessionÚ_build_package_finderr'   r    Ú	cache_dirr
   ÚloggerÚwarningr   r   r(   Úpopulate_requirement_setrK   r   r)   r?   r	   Úisolated_modeÚresolveÚjoinÚsuccessfully_downloadedÚinfoÚcleanup_files)r1   r8   r2   r:   Údist_restriction_setÚbinary_onlyÚno_sdist_dependenciesr9   rA   Úbuild_deleteÚ	directoryÚrequirement_setr@   ÚresolverÚ
downloadedr6   r6   r7   Úrun}   s’    








zDownloadCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__rK   ÚusageÚsummaryr   ri   Ú__classcell__r6   r6   )r5   r7   r      s   Rr   )Ú
__future__r   Úloggingr+   Úpip._internalr   Úpip._internal.basecommandr   Úpip._internal.exceptionsr   Úpip._internal.indexr   Ú pip._internal.operations.preparer   Zpip._internal.reqr   Úpip._internal.resolver	   Úpip._internal.utils.filesystemr
   Úpip._internal.utils.miscr   r   Úpip._internal.utils.temp_dirr   Ú	getLoggerrj   rX   r   r6   r6   r6   r7   Ú<module>   s   
