a Re @s>dZddlZddlZddlZddlZddlZzddlmZWne yVddl ZYn0zddl m Z Wne yddl m Z Yn0ddlmZddlmZmZddlmZmZmZddlmZmZmZeeZd d Zdd d ZefddZddZ e!Z"e"j#ddde"j#ddddddZ$edkr:e$dS)z2Build metadata for a project using PEP 517 hooks. N)Path)BuildEnvironment)Pep517HookCallerquiet_subprocess_runner)tempdirmkdir_pdir_to_zipfile)validate_system load_system compat_systemc Cs|i}td|||tdtT}td|||i}tj||}t |tj|tj |Wdn1s0YdS)NzGot build requires: %sz$Installed dynamic build dependencieszTrying to build metadata in %s) get_requires_for_build_wheelloginfo pip_installr prepare_metadata_for_build_wheelospathjoinshutilmovebasename)hooksenvdestreqstdfilenamesourcer/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/pep517/meta.py _prep_metas      r!.c Cs|p t|}tj||pd}t|t|t||d|d}|t Pt *}| |dt |||Wdn1s0YWdn1s0YdS)Ndistz build-backendz backend-pathrequires) r rrrrr rgetsubprocess_runnerrrrr!) source_dirrsystemrrrrr build)s  r)cCs<t"}||dt|WdS1s.0YdS)N)r)rr )builderout_dirrrr build_as_zip8s r,cCs:tj|}t|}tjt||d}tt|}t |S)z Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package. )r'r() rr expanduserr functoolspartialr)rr,imp_metaZPathDistribution)rootr(r*rrrr load>s   r2r'z%A directory containing pyproject.toml)helpz --out-dirz-oz>Destination in which to save the builds relative to source dircCst}t|j|jdS)N)parser parse_argsr)r'r+)argsrrr mainVsr7__main__)r"NN)%__doc__argparseloggingrrr.importlib.metadatametadatar0 ImportErrorZimportlib_metadatazipfilerZzippZenvbuildrwrappersrrZdirtoolsrrr r)r r r getLogger__name__rr!r,r2ArgumentParserr4 add_argumentr7rrrr sD