a
    hbòf�  ã                   @   s  d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZmZ ddlmZmZ e e¡Zdd	„ Zd
d„ Zdd„ Zdd„ Zd"dd„Ze ¡ Zejddd� ejddddd� ejddddd� ejdddd� dd „ Zed!k�r ee ¡ ƒ dS )#z%Build a project using PEP 517 hooks.
é    Né   )ÚBuildEnvironment)ÚPep517HookCaller)ÚtempdirÚmkdir_p)ÚFileNotFoundErrorÚ	toml_loadc                 C   s4   ddh}|t | ƒks0dj|t | ƒ d�}t|ƒ‚dS )z7
    Ensure build system has the requisite fields.
    Úrequiresúbuild-backendz"Missing required fields: {missing})ÚmissingN)ÚsetÚformatÚ
ValueError)ÚsystemÚrequiredÚmessage© r   úU/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_vendor/pep517/build.pyÚvalidate_system   s    
ÿr   c                 C   sJ   t j | d¡}t |d¡�}t|ƒ}W d  ƒ n1 s80    Y  |d S )zC
    Load the build system from a source dir (pyproject.toml).
    zpyproject.tomlÚrbNzbuild-system)ÚosÚpathÚjoinÚioÚopenr   )Ú
source_dirÚ	pyprojectÚfZpyproject_datar   r   r   Úload_system   s    &r   c              	   C   sH   zt | ƒ}W n ttfy&   i }Y n0 | dd¡ | dddg¡ |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	   Ú
setuptoolsÚwheel)r   r   ÚKeyErrorÚ
setdefault)r   r   r   r   r   Úcompat_system'   s    
þr#   c              
   C   sÎ   dj f i tƒ ¤Ž}t| |ƒ}|i ƒ}t d|¡ | |¡ t d¡ tƒ �p}t d||¡ dj f i tƒ ¤Ž}t| |ƒ}	|	|i ƒ}
tj 	||
¡}t
 |tj 	|tj |
¡¡¡ W d   ƒ n1 sÀ0    Y  d S )Nzget_requires_for_build_{dist}zGot build requires: %sz$Installed dynamic build dependencieszTrying to build %s in %szbuild_{dist})r   ÚlocalsÚgetattrÚlogÚinfoÚpip_installr   r   r   r   ÚshutilÚmoveÚbasename)ÚhooksÚenvÚdistÚdestZget_requires_nameÚget_requiresÚreqsÚtdZ
build_nameÚbuildÚfilenameÚsourcer   r   r   Ú	_do_build:   s    




r6   c                 C   sŠ   |p
t | ƒ}tj | |pd¡}t|ƒ t|ƒ t| |d | d¡ƒ}tƒ �,}| 	|d ¡ t
||||ƒ W d   ƒ n1 s|0    Y  d S )Nr.   r
   zbackend-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)ÚactionÚdefaultz--sourcez-sz	--out-dirz-oz>Destination in which to save the builds relative to source dirc                 C   sZ   t  d¡ ttd | js| js dnd | js.| js2dnd fƒƒ}|D ]}t| j|| jƒ q@d S )NzQpep517.build is deprecated. Consider switching to https://pypi.org/project/build/Úsdistr    )	r&   ÚwarningÚlistÚfilterr5   Úbinaryr3   r   Zout_dir)ÚargsÚdistsr.   r   r   r   Úmainp   s    
þrC   Ú__main__)NN)Ú__doc__Úargparser   Úloggingr   r)   Zenvbuildr   Úwrappersr   Zdirtoolsr   r   Úcompatr   r   Ú	getLoggerÚ__name__r&   r   r   r#   r6   r3   ÚArgumentParserÚparserÚadd_argumentrC   Ú
parse_argsr   r   r   r   Ú<module>   sJ   


þýýþ
