o ƚRe @sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZmZeeZdd Zd d Zd d ZddZd"ddZeZejdddejdddddejdddddejdddddd Zed!kreedSdS)#z%Build a project using PEP 517 hooks. N)BuildEnvironment)Pep517HookCaller)tempdirmkdir_p)FileNotFoundError toml_loadcCs4ddh}|t|ksdj|t|d}t|dS)z7 Ensure build system has the requisite fields. requires build-backendz"Missing required fields: {missing})missingN)setformat ValueError)systemrequiredmessager/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/pep517/build.pyvalidate_systems  rcCsPtj|d}t|d}t|}Wd|dS1swY|dS)zC Load the build system from a source dir (pyproject.toml). zpyproject.tomlrbNz build-system)ospathjoinioopenr) source_dir pyprojectfZpyproject_datarrr load_systems  rc CsHzt|}Wn ttfyi}Ynw|dd|dddg|S)z Given a source dir, attempt to get a build system backend and requirements from pyproject.toml. Fallback to setuptools but only if the file was not found or a build system was not indicated. r z setuptools.build_meta:__legacy__r setuptoolswheel)rrKeyError setdefault)rrrrr compat_system's r#c Csdjdit}t||}|i}td|||tdt9}td||djdit}t||} | |i} tj || } t | tj |tj | WddS1sawYdS)Nzget_requires_for_build_{dist}zGot build requires: %sz$Installed dynamic build dependencieszTrying to build %s in %sz build_{dist}r) r localsgetattrloginfo pip_installrrrrshutilmovebasename) hooksenvdistdestZget_requires_name get_requiresreqstdZ build_namebuildfilenamesourcerrr _do_build:s       "r6cCs|pt|}tj||p d}t|t|t||d|d}t}| |dt ||||WddS1s?wYdS)Nr.r z backend-pathr ) rrrrrrrgetrr(r6)rr.r/rr,r-rrrr3Ls "r3rz%A directory containing pyproject.toml)helpz--binaryz-b store_trueF)actiondefaultz--sourcez-sz --out-dirz-oz>Destination in which to save the builds relative to source dircCsZtdttd|js|jsdnd|js|jsdndf}|D] }t|j||jq dS)NzQpep517.build is deprecated. Consider switching to https://pypi.org/project/build/sdistr ) r&warninglistfilterr5binaryr3rZout_dir)argsdistsr.rrrmainps rC__main__)NN)__doc__argparserloggingrr)ZenvbuildrwrappersrZdirtoolsrrcompatrr getLogger__name__r&rrr#r6r3ArgumentParserparser add_argumentrC parse_argsrrrrsN