B
    ãUvgl  ã               @   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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 e e¡ZG dd„ de	ƒZdS )é    )Úabsolute_importN)Ú
WheelCache)Ú
cmdoptions)ÚRequirementCommand)ÚCommandErrorÚPreviousBuildDirError)ÚRequirementPreparer)ÚRequirementSet)ÚRequirementTracker)ÚResolver)ÚTempDirectory)ÚWheelBuilderc                   s4   e Zd ZdZdZdZdZ‡ fdd„Zdd„ Z‡  Z	S )	ÚWheelCommanda´  
    Build Wheel archives for your requirements and dependencies.

    Wheel is a built-package format, and offers the advantage of not
    recompiling your software during every install. For more details, see the
    wheel docs: https://wheel.readthedocs.io/en/latest/

    Requirements: setuptools>=0.8, and wheel.

    'pip wheel' uses the bdist_wheel setuptools extension from the wheel
    package to build individual wheels.

    Úwheelzõ
      %prog [options] <requirement specifier> ...
      %prog [options] -r <requirements file> ...
      %prog [options] [-e] <vcs project url> ...
      %prog [options] [-e] <local project path> ...
      %prog [options] <archive url/path> ...z$Build wheels from your requirements.c                s^  t t| ƒj||Ž | j}|jddddtjdd | t ¡ ¡ | t 	¡ ¡ | t 
¡ ¡ |jddd	d
dd | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ |jddd
d	dd |jddddd | t ¡ ¡ | t ¡ ¡ t tj| j¡}| j d|¡ | j d|¡ d S )Nz-wz--wheel-dirÚ	wheel_dirÚdirzLBuild wheels into <dir>, where the default is the current working directory.)ÚdestÚmetavarÚdefaultÚhelpz--build-optionÚbuild_optionsÚoptionsÚappendz9Extra arguments to be supplied to 'setup.py bdist_wheel'.)r   r   Úactionr   z--global-optionÚglobal_optionszZExtra global options to be supplied to the setup.py call before the 'bdist_wheel' command.)r   r   r   r   z--preÚ
store_trueFzYInclude pre-release and development versions. By default, pip only finds stable versions.)r   r   r   r   )Úsuperr   Ú__init__Úcmd_optsÚ
add_optionÚosÚcurdirr   Ú	no_binaryÚonly_binaryÚprefer_binaryÚno_build_isolationÚconstraintsÚeditableÚrequirementsÚsrcÚignore_requires_pythonÚno_depsÚ	build_dirÚprogress_barÚno_cleanÚrequire_hashesÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚargsÚkwr   Ú
index_opts)Ú	__class__© ú=/tmp/pip-install-r_9ig3yj/pip/pip/_internal/commands/wheel.pyr   .   sX    zWheelCommand.__init__c             C   sÎ  t  |¡ |jg|j }|jr4t dd |¡¡ g }|jrJt	j
 |j¡|_t	j
 |j¡|_|  |¡^}|  ||¡}|jp~|j }t|j|jƒ}tƒ "}t|j|dd}	t|jd}
zÖy²|  |
||||| j|¡ t|	j
|jd |j|j|j|d}t||||ddd|j|jd	|j d
}| !|
¡ t"||||j#p6g |j$p@g |jd}|j%|
j& '¡ |d}|slt(dƒ‚W n t)k
rŒ   d	|_‚ Y nX W d |jsª|
 *¡  | +¡  X W d Q R X W d Q R X W d Q R X d S )NzIgnoring indexes: %sú,r   )ÚdeleteÚkind)r/   )r,   Úsrc_dirÚdownload_dirÚwheel_download_dirr-   Úbuild_isolationÚreq_trackerFzto-satisfy-onlyT)ÚpreparerÚfinderÚsessionÚwheel_cacheÚuse_user_siteÚupgrade_strategyÚforce_reinstallÚignore_dependenciesr*   Úignore_installedÚisolated)r   r   r.   )rE   z"Failed to build one or more wheels),r   Úcheck_install_build_globalÚ	index_urlÚextra_index_urlsÚno_indexÚloggerÚdebugÚjoinr,   r    ÚpathÚabspathr>   Ú_build_sessionÚ_build_package_finderr.   r   Ú	cache_dirÚformat_controlr
   r   r	   r/   Úpopulate_requirement_setÚnamer   r   r-   rA   r   rJ   r*   Úisolated_modeÚresolver   r   r   Úbuildr(   Úvaluesr   r   Úcleanup_filesÚcleanup)r4   r   r5   Ú
index_urlsrE   rD   Úbuild_deleterF   rB   Ú	directoryÚrequirement_setrC   ÚresolverÚwbÚwheels_built_successfullyr9   r9   r:   Úrunj   st    









zWheelCommand.run)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r[   ÚusageÚsummaryr   ri   Ú__classcell__r9   r9   )r8   r:   r      s   <r   )Ú
__future__r   Úloggingr    Úpip._internal.cacher   Zpip._internal.clir   Úpip._internal.cli.base_commandr   Úpip._internal.exceptionsr   r   Ú pip._internal.operations.preparer   Zpip._internal.reqr	   Úpip._internal.req.req_trackerr
   Úpip._internal.resolver   Úpip._internal.utils.temp_dirr   Úpip._internal.wheelr   Ú	getLoggerrj   rQ   r   r9   r9   r9   r:   Ú<module>   s   
