o
    ¾Ôi}  ã                   @   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
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  e¡ZG dd„ de
ƒZdS )é    N)ÚValues)Ú
WheelCache)Ú
cmdoptions)ÚRequirementCommandÚwith_cleanup)ÚSUCCESS)ÚCommandError)Úget_build_tracker)ÚInstallRequirement)Ú
ensure_dirÚnormalize_path)ÚTempDirectory)Úbuildc                   @   s<   e Zd ZdZdZddd„Zededee	 de
f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/

    'pip wheel' uses the build system interface as described here:
    https://pip.pypa.io/en/stable/reference/build-system/

    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> ...ÚreturnNc                 C   sv  | j jddddtjdd | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t 	¡ ¡ | j  t 
¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j jddd	d
dd | j  t ¡ ¡ | j jdd	d
dd | j  t ¡ ¡ t tj| j¡}| j d|¡ | 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   )Zcmd_optsZ
add_optionÚosÚcurdirr   Z	no_binaryZonly_binaryZprefer_binaryZno_build_isolationZ
use_pep517Zcheck_build_depsZconstraintsZbuild_constraintsZeditableÚrequirementsÚsrcÚignore_requires_pythonZno_depsZprogress_barZconfig_settingsZrequire_hashesZmake_option_groupZindex_groupÚparserZinsert_option_group)ÚselfZ
index_opts© r!   ú<lib/python3.10/site-packages/pip/_internal/commands/wheel.pyÚadd_options*   sV   ùûû
þzWheelCommand.add_optionsÚoptionsÚargsc                 C   s   t  |¡ |  |¡}|  ||¡}t|jƒ|_t|jƒ |  tƒ ¡}t	|j
 ddd}|  ||||¡}t|jƒ}| j||||||jd| jd}	| j|	||||jd}
|  |¡ |
j|dd}|	 |j ¡ ¡ g }|j ¡ D ]}|jrw|	 |¡ ql| |¡ qlt|||j d\}}|D ]9}|jr“|jjs•J ‚|jsšJ ‚z
t |j|j¡ W qŠ t yÃ } zt! "d	|j#|¡ | |¡ W Y d }~qŠd }~ww t$|ƒd
krÎt%dƒ‚t&S )NZwheelT)ÚdeleteÚkindZglobally_managedF)Ztemp_build_dirr$   Úbuild_trackerÚsessionÚfinderZdownload_dirZuse_user_siteÚ	verbosity)Úpreparerr*   r$   Úwheel_cacher   )Zcheck_supported_wheels)r-   Zverifyz Building wheel for %s failed: %sr   z"Failed to build one or more wheels)'r   Zcheck_build_constraintsZget_default_sessionZ_build_package_finderr   r   r   Úenter_contextr	   r   Zno_cleanZget_requirementsr   Z	cache_dirZmake_requirement_preparerr+   Zmake_resolverr   Ztrace_basic_infoÚresolveZ prepare_linked_requirements_morer   ÚvaluesZis_wheelZsave_linked_requirementÚappendr   r   ÚlinkZlocal_file_pathÚshutilÚcopyÚOSErrorÚloggerZwarningÚnameÚlenr   r   )r    r$   r%   r)   r*   r(   Z	directoryZreqsr-   r,   ZresolverZrequirement_setZreqs_to_buildZreqZbuild_successesZbuild_failuresÚer!   r!   r"   Úrunc   sx   


ý
øû

ý
ý€úzWheelCommand.run)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager#   r   r   ÚlistÚstrÚintr:   r!   r!   r!   r"   r      s    
9 r   )Zloggingr   r3   Zoptparser   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.operations.build.build_trackerr	   Zpip._internal.req.req_installr
   Zpip._internal.utils.miscr   r   Zpip._internal.utils.temp_dirr   Zpip._internal.wheel_builderr   Z	getLoggerr;   r6   r   r!   r!   r!   r"   Ú<module>   s     
