
    @[h                         d 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
 ddlmZ ddlmZmZ  ej        e          Zd	 Z G d
 d          ZddZddZdS )zIBuild wheels/sdists by installing build deps to a temporary environment.
    N)
check_call)	get_paths)mkdtemp   )tomllib)LoggerWrapperPep517HookCallerc                    t          t          j                            | d          d          5 }t	          j        |          }d d d            n# 1 swxY w Y   |d         }|d         |d         |                    d          fS )Nzpyproject.tomlrbzbuild-systemrequireszbuild-backendzbackend-path)openospathjoinr   loadget)
source_dirfpyproject_databuildsyss       j/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/pip/_vendor/pep517/envbuild.py_load_pyprojectr      s    	GLL%566
 
 )  a	) ) ) ) ) ) ) ) ) ) ) ) ) ) )
 n-H!^$$ s   AAAc                   0    e Zd ZdZdZddZd Zd Zd ZdS )	BuildEnvironmentzContext manager to install build deps in a simple temporary environment

    Based on code I wrote for pip, which is MIT licensed.
    NTc                     || _         d S N)_cleanup)selfcleanups     r   __init__zBuildEnvironment.__init__<   s        c                 
   t          d          | _        t                              d| j                   t          j                            dd           | _        t          j                            dd           | _        t          j	        dk    rdnd}t          || j        | j        d	          }|d
         }| j        r%|t          j        z   | j        z   t          j        d<   n)|t          j        z   t          j        z   t          j        d<   |d         |d         k    r	|d         }n|d         t          j        z   |d         z   }| j        r%|t          j        z   | j        z   t          j        d<   n|t          j        d<   | S )Nzpep517-build-env-)prefixzTemporary build environment: %sPATH
PYTHONPATHntposix_prefix)baseplatbase)varsscriptspurelibplatlib)r   r   loginfor   environr   	save_pathsave_pythonpathnamer   pathsepdefpath)r   install_schemeinstall_dirsr+   lib_dirss        r   	__enter__zBuildEnvironment.__enter__?   sd   #6777	2DI>>>55!z~~lDAA"$'T// I	7
 7
   
 y)> 	C!(2:!5!FBJv!(2:!5
!BBJv	"l9&===#I.HH#I.;Y'(H 	0'/"*'<$(%BJ|$$ (0BJ|$r!   c                 ,   |sdS t                               d|           t          j        ddddd| j        gt          |          z   }t          |t          t           t          j	                  t          t           t          j
                             dS )	zAInstall dependencies into this env by calling pip in a subprocessNzCalling pip to install %sz-mpipinstallz--ignore-installedz--prefix)stdoutstderr)r.   r/   sys
executabler   listr   r   loggingINFOERROR)r   reqscmds      r   pip_installzBuildEnvironment.pip_install_   s     	F,d333ND%4H	#%)$ZZ0 	 gl33 gm44	
 	
 	
 	
 	
 	
r!   c                    | j         o,| j        d uo#t          j                            | j                  }|rt	          j        | j                   | j        !t          j                            dd            n| j        t          j        d<   | j	        "t          j                            dd            d S | j	        t          j        d<   d S )Nr$   r%   )
r   r   r   isdirshutilrmtreer1   r0   popr2   )r   exc_typeexc_valexc_tbneeds_cleanups        r   __exit__zBuildEnvironment.__exit__m   s    M %IT!%GMM$)$$ 	
  	%M$)$$$>!JNN64((((!%BJv'JNN<.....'+';BJ|$$$r!   )T)	__name__
__module____qualname____doc__r   r    r9   rG   rQ    r!   r   r   r       sg         2 D         @
 
 
< < < < <r!   r   c                 L   |i }t          |           \  }}}t          | ||          }t                      5 }|                    |           |                    |          }|                    |           |                    ||          cddd           S # 1 swxY w Y   dS )am  Build a wheel from a source directory using PEP 517 hooks.

    :param str source_dir: Source directory containing pyproject.toml
    :param str wheel_dir: Target directory to create wheel in
    :param dict config_settings: Options to pass to build backend

    This is a blocking function which will run pip in a subprocess to install
    build requirements.
    N)r   r	   r   rG   get_requires_for_build_wheelbuild_wheel)	r   	wheel_dirconfig_settingsr   backendbackend_pathhooksenvrE   s	            r   rY   rY           &5j&A&A#Hg|Z,??E			 =s!!!11/BB  O<<	= = = = = = = = = = = = = = = = = =   ABB Bc                 L   |i }t          |           \  }}}t          | ||          }t                      5 }|                    |           |                    |          }|                    |           |                    ||          cddd           S # 1 swxY w Y   dS )am  Build an sdist from a source directory using PEP 517 hooks.

    :param str source_dir: Source directory containing pyproject.toml
    :param str sdist_dir: Target directory to place sdist in
    :param dict config_settings: Options to pass to build backend

    This is a blocking function which will run pip in a subprocess to install
    build requirements.
    N)r   r	   r   rG   get_requires_for_build_sdistbuild_sdist)	r   	sdist_dirr[   r   r\   r]   r^   r_   rE   s	            r   rd   rd      r`   ra   r   )rU   rB   r   rJ   r?   
subprocessr   	sysconfigr   tempfiler   _compatr   wrappersr   r	   	getLoggerrR   r.   r   r   rY   rd   rV   r!   r   <module>rl      s     				  



 ! ! ! ! ! !                   5 5 5 5 5 5 5 5g!!  ^< ^< ^< ^< ^< ^< ^< ^<B= = = =,= = = = = =r!   