o
    Ëý°jÄ  ã                   @   sø   d Z ddlZddlZddlZddlZddlmZmZ ddl	Z	ddl
mZ ddlZddlZddlmZ ddl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dd„ Zdd„ Zdd„ Zddd„Z dddddœZ!dd„ Z"edkrze ƒ  dS dS )zHCheck a project and backend by attempting to build using PEP 517 hooks.
é    N)ÚisfileÚjoin)ÚCalledProcessError)Úmkdtempé   )Úenable_colourful_output)ÚTOMLDecodeErrorÚ	toml_load)ÚBuildEnvironment)ÚPep517HookCallerc              
   C   ó@  t ƒ ��}z| |¡ t d¡ W n ty&   t d¡ Y W d   ƒ dS w z|  i ¡}t d|¡ W n tyK   tjddd� Y W d   ƒ dS w z| |¡ t d¡ W n tym   t d	¡ Y W d   ƒ dS w tƒ }t d
|¡ zŽz|  	|i ¡}t d|¡ W n ty£   tjddd� Y W t
 |¡ W d   ƒ dS w | d¡s½t d|¡ W t
 |¡ W d   ƒ dS t||ƒ}t|ƒrÍt d|¡ nt d|¡ W t
 |¡ W d   ƒ dS t |¡rìt d¡ nt d¡ W t
 |¡ W d   ƒ dS W t
 |¡ nt
 |¡ w 	 W d   ƒ dS 1 �sw   Y  d S )Nú#Installed static build dependenciesú+Failed to install static build dependenciesFúGot build requires: %sú'Failure in get_requires_for_build_sdistT©Úexc_infoú$Installed dynamic build dependenciesú,Failed to install dynamic build dependencieszTrying to build sdist in %szbuild_sdist returned %rzFailure in build_sdistz.tar.gzz*Filename %s doesn't have .tar.gz extensionúOutput file %s existsúOutput file %s does not existzOutput file is a tar filezOutput file is not a tar file)r
   Úpip_installÚlogÚinfor   ÚerrorÚget_requires_for_build_sdistÚ	Exceptionr   Úbuild_sdistÚshutilÚrmtreeÚendswithÚpjoinr   ÚtarfileÚ
is_tarfile©ÚhooksÚbuild_sys_requiresÚenvÚreqsÚtdÚfilenameÚpath© r,   ú‹/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/pep517/check.pyÚcheck_build_sdist   sz   


ú
ó

ì
Í
ÿ
Í
%
	Í
,

Í-&Ër.   c              
   C   r   )Nr   r   Fr   r   Tr   r   r   zTrying to build wheel in %szbuild_wheel returned %rzFailure in build_wheelz.whlz'Filename %s doesn't have .whl extensionr   r   zOutput file is a zip filezOutput file is not a zip file)r
   r   r   r   r   r   Úget_requires_for_build_wheelr   r   Úbuild_wheelr   r   r    r!   r   ÚzipfileÚ
is_zipfiler$   r,   r,   r-   Úcheck_build_wheelP   sv   


ú
ó

ì
Î

Î
$
	Î
+

Î,&Ìr3   c              	   C   sø   t | dƒ}t|ƒrt d¡ nt d¡ dS z2t |d¡�}t|ƒ}W d   ƒ n1 s,w   Y  |d }|d }|d }| d	¡}t d
¡ W n t	t
fy[   tjddd� Y dS w t| ||ƒ}t||ƒ}	t||ƒ}
|	sst d¡ |
szt d¡ |	S )Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFÚrbzbuild-systemÚrequireszbuild-backendzbackend-pathzLoaded pyproject.tomlzInvalid pyproject.tomlTr   z%Sdist checks failed; scroll up to seezWheel checks failed)r!   r   r   r   r   ÚioÚopenr	   Úgetr   ÚKeyErrorr   r.   r3   Úwarning)Ú
source_dirÚ	pyprojectÚfÚpyproject_dataÚbuildsysr5   ÚbackendÚbackend_pathr%   Úsdist_okÚwheel_okr,   r,   r-   Úcheckˆ   s4   


ÿ
þ



rD   c                 C   sl   t  d¡ t ¡ }|jddd� | | ¡}tƒ  t|jƒ}|r(t	t
ddƒƒ d S t	t
ddƒƒ t d	¡ d S )
NzQpep517.check is deprecated. Consider switching to https://pypi.org/project/build/r;   z%A directory containing pyproject.toml)ÚhelpzChecks passedÚgreenzChecks failedÚredr   )r   r:   ÚargparseÚArgumentParserÚadd_argumentÚ
parse_argsr   rD   r;   ÚprintÚansiÚsysÚexit)ÚargvÚapÚargsÚokr,   r,   r-   Úmainª   s   
þ

rT   z[0mz[1mz[31mz[32m)ÚresetÚboldrG   rF   c                 C   s4   t jdkrtj ¡ rt| t| ƒ td  S t| ƒS )NÚntrU   )ÚosÚnamerN   ÚstdoutÚisattyÚ
ansi_codesÚstr)ÚsÚattrr,   r,   r-   rM   Ç   s   rM   Ú__main__)N)#Ú__doc__rH   r6   ÚloggingrX   Úos.pathr   r   r!   r   Ú
subprocessr   rN   r"   Útempfiler   r1   Úcolorlogr   Úcompatr   r	   Úenvbuildr
   Úwrappersr   Ú	getLoggerÚ__name__r   r.   r3   rD   rT   r\   rM   r,   r,   r,   r-   Ú<module>   s<    
98
"ü
ÿ