o ai @ s d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl mZmZ ddl mZmZ eeZdd Zd d Zdd Zdd Zd"ddZe Zejddd ejddddd ejddddd ejdddd dd Zed!kree dS dS )#z%Build a project using PEP 517 hooks. N )BuildEnvironment)Pep517HookCaller)tempdirmkdir_p)FileNotFoundError toml_loadc C s4 ddh}|t | ksdj|t | d}t|dS )z7 Ensure build system has the requisite fields. requires build-backendz"Missing required fields: {missing})missingN)setformat ValueError)systemrequiredmessage r /builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/pep517/build.pyvalidate_system s r c C sP t j| d}t|d}t|}W d |d S 1 sw Y |d S )zC Load the build system from a source dir (pyproject.toml). zpyproject.tomlrbNzbuild-system)ospathjoinioopenr ) source_dir pyprojectfZpyproject_datar r r load_system s r c C sH zt | }W n ttfy i }Y nw |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)r r KeyError setdefault)r r r r r compat_system' s r# c C s dj di t }t| |}|i }td| || td t 9}td|| dj di t }t| |} | |i } tj || }t |tj |tj| W d d S 1 saw Y d S )Nzget_requires_for_build_{dist}zGot build requires: %sz$Installed dynamic build dependencieszTrying to build %s in %szbuild_{dist}r ) r localsgetattrloginfopip_installr r r r shutilmovebasename)hooksenvdistdestZget_requires_nameget_requiresreqstdZ build_namebuildfilenamesourcer r r _do_build: s "r6 c C s |pt | }tj| |p d}t| t| t| |d |d}t }| |d t |||| W d d S 1 s?w Y d S )Nr. r zbackend-pathr )r r r r r r r getr r( r6 )r r. r/ r r, r- r r r r3 L s "r3 r z%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 dirc C sZ t d ttd | js| jsdnd | js| jsdnd f}|D ] }t| j|| j q d S )NzQpep517.build is deprecated. Consider switching to https://pypi.org/project/build/sdistr ) r&