3
ÀÞL]ç  ã               @   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jeƒZG dd„ deƒZdS )é    )Úabsolute_importN)Ú
cmdoptions)ÚRequirementCommand)Úmake_target_python)ÚResolver)ÚRequirementPreparer)ÚRequirementSet)ÚRequirementTracker)Ú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          
      sN  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tjƒ ƒ |jtjƒ ƒ |jddddddtjdd� 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_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ÚargsÚkwr   Ú
index_opts)Ú	__class__© ú>/tmp/pip-build-69lrc5qx/pip/pip/_internal/commands/download.pyr   +   s<    
zDownloadCommand.__init__c          #   C   s~  d|_ g |_tj|ƒ tjj|jƒ|_t|j	ƒ|_	t
|j	ƒ | j|ƒ��,}t|ƒ}| j|||d�}|jpl|j }|jr–t|jƒ r–t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|jdd|j d
�}|j!|	ƒ dj"dd„ |	j#D ƒƒ}|�rLtj$d|ƒ |j�s\|	j%ƒ  W d Q R X W d Q R X W d Q R X |	S )NT)ÚoptionsÚsessionÚtarget_pythonzÝ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_isolationÚreq_trackerFzto-satisfy-only)ÚpreparerÚfinderr4   Úwheel_cacheÚuse_user_siteÚupgrade_strategyÚforce_reinstallÚignore_dependenciesZpy_version_infoÚignore_requires_pythonÚignore_installedÚisolatedú c             S   s   g | ]
}|j ‘qS r1   )Úname)Ú.0Úreqr1   r1   r2   ú
<listcomp>Ÿ   s    z'DownloadCommand.run.<locals>.<listcomp>zSuccessfully downloaded %s)&rD   Ú	editablesr   Zcheck_dist_restrictionr&   ÚpathÚabspathr8   r   r   r   Ú_build_sessionr   Ú_build_package_finderr#   r   Ú	cache_dirr
   ÚloggerÚwarningr	   r   r   r$   Úpopulate_requirement_setrG   r   r%   r:   r   rB   Úpython_versionÚisolated_modeÚresolveÚjoinÚsuccessfully_downloadedÚinfoÚcleanup_files)r,   r3   r-   r4   r5   r=   Úbuild_deleter;   Ú	directoryÚrequirement_setr<   ÚresolverÚ
downloadedr1   r1   r2   ÚrunS   sx    





&zDownloadCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__rG   ÚusageÚsummaryr   r`   Ú__classcell__r1   r1   )r0   r2   r      s   (r   )Ú
__future__r   Úloggingr&   Zpip._internal.clir   Zpip._internal.cli.base_commandr   Zpip._internal.cli.cmdoptionsr   Zpip._internal.legacy_resolver   Z pip._internal.operations.preparer   Zpip._internal.reqr   Zpip._internal.req.req_trackerr	   Zpip._internal.utils.filesystemr
   Zpip._internal.utils.miscr   r   Zpip._internal.utils.temp_dirr   Ú	getLoggerra   rQ   r   r1   r1   r1   r2   Ú<module>   s   
