o
    “si�  ã                   @   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 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sd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   úgC:\Users\PC\students\dividedattentionclub\venv\lib\python3.10\site-packages\pip/_vendor/pep517/build.pyÚvalidate_system   s   
ÿür   c                 C   sP   t j | d¡}t |d¡�}t|ƒ}W d  ƒ |d S 1 sw   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w | 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 di tƒ ¤Ž}t| |ƒ}|i ƒ}t d|¡ | |¡ t d¡ tƒ �9}t d||¡ dj di tƒ ¤Ž}t| |ƒ}	|	|i ƒ}
tj 	||
¡}t
 |tj 	|tj |
¡¡¡ W d   ƒ d S 1 saw   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   )r   ÚlocalsÚgetattrÚlogÚinfoÚpip_installr   r   r   r   ÚshutilÚmoveÚbasename)ÚhooksÚenvÚdistÚdestZget_requires_nameZget_requiresÚreqsÚtdZ
build_nameÚbuildÚfilenameÚsourcer   r   r   Ú	_do_build:   s   




 "úr5   c                 C   sŒ   |pt | ƒ}tj | |pd¡}t|ƒ t|ƒ t| |d | d¡ƒ}tƒ �}| 	|d ¡ t
||||ƒ W d   ƒ d S 1 s?w   Y  d S )Nr.   r
   zbackend-pathr	   )r   r   r   r   r   r   r   Úgetr   r(   r5   )r   r.   r/   r   r,   r-   r   r   r   r2   L   s   ÿ"þr2   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sd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Úfilterr4   Úbinaryr2   r   Zout_dir)ÚargsÚdistsr.   r   r   r   Úmainp   s   
þÿrB   Ú__main__)NN)Ú__doc__Úargparser   Úloggingr   r)   Zenvbuildr   Úwrappersr   Zdirtoolsr   r   Úcompatr   r   Ú	getLoggerÚ__name__r&   r   r   r#   r5   r2   ÚArgumentParserÚparserÚadd_argumentrB   Ú
parse_argsr   r   r   r   Ú<module>   sN    


þýýþÿ