o 7]h@sdZddlZddlZddlZddlZddlmZmZddl Z ddl m Z ddl Z ddl Z ddlmZddlZddlmZddlmZmZdd lmZdd lmZeeZd d Zd dZddZdddZ dddddZ!ddZ"edkrze dSdS)zHCheck a project and backend by attempting to build using PEP 517 hooks. N)isfilejoin)CalledProcessError)mkdtemp)enable_colourful_output)TOMLDecodeError toml_load)BuildEnvironment)Pep517HookCallerc C@t}z ||tdWnty&tdYWddSwz |i}td|WntyKtjdddYWddSwz ||tdWntymtd YWddSwt}td |zz| |i}td |Wntytjd ddYWt |WddSw| d std|Wt |WddSt ||}t|rtd|ntd|Wt |WddSt|rtdntdWt |WddSWt |nt |w WddS1swYdS)N#Installed static build dependencies+Failed to install static build dependenciesFGot build requires: %s'Failure in get_requires_for_build_sdistTexc_info$Installed dynamic build dependencies,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 extensionOutput file %s existsOutput file %s does not existzOutput file is a tar filezOutput file is not a tar file)r pip_installloginforerrorget_requires_for_build_sdist Exceptionr build_sdistshutilrmtreeendswithpjoinrtarfile is_tarfilehooksbuild_sys_requiresenvreqstdfilenamepathr,:/usr/lib/python3/dist-packages/pip/_vendor/pep517/check.pycheck_build_sdistsz                 %   ,   -&r.c Cr )Nr rFrrTrrrzTrying to build wheel in %szbuild_wheel returned %rzFailure in build_wheelz.whlz'Filename %s doesn't have .whl extensionrrzOutput file is a zip filezOutput file is not a zip file)r rrrrrget_requires_for_build_wheelrr build_wheelrrr r!rzipfile is_zipfiler$r,r,r-check_build_wheelPsv                  $   +   ,&r3c Cst|d}t|rtdntddSz2t|d }t|}Wdn1s,wY|d}|d}|d}|d }td Wnt t fy[tjd d d YdSwt |||}t ||} t ||} | sstd| sztd| S)Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFrbz build-systemrequiresz build-backendz backend-pathzLoaded pyproject.tomlzInvalid pyproject.tomlTrz%Sdist checks failed; scroll up to seezWheel checks failed)r!rrrrioopenr getrKeyErrorr r.r3warning) source_dir pyprojectfpyproject_databuildsysr5backend backend_pathr%sdist_okwheel_okr,r,r-checks4          rDcCsltdt}|jddd||}tt|j}|r(t t dddSt t ddt d dS) NzQpep517.check is deprecated. Consider switching to https://pypi.org/project/build/r;z%A directory containing pyproject.toml)helpz Checks passedgreenz Checks failedredr) rr:argparseArgumentParser add_argument parse_argsrrDr;printansisysexit)argvapargsokr,r,r-mains   rTzzzz)resetboldrGrFcCs4tjdkrtjrt|t|tdSt|S)NntrU)osnamerNstdoutisatty ansi_codesstr)sattrr,r,r-rMsrM__main__)N)#__doc__rHr6loggingrXos.pathrrr!r subprocessrrNr"tempfilerr1colorlogrcompatrr envbuildr wrappersr getLogger__name__rr.r3rDrTr\rMr,r,r,r-s<      98 "