3 ReI @ s d Z ddlZddlZddlZddlmZmZ ddlm Z m Z ddlZddl mZ ddlZddlZddlmZ ddlZddlmZ dd lmZ dd lmZ ejeZdd Zd d Zdd ZdddZ dddddZ!dd Z"edkre dS )zHCheck a project and backend by attempting to build using PEP 517 hooks. N)isfilejoin)TomlDecodeErrorload)CalledProcessError)mkdtemp )enable_colourful_output)BuildEnvironment)Pep517HookCallerc 0 C s t }y|j| tjd W n tk r@ tjd dS X y| ji }tjd| W n" tk r~ tjddd dS X y|j| tjd W n tk r tjd dS X t }tjd | zy| j |i }tjd| W n$ tk r tjddd dS X |j d s*tjd| dS t||}t|rLtjd| ntjd| dS t j|rttjd ntjd dS W d tj| 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_installloginfor errorget_requires_for_build_sdist Exceptionr build_sdistendswithpjoinr tarfile is_tarfileshutilrmtree)hooksbuild_sys_requiresenvreqstdfilenamepath r! /builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/pep517/check.pycheck_build_sdist sV r# c 0 C s t }y|j| tjd W n tk r@ tjd dS X y| ji }tjd| W n" tk r~ tjddd dS X y|j| tjd W n tk r tjd dS X t }tjd | zy| j |i }tjd| W n$ tk r tjddd dS X |j d s*tjd| dS t||}t|rLtjd| ntjd| dS t j|rttjd ntjd dS W d tj| 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|rtjd ntjd dS yLt|}t|}W d Q R X |d }|d }|d }|jd}tjd W n& tt fk r tjd dd dS X t | ||}t||} t||} | stj d | stj d | S )Nzpyproject.tomlzFound pyproject.tomlzMissing pyproject.tomlFzbuild-systemrequiresz 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_loadgetr KeyErrorr r# r( warning) source_dir pyprojectfZpyproject_dataZbuildsysr) backendbackend_pathr Zsdist_okZwheel_okr! r! r" check s0 r4 c C s` t j }|jddd |j| }t t|j}|rDttdd nttdd t j d d S ) Nr/ z%A directory containing pyproject.toml)helpz Checks passedgreenz Checks failedredr )argparseArgumentParseradd_argument parse_argsr r4 r/ printansisysexit)argvZapargsokr! r! r" main s rC z[0mz[1mz[31mz[32m)resetZboldr7 r6 c C s8 t jdkr,tjj r,t| t| td S t| S d S )NntrD )osnamer> stdoutisatty ansi_codesstr)sattrr! 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&