3
ûâde  ã               @   sÒ   d dl 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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mZ e jeƒZ G dd„ deƒZ!dS )é    N)ÚValues)ÚList)Ú
WheelCache)Ú
cmdoptions)ÚRequirementCommandÚwith_cleanup)ÚSUCCESS)ÚCommandError)ÚInstallRequirement)Úget_requirement_tracker)Ú
ensure_dirÚnormalize_path)ÚTempDirectory)ÚbuildÚshould_build_for_wheel_commandc               @   s<   e Zd ZdZdZddœdd„Zeeee	 e
dœdd	„ƒZd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.

    zõ
      %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> ...N)Úreturnc             C   sv  | j jddddtjdd� | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtj	ƒ ƒ | j jtj
ƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jtjƒ ƒ | j jddd	d
dd� | j jtjƒ ƒ | j jtjƒ ƒ | j jdd	d
dd� | j jtjƒ ƒ tjtj| jƒ}| jjd|ƒ | jjd| j ƒ d S )Nz-wz--wheel-dirÚ	wheel_dirÚdirzLBuild wheels into <dir>, where the default is the current working directory.)ÚdestÚmetavarÚdefaultÚhelpz--no-verifyÚ	no_verifyÚ
store_trueFz%Don't verify if built wheel is valid.)r   Úactionr   r   z--prezYInclude pre-release and development versions. By default, pip only finds stable versions.)r   r   r   r   )Úcmd_optsÚ
add_optionÚosÚcurdirr   Ú	no_binaryÚonly_binaryZprefer_binaryZno_build_isolationÚ
use_pep517Zno_use_pep517ÚconstraintsÚeditableÚrequirementsÚsrcÚignore_requires_pythonÚno_depsZprogress_barÚbuild_optionsÚglobal_optionsÚrequire_hashesÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r2   ú;/tmp/pip-build-red6nood/pip/pip/_internal/commands/wheel.pyÚadd_options+   sN    zWheelCommand.add_options)ÚoptionsÚargsr   c             C   sÄ  t j|ƒ | j|ƒ}| j||ƒ}t|j|jƒ}t|jƒ|_t	|jƒ | j
tƒ ƒ}t|j ddd�}| j||||ƒ}| j||||||jdd�}	| j|	||||j|jd�}
| j|ƒ |
j|dd�}g }x6|jjƒ D ](}|jrä|	j|ƒ qÎt|ƒrÎ|j|ƒ qÎW t|||j |j�pg |j�pg d�\}}x„|D ]|}|j�r@|jj�sDt ‚|j!�sPt ‚yt"j#|j!|jƒ W n> t$k
�r¢ } z t%j&d	|j'|ƒ |j|ƒ W Y d d }~X nX �q*W t(|ƒd
k�rÀt)dƒ‚t*S )NÚwheelT)ÚdeleteÚkindZglobally_managedF)Ztemp_build_dirr5   Úreq_trackerÚsessionÚfinderÚdownload_dirÚuse_user_site)Úpreparerr<   r5   Úwheel_cacher'   r"   )Zcheck_supported_wheels)r@   Úverifyr)   r*   z Building wheel for %s failed: %sr   z"Failed to build one or more wheels)+r   Úcheck_install_build_globalZget_default_sessionÚ_build_package_finderr   Ú	cache_dirÚformat_controlr   r   r   Úenter_contextr   r   Úno_cleanZget_requirementsZmake_requirement_preparerZmake_resolverr'   r"   Ztrace_basic_infoÚresolver%   ÚvaluesÚis_wheelZsave_linked_requirementr   Úappendr   r   r)   r*   ÚlinkÚAssertionErrorZlocal_file_pathÚshutilÚcopyÚOSErrorÚloggerÚwarningÚnameÚlenr	   r   )r0   r5   r6   r;   r<   r@   r:   Ú	directoryÚreqsr?   ÚresolverÚrequirement_setZreqs_to_buildÚreqZbuild_successesZbuild_failuresÚer2   r2   r3   Úrune   sn    






"zWheelCommand.run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager4   r   r   r   ÚstrÚintr[   r2   r2   r2   r3   r      s
   :r   )"Úloggingr   rN   Úoptparser   Útypingr   Zpip._internal.cacher   Zpip._internal.clir   Zpip._internal.cli.req_commandr   r   Zpip._internal.cli.status_codesr   Zpip._internal.exceptionsr	   Zpip._internal.req.req_installr
   Zpip._internal.req.req_trackerr   Zpip._internal.utils.miscr   r   Zpip._internal.utils.temp_dirr   Zpip._internal.wheel_builderr   r   Ú	getLoggerr\   rQ   r   r2   r2   r2   r3   Ú<module>   s    
