§
    îyIf?  ã                  óÔ   — d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 d dlmZmZmZmZmZmZ ddlmZmZ erd d	lmZ d d
lmZ  G d„ dee
¦  «        Z G d„ de¦  «        ZdZdS )é    )ÚannotationsN)Úcontextmanager)ÚPIPEÚPopen)ÚThread)ÚIOÚTYPE_CHECKINGÚAnyÚIteratorÚTupleÚcasté   )Ú	CmdStatusÚFrontend)ÚPath)ÚRequirementc                  óH   ‡ — e Zd Zdˆ fd„Zdd„Zedd„¦   «         Zdd
„Zˆ xZS )ÚSubprocessCmdStatusÚprocessú
Popen[str]ÚreturnÚNonec                óŒ   •— t          ¦   «                              ¦   «          || _        d | _        |                      ¦   «          d S ©N)ÚsuperÚ__init__r   Ú_out_errÚstart)Úselfr   Ú	__class__s     €úW/var/www/piapp/venv/lib/python3.11/site-packages/pyproject_api/_via_fresh_subprocess.pyr   zSubprocessCmdStatus.__init__   s8   ø€ Ý‰Œ×ÒÑÔÐØˆŒØ04ˆŒØ�
Š
‰Œˆˆˆó    c                óB   — | j                              ¦   «         | _        d S r   )r   Úcommunicater   ©r   s    r!   ÚrunzSubprocessCmdStatus.run   s   € Øœ×0Ò0Ñ2Ô2ˆŒˆˆr"   Úboolc                ó   — | j         j        d uS r   )r   Ú
returncoder%   s    r!   ÚdonezSubprocessCmdStatus.done   s   € àŒ|Ô&¨dÐ2Ð2r"   útuple[str, str]c                óZ   — t          t          t          t          f         | j        ¦  «        S r   )r   r   Ústrr   r%   s    r!   Úout_errzSubprocessCmdStatus.out_err    s   € Ý•E�#�s˜(”O T¤]Ñ3Ô3Ð3r"   )r   r   r   r   )r   r   )r   r'   )r   r+   )	Ú__name__Ú
__module__Ú__qualname__r   r&   Úpropertyr*   r.   Ú__classcell__©r    s   @r!   r   r      s…   ø€ € € € € ðð ð ð ð ð ð3ð 3ð 3ð 3ð ð3ð 3ð 3ñ „Xð3ð4ð 4ð 4ð 4ð 4ð 4ð 4ð 4r"   r   c                  óD   ‡ — e Zd ZdZdˆ fd„Zedd„¦   «         Zdd„Zˆ xZS )ÚSubprocessFrontendzWA frontend that creates fresh subprocess at every call to communicate with the backend.Úrootr   Úbackend_pathsútuple[Path, ...]Úbackend_moduler-   Úbackend_objú
str | NoneÚrequiresútuple[Requirement, ...]r   r   c                óx   •— t          ¦   «                              |||||d¬¦  «         t          j        | _        dS )a•  
        Create a subprocess frontend.

        :param root: the root path to the built project
        :param backend_paths: paths that are available on the python path for the backend
        :param backend_module: module where the backend is located
        :param backend_obj: object within the backend module identifying the backend
        :param requires: seed requirements for the backend
        F)Úreuse_backendN)r   r   ÚsysÚ
executable)r   r7   r8   r:   r;   r=   r    s         €r!   r   zSubprocessFrontend.__init__'   s8   ø€ õ" 	‰Œ×Ò˜˜}¨n¸kÈ8ÐchÐÑiÔiÐiÝœ.ˆŒˆˆr"   ÚcmdÚresult_fileÚmsgúIterator[SubprocessCmdStatus]c           	   #  ó  K  — t           j                             ¦   «         }t           j                             d„ | j        D ¦   «         ¦  «                             ¦   «         }|r||d<   t          | j        g| j	        ¢t          t          t          d| j        |¬¦  «        }t          t          t                   |j        ¦  «                             t           j        › |› t           j        › �¦  «         t%          |¦  «        V — d S )Nc              3  ó4   K  — | ]}t          |¦  «        V — Œd S r   )r-   )Ú.0Úis     r!   ú	<genexpr>z/SubprocessFrontend._send_msg.<locals>.<genexpr>>   s(   è è € Ð!FÐ!F¨Q¥# a¡&¤&Ð!FÐ!FÐ!FÐ!FÐ!FÐ!Fr"   Ú
PYTHONPATHT)ÚargsÚstdoutÚstderrÚstdinÚuniversal_newlinesÚcwdÚenv)ÚosÚenvironÚcopyÚpathsepÚjoinÚ_backend_pathsÚstripr   rB   Úbackend_argsr   Ú_rootr   r   r-   rP   ÚwriteÚlinesepr   )r   rC   rD   rE   rS   Úbackendr   s          r!   Ú	_send_msgzSubprocessFrontend._send_msg;   sæ   è è € åŒj�oŠoÑÔˆÝ”*—/’/Ð!FÐ!F°$Ô2EÐ!FÑ!FÔ!FÑFÔF×LÒLÑNÔNˆØð 	(Ø 'ˆC�ÑÝØ”/Ð6 DÔ$5Ð6ÝÝÝØ#Ø”
Øð
ñ 
ô 
ˆõ 	�R•ŒW�g”mÑ$Ô$×*Ò*­b¬jÐ+K¸#Ð+K½r¼zÐ+KÐ+KÑLÔLÐLÝ! 'Ñ*Ô*Ð*Ð*Ð*Ð*Ð*r"   Úkwargsr
   útuple[Any, str, str]c                ó   —  | j         |fi |¤ŽS )zê
        Send a command to the backend.

        :param cmd: the command to send
        :param kwargs: keyword arguments to the backend
        :return: a tuple of: backend response, standard output text, standard error text
        )Ú_send)r   rC   ra   s      r!   Úsend_cmdzSubprocessFrontend.send_cmdM   s   € ð ˆtŒz˜#Ð(Ð( Ð(Ð(Ð(r"   )r7   r   r8   r9   r:   r-   r;   r<   r=   r>   r   r   )rC   r-   rD   r   rE   r-   r   rF   )rC   r-   ra   r
   r   rb   )	r/   r0   r1   Ú__doc__r   r   r`   re   r3   r4   s   @r!   r6   r6   $   sw   ø€ € € € € ØaÐað)ð )ð )ð )ð )ð )ð( ð+ð +ð +ñ „^ð+ð")ð )ð )ð )ð )ð )ð )ð )r"   r6   )r6   )Ú
__future__r   rT   rA   Ú
contextlibr   Ú
subprocessr   r   Ú	threadingr   Útypingr   r	   r
   r   r   r   Ú	_frontendr   r   Úpathlibr   Úpackaging.requirementsr   r   r6   Ú__all__© r"   r!   ú<module>rq      s;  ðØ "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø 
€
€
€
Ø %Ð %Ð %Ð %Ð %Ð %Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *àð 3ØÐÐÐÐÐà2Ð2Ð2Ð2Ð2Ð2ð4ð 4ð 4ð 4ð 4˜) Vñ 4ô 4ð 4ð$1)ð 1)ð 1)ð 1)ð 1)˜ñ 1)ô 1)ð 1)ðh "€€€r"   