a  ze@sdZddlZddlZddlZddlZddlmZmZddl Z ddl m Z ddl Z ddl Z ddlmZddlZddlmZddlmZmZdd lmZdd lmZeeZd d Zd dZddZdddZ dddddZ!ddZ"edkre dS)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 CsHt*}z||tdWn*tyLtdYWddS0z|i}td|Wn.tytjdddYWddS0z||tdWn*tytd YWddS0t}td |z$z| |i}td |Wn<tyJtjd ddYWt |WddS0| d std|Wt |WddSt ||}t|rtd|n(td|Wt |WddSt|rtdn&tdWt |WddSWt |n t |0WddS1s:0YdS)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_tarfilehooksZbuild_sys_requiresenvreqstdfilenamepathr*Z/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_vendor/pep517/check.pycheck_build_sdistsh                      r,c CsHt*}z||tdWn*tyLtdYWddS0z|i}td|Wn.tytjdddYWddS0z||tdWn*tytd YWddS0t}td |z$z| |i}td |Wn<tyJtjd ddYWt |WddS0| d std|Wt |WddSt ||}t|rtd|n(td|Wt |WddSt|rtdn&tdWt |WddSWt |n t |0WddS1s:0YdS)Nr r FrrTrrrzTrying 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_wheelrrrr rzipfile is_zipfiler#r*r*r+check_build_wheelPsd                       r1c Cst|d}t|rtdntddSzftj|dd}t|}Wdn1sZ0Y|d}|d}|d }|d }td Wn&t t fytjd d dYdS0t |||}t ||} t ||} | std| std| S)Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFzutf-8)encodingz build-systemrequiresz build-backendz backend-pathzLoaded pyproject.tomlzInvalid pyproject.tomlTrz%Sdist checks failed; scroll up to seezWheel checks failed)r rrrrioopenr getrKeyErrorr r,r1warning) source_dir pyprojectfZpyproject_dataZbuildsysr3backend backend_pathr$Zsdist_okZwheel_okr*r*r+checks0   &      r>cCsjtdt}|jddd||}tt|j}|rNt t ddnt t ddt d dS) NzQpep517.check is deprecated. Consider switching to https://pypi.org/project/build/r9z%A directory containing pyproject.toml)helpz Checks passedgreenz Checks failedredr) rr8argparseArgumentParser add_argument parse_argsrr>r9printansisysexit)argvZapargsokr*r*r+mains   rMzzzz)resetZboldrAr@cCs8tjdkr,tjr,t|t|tdSt|SdS)NntrN)osnamerHstdoutisatty ansi_codesstr)sattrr*r*r+rGsrG__main__)N)#__doc__rBr4loggingrPos.pathrrr r subprocessrrHr!tempfilerr/Zcolorlogrcompatrr Zenvbuildr wrappersr getLogger__name__rr,r1r>rMrTrGr*r*r*r+s8      98"