o
    àej2#  ã                   @  sr  d Z ddlmZ 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mZ ddlmZmZ ddlmZ dd	lmZ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$ ddl%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ e ,e-¡Z.e /dej0¡Z1e2e3e" e3e" f Z4d5dd„Z5d6dd„Z6d7d"d#„Z7d8d&d'„Z8d9d,d-„Z9d:d.d/„Z:d;d3d4„Z;dS )<z:Orchestrator for building wheels from InstallRequirements.é    )ÚannotationsN)ÚIterable)ÚTemporaryDirectory)Úcanonicalize_nameÚcanonicalize_version)ÚInvalidVersionÚVersion)Ú
WheelCache)ÚInvalidWheelFilenameÚUnsupportedWheel)ÚFilesystemWheelÚget_wheel_distribution)ÚLink)ÚWheel)Úbuild_wheel_pep517)Úbuild_wheel_editable)ÚInstallRequirement)Ú
indent_log)Ú
ensure_dirÚ	hash_file)Úpath_to_url)Úvcsz([a-z0-9_.]+)-([a-z0-9_.!+-]+)ÚsÚstrÚreturnÚboolc                 C  s   t t | ¡ƒS )zjDetermine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    )r   Ú_egg_info_reÚsearch)r   © r   ú[/var/www/html/choboyeo/PHP/venv/lib/python3.10/site-packages/pip/_internal/wheel_builder.pyÚ_contains_egg_info"   s   r    Úreqr   úbool | Nonec                 C  sŠ   | j s| jsdS | jr1| jjr1| j rJ ‚| jsJ ‚t | jj¡}|s$J ‚| | jj| j¡r/dS dS | js6J ‚| j 	¡ \}}t
|ƒrCdS dS )z‹
    Return whether a built InstallRequirement can be stored in the persistent
    wheel cache, assuming the wheel cache is available.
    FT)ÚeditableÚ
source_dirÚlinkÚis_vcsr   Úget_backend_for_schemeÚschemeÚis_immutable_rev_checkoutÚurlÚsplitextr    )r!   Úvcs_backendÚbaseÚextr   r   r   Ú_should_cache*   s   


r/   Úwheel_cacher	   c                 C  s@   t |jƒ}| js
J ‚|rt| ƒr| | j¡}|S | | j¡}|S )zdReturn the persistent or temporary cache directory where the built
    wheel need to be stored.
    )r   Ú	cache_dirr%   r/   Úget_path_for_linkÚget_ephem_path_for_link)r!   r0   Úcache_availabler1   r   r   r   Ú_get_cache_dirI   s   

ÿr5   Ú
wheel_pathÚNonec           	      C  sò   t | jpdƒ}ttj |¡ƒ}|j|krtd|›d|j›�ƒ‚tt|ƒ|ƒ}t	|j
ƒ}t|ƒt|j
ƒkr?td|›d|j
›�ƒ‚|j}|d u rJtdƒ‚zt|ƒ}W n ty`   d|› �}t|ƒ‚w |tdƒkrut|j
tƒswtd|›d�ƒ‚d S d S )	NÚ z)Wheel has unexpected file name: expected z, got zMissing Metadata-VersionzInvalid Metadata-Version: z1.2z+Metadata 1.2 mandates PEP 440 version, but z is not)r   Únamer   ÚosÚpathÚbasenamer
   r   r   r   Úversionr   Úmetadata_versionr   r   r   Ú
isinstance)	r!   r6   Úcanonical_nameÚwÚdistÚdist_verstrÚmetadata_version_valuer>   Úmsgr   r   r   Ú_verify_oneY   s<   
ÿÿ
ÿÿ
þ
ÿÿrF   Ú
output_dirÚverifyr#   ú
str | Nonec              
   C  sÞ   |rdnd}zt |ƒ W n ty( } zt d|| j|¡ W Y d}~dS d}~ww | j� t| ||ƒ}W d  ƒ n1 s=w   Y  |rm|rmzt| |ƒ W |S  tt	fyl } zt d|| j|¡ W Y d}~dS d}~ww |S )zaBuild one wheel.

    :return: The filename of the built wheel, or None if the build failed.
    r#   ÚwheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s)
r   ÚOSErrorÚloggerÚwarningr9   Ú	build_envÚ_build_one_inside_envrF   r
   r   )r!   rG   rH   r#   ÚartifactÚer6   r   r   r   Ú
_build_onev   s4   
ü€ù
ÿý€þrR   c           
      C  s*  t |d��†}| jsJ ‚| jsJ ‚| jsJ ‚|r#t| j| j| j|d�}nt| j| j| j|d�}|d ur‚tj |¡}tj 	||¡}z(t
|ƒ\}}t ||¡ t d| j||| ¡ ¡ t d|¡ |W W  d   ƒ S  ty� }	 zt d| j|	¡ W Y d }	~	nd }	~	ww 	 W d   ƒ d S 1 sŽw   Y  d S )N)Údir)r9   ÚbackendÚmetadata_directoryÚwheel_directoryz3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)r   r9   rU   Úpep517_backendr   r   r:   r;   r<   Újoinr   ÚreplacerL   ÚinfoÚ	hexdigestÚ	ExceptionrM   )
r!   rG   r#   rV   r6   Ú
wheel_nameÚ	dest_pathÚ
wheel_hashÚlengthrQ   r   r   r   rO   ˜   sV   


üüûÛ&ý€ÿ$ÔrO   ÚrequirementsúIterable[InstallRequirement]ÚBuildResultc                 C  s*  | sg g fS t  dd dd„ | D ƒ¡¡ tƒ �R g g }}| D ]B}|js&J ‚t||ƒ}t||||jo4|jƒ}|r\|j	durD| 
||j	¡ tt|ƒƒ|_|jj|_|jjsVJ ‚| |¡ q| |¡ qW d  ƒ n1 slw   Y  |r�t  dd dd	„ |D ƒ¡¡ |r‘t  d
d dd	„ |D ƒ¡¡ ||fS )z˜Build wheels.

    :return: The list of InstallRequirement that succeeded to build and
        the list of InstallRequirement that failed to build.
    z*Building wheels for collected packages: %sz, c                 s  s   � | ]}|j V  qd S )N©r9   ©Ú.0r!   r   r   r   Ú	<genexpr>Ü   s   € zbuild.<locals>.<genexpr>NzSuccessfully built %sú c                 S  ó   g | ]}|j ‘qS r   rd   re   r   r   r   Ú
<listcomp>ý   ó    zbuild.<locals>.<listcomp>zFailed to build %sc                 S  ri   r   rd   re   r   r   r   rj     rk   )rL   rZ   rX   r   r9   r5   rR   r#   Úpermit_editable_wheelsÚdownload_infoÚrecord_download_originr   r   r%   Ú	file_pathÚlocal_file_pathÚis_wheelÚappend)ra   r0   rH   Úbuild_successesÚbuild_failuresr!   r1   Ú
wheel_filer   r   r   ÚbuildÌ   sL   
þ



ü

êþþþrv   )r   r   r   r   )r!   r   r   r"   )r!   r   r0   r	   r   r   )r!   r   r6   r   r   r7   )
r!   r   rG   r   rH   r   r#   r   r   rI   )r!   r   rG   r   r#   r   r   rI   )ra   rb   r0   r	   rH   r   r   rc   )<Ú__doc__Ú
__future__r   ÚloggingÚos.pathr:   ÚreÚcollections.abcr   Útempfiler   Úpip._vendor.packaging.utilsr   r   Úpip._vendor.packaging.versionr   r   Úpip._internal.cacher	   Úpip._internal.exceptionsr
   r   Úpip._internal.metadatar   r   Úpip._internal.models.linkr   Úpip._internal.models.wheelr   Ú$pip._internal.operations.build.wheelr   Ú-pip._internal.operations.build.wheel_editabler   Úpip._internal.req.req_installr   Úpip._internal.utils.loggingr   Úpip._internal.utils.miscr   r   Úpip._internal.utils.urlsr   Úpip._internal.vcsr   Ú	getLoggerÚ__name__rL   ÚcompileÚ
IGNORECASEr   ÚtupleÚlistrc   r    r/   r5   rF   rR   rO   rv   r   r   r   r   Ú<module>   s>    






"4