a Re @sdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZmZeeZdd Zd d Zd d ZddZd"ddZeZejdddejdddddejdddddejdddddd Zed!kreedS)#z%Build a project using PEP 517 hooks. N)BuildEnvironment)Pep517HookCaller)tempdirmkdir_p)FileNotFoundError toml_loadcCs4ddh}|t|ks0dj|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-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/pep517/build.pyvalidate_systems   rcCsJtj|d}t|d}t|}Wdn1s80Y|dS)zC Load the build system from a source dir (pyproject.toml). zpyproject.tomlrbNz build-system)ospathjoinioopenr) source_dir pyprojectfZpyproject_datarrr load_systems&rc CsHz t|}Wnttfy&i}Yn0|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 Csdjfit}t||}|i}td|||tdtp}td||djfit}t||} | |i} tj || } t | tj |tj | Wdn1s0YdS)Nzget_requires_for_build_{dist}zGot build requires: %sz$Installed dynamic build dependencieszTrying to build %s in %sz build_{dist}) r localsgetattrloginfo pip_installrrrrshutilmovebasename) hooksenvdistdestZget_requires_name get_requiresreqstdZ build_namebuildfilenamesourcerrr _do_build:s      r6cCs|p t|}tj||pd}t|t|t||d|d}t,}| |dt ||||Wdn1s|0YdS)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|js dnd|js.|js2dndf}|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_argsrrrrsJ