B š•ReI ã @ sì d Z ddlZddlZddlZddlmZmZ ddlm Z m Z ddlZddl mZ ddlZddlZddlmZ ddlZddlmZ dd lmZ dd lmZ e e¡Zdd„ Zd d„ Zdd„ Zddd„Z dddddœZ!dd„ Z"edkrèe ƒ dS )zHCheck a project and backend by attempting to build using PEP 517 hooks. é N)ÚisfileÚjoin)ÚTomlDecodeErrorÚload)ÚCalledProcessError)Úmkdtempé )Úenable_colourful_output)ÚBuildEnvironment)ÚPep517HookCallerc C s t ƒ Ž}y| |¡ t d¡ W n tk r@ t d¡ dS X y| i ¡}t d|¡ W n" tk r~ tjddd dS X y| |¡ t d¡ W n tk r¶ t d ¡ dS X tƒ }t d |¡ zºy| |i ¡}t d|¡ W n$ tk r tjddd dS X | d ¡s*t d|¡ dS t||ƒ}t|ƒrLt d|¡ nt d|¡ dS t |¡rtt d¡ nt d¡ dS W d t |¡ X dS Q R X d S )Nz#Installed static build dependenciesz+Failed to install static build dependenciesFzGot build requires: %sz'Failure in get_requires_for_build_sdistT)Úexc_infoz$Installed dynamic build dependenciesz,Failed to install dynamic build dependencieszTrying to build sdist in %szbuild_sdist returned %rzFailure in build_sdistz.tar.gzz*Filename %s doesn't have .tar.gz extensionzOutput file %s existszOutput file %s does not existzOutput file is a tar filezOutput file is not a tar file)r Úpip_installÚlogÚinfor ÚerrorÚget_requires_for_build_sdistÚ Exceptionr Úbuild_sdistÚendswithÚpjoinr ÚtarfileÚ is_tarfileÚshutilÚrmtree)ÚhooksÚbuild_sys_requiresÚenvÚreqsÚtdÚfilenameÚpath© r! ú‡/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_vendor/pep517/check.pyÚcheck_build_sdist sV r# c C s t ƒ Ž}y| |¡ t d¡ W n tk r@ t d¡ dS X y| i ¡}t d|¡ W n" tk r~ tjddd dS X y| |¡ t d¡ W n tk r¶ t d ¡ dS X tƒ }t d |¡ zºy| |i ¡}t d|¡ W n$ tk r tjddd dS X | d ¡s*t d|¡ dS t||ƒ}t|ƒrLt d|¡ nt d|¡ dS t |¡rtt d¡ nt d¡ dS W d t |¡ X dS Q R X d S )Nz#Installed static build dependenciesz+Failed to install static build dependenciesFzGot build requires: %sz'Failure in get_requires_for_build_sdistT)r z$Installed dynamic build dependenciesz,Failed to install dynamic build dependencieszTrying to build wheel in %szbuild_wheel returned %rzFailure in build_wheelz.whlz'Filename %s doesn't have .whl extensionzOutput file %s existszOutput file %s does not existzOutput file is a zip filezOutput file is not a zip file)r r r r r r Úget_requires_for_build_wheelr r Úbuild_wheelr r r ÚzipfileÚ is_zipfiler r )r r r r r r r r! r! r" Úcheck_build_wheelO sT r( c C sà t | dƒ}t|ƒrt d¡ nt d¡ dS yLt|ƒ}t|ƒ}W d Q R X |d }|d }|d }| d¡}t d ¡ W n& tt fk rž tjd dd dS X t | ||ƒ}t||ƒ} t||ƒ} | sÎt d ¡ | sÜt d¡ | S )Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFzbuild-systemÚrequiresz build-backendzbackend-pathzLoaded pyproject.tomlzInvalid pyproject.tomlT)r z%Sdist checks failed; scroll up to seezWheel checks failed)r r r r r ÚopenÚ toml_loadÚgetr ÚKeyErrorr r# r( Úwarning)Ú source_dirÚ pyprojectÚfZpyproject_dataZbuildsysr) ÚbackendÚbackend_pathr Zsdist_okZwheel_okr! r! r" Úcheck‡ s0 r4 c C s` t ¡ }|jddd | | ¡}tƒ t|jƒ}|rDttddƒƒ nttddƒƒ t d¡ d S ) Nr/ z%A directory containing pyproject.toml)Úhelpz Checks passedÚgreenz Checks failedÚredr )ÚargparseÚArgumentParserÚadd_argumentÚ parse_argsr r4 r/ ÚprintÚansiÚsysÚexit)ÚargvZapÚargsÚokr! r! r" Úmain© s rC z[0mz[1mz[31mz[32m)ÚresetZboldr7 r6 c C s8 t jdkr,tj ¡ r,t| t| ƒ td S t| ƒS d S )NÚntrD )ÚosÚnamer> ÚstdoutÚisattyÚ ansi_codesÚstr)ÚsÚattrr! r! r" r= à s r= Ú__main__)N)#Ú__doc__r8 ÚloggingrF Úos.pathr r r Zpip._vendor.tomlr r r+ r Ú subprocessr r> r Útempfiler r&