ReI@sYdZddlZddlZddlZddlmZmZddlm Z m Z ddl Z ddl mZddlZddlZddlmZddlZddlmZdd lmZdd lmZejeZd d Zd dZddZdddZ ddddddddiZ!ddZ"edkrUe dS)zHCheck a project and backend by attempting to build using PEP 517 hooks. N)isfilejoin)TomlDecodeErrorload)CalledProcessError)mkdtemp)enable_colourful_output)BuildEnvironment)Pep517HookCallerc0Cst}y|j|tjdWn#tk rOtjddSYnXy#|ji}tjd|Wn)tk rtjddddSYnXy|j|tjdWn#tk rtjd dSYnXt}tjd |zy&|j |i}tjd |Wn)tk rPtjd dddSYnX|j d sttjd|dSt ||}t |rtjd|ntjd|dSt j|rtjdntjddSWdtj|XdSWdQRXdS)Nz#Installed static build dependenciesz+Failed to install static build dependenciesFzGot build requires: %sz'Failure in get_requires_for_build_sdistexc_infoTz$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_installloginforerrorget_requires_for_build_sdist Exceptionr build_sdistendswithpjoinrtarfile is_tarfileshutilrmtree)hooksbuild_sys_requiresenvreqstdfilenamepathr!/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/pep517/check.pycheck_build_sdistsV                 r#c0Cst}y|j|tjdWn#tk rOtjddSYnXy#|ji}tjd|Wn)tk rtjddddSYnXy|j|tjdWn#tk rtjd dSYnXt}tjd |zy&|j |i}tjd |Wn)tk rPtjd dddSYnX|j d sttjd|dSt ||}t |rtjd|ntjd|dSt j|rtjdntjddSWdtj|XdSWdQRXdS)Nz#Installed static build dependenciesz+Failed to install static build dependenciesFzGot build requires: %sz'Failure in get_requires_for_build_sdistr Tz$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 rrrrget_requires_for_build_wheelrr build_wheelrrrzipfile is_zipfilerr)rrrrrrr r!r!r"check_build_wheelOsT                r(c Cs(t|d}t|r+tjdntjddSy`t|}t|}WdQRX|d}|d}|d}|jd}tjd Wn/tt fk rtjd d d dSYnXt |||}t ||} t ||} | stj d | s$tj d| S)Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFz build-systemrequiresz build-backendz backend-pathzLoaded pyproject.tomlzInvalid pyproject.tomlr Tz%Sdist checks failed; scroll up to seezWheel checks failed)rrrrropen toml_loadgetrKeyErrorr r#r(warning) source_dir pyprojectfZpyproject_dataZbuildsysr)backend backend_pathrZsdist_okZwheel_okr!r!r"checks0        r4cCstj}|jddd|j|}tt|j}|r`ttddn ttddt j ddS) Nr/helpz%A directory containing pyproject.tomlz Checks passedgreenz Checks failedredr) argparseArgumentParser add_argument parse_argsr r4r/printansisysexit)argvZapargsokr!r!r"mains rCresetzZboldzr7zr6zcCsFtjdkr8tjjr8t|t|tdSt|SdS)NntrD)osnamer>stdoutisatty ansi_codesstr)sattrr!r!r"r=sr=__main__)#__doc__r8loggingrFos.pathrrrZpip._vendor.tomlrrr+r subprocessrr>rtempfilerr&Zcolorlogr Zenvbuildr wrappersr getLogger__name__rr#r(r4rCrJr=r!r!r!r"s4        9 8 "