§
    ÎÑßjls  ã                  óÈ  — d Z ddlmZ ddlZddlZddl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mZmZmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& erddl'Z'dd
l(m)Z)m*Z*m+Z+ e,ej-        e,         z  Z- ej.        e/¦  «        Z0dd„Z1dd„Z2e1Z3 G d„ d¦  «        Z4 G d„ de¦  «        Z5 G d„ d¦  «        Z6 G d„ d¦  «        Z7 e7¦   «         Z8dS ) z<
Builder and Builds classes for managing the build process.
é    )ÚannotationsN)ÚIOÚTYPE_CHECKINGÚAnyÚ	TypedDictÚcast)	ÚDATA_DIRÚ
MODULE_DIRÚConfigurationErrorÚWorkDirsÚ
build_archÚextract_archiveÚget_toolchainÚget_tripletÚ	work_dirsé   )Úbuild_default)ÚDownload)Ú
BuildStatsÚLineCountHandlerÚload_build_statsÚprint_uiÚprint_ui_expandedÚupdate_build_stats)ÚCallableÚMutableMappingÚSequenceÚenvúMutableMapping[str, str]ÚdirsÚDirsÚreturnÚNonec                ó   — | }|}dS )zÌDefault populate_env implementation (does nothing).

    This default implementation intentionally does nothing; specific steps may
    provide their own implementation via the ``populate_env`` hook.
    N© )r   r    Ú_s      úO/opt/saltstack/salt/lib/python3.11/site-packages/relenv/build/common/builder.pyÚ_default_populate_envr(   :   s   € ð 	€AØ€A€A€Aó    ÚnameÚstrÚplatformúdict[str, str] | Nonec                óî  — t           dz  }|                     ¦   «         sdS t          j        |                     ¦   «         ¦  «        }|                     di ¦  «        }| |vrdS ||          }t          |                     ¦   «         d„ d¬¦  «        D ]d\  }}||                     dg ¦  «        v rG||d         |                     d	d
¦  «        dœ}|                     ¦   «         D ]\  }	}
|	dvr|
||	<   Œ|c S ŒedS )a‰  
    Get dependency version and metadata from python-versions.json.

    Returns dict with keys: version, url, sha256, and any extra fields (e.g., sqliteversion)
    Returns None if dependency not found.

    :param name: Dependency name (openssl, sqlite, xz)
    :param platform: Platform name (linux, darwin, win32)
    :return: Dict with version, url, sha256, and extra fields, or None
    zpython-versions.jsonNÚdependenciesc                óL   — d„ | d                               d¦  «        D ¦   «         S )Nc                ó,   — g | ]}t          |¦  «        ‘ŒS r%   )Úint)Ú.0Úns     r'   ú
<listcomp>z<get_dependency_version.<locals>.<lambda>.<locals>.<listcomp>]   s   € Ð7Ð7Ð7 !•s˜1‘v”vÐ7Ð7Ð7r)   r   ú.)Úsplit)Úxs    r'   ú<lambda>z(get_dependency_version.<locals>.<lambda>]   s#   € Ð7Ð7 q¨¤t§z¢z°#¡¤Ð7Ñ7Ô7€ r)   T)ÚkeyÚreverseÚ	platformsÚurlÚsha256Ú )Úversionr=   r>   )r=   r>   r<   )r
   ÚexistsÚjsonÚloadsÚ	read_textÚgetÚsortedÚitems)r*   r,   Úversions_fileÚdatar/   Údep_versionsr@   ÚinfoÚresultr:   Úvalues              r'   Úget_dependency_versionrN   D   s8  € õ Ð!7Ñ7€MØ×ÒÑ!Ô!ð ØˆtåŒ:�m×-Ò-Ñ/Ô/Ñ0Ô0€DØ—8’8˜N¨BÑ/Ô/€Là�<ÐÐØˆtð   Ô%€LÝØ×ÒÑÔØ7Ð7Øðñ ô ð ð ‰ˆ�ð
 �t—x’x ¨RÑ0Ô0Ð0Ð0ð #Ø˜E”{ØŸ(š( 8¨RÑ0Ô0ðð ˆFð #Ÿjšj™lœlð (ð (‘
��UØÐ<Ð<Ð<Ø"'�F˜3‘KøØˆMˆMˆMð 1ð ˆ4r)   c                  óz   — e Zd ZdZdd
„Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zdd„Z	dd„Z
dd„ZdS )r!   a"  
    A container for directories during build time.

    :param dirs: A collection of working directories
    :type dirs: ``relenv.common.WorkDirs``
    :param name: The name of this collection
    :type name: str
    :param arch: The architecture being worked with
    :type arch: str
    r    r   r*   r+   Úarchr@   r"   r#   c                óð   — || _         || _        || _        |j        | _        |j        | _        |j        | _        |j        | _        |j        | _	        t          j        |› d�¬¦  «        | _        d | _        d S )NÚ_build)Úprefix)r*   r@   rP   ÚrootÚbuildÚdownloadÚ	downloadsÚlogsÚsrcÚsourcesÚtempfileÚmkdtempÚtmpbuildÚsource)Úselfr    r*   rP   r@   s        r'   Ú__init__zDirs.__init__€   sl   € ð ˆŒ	ØˆŒØˆŒ	Ø”IˆŒ	Ø”ZˆŒ
ØœˆŒØ”IˆŒ	Ø”xˆŒÝ Ô(°4°°°Ð@Ñ@Ô@ˆŒØ+/ˆŒˆˆr)   úpathlib.Path | Nonec                óÊ   — t           j        dk    rt          | j        ¬¦  «        S t           j        dk    rt          | j        ¬¦  «        S t          | j        | j        ¦  «        S )z:Get the toolchain directory path for the current platform.Údarwin)rT   Úwin32)Úsysr,   r   rT   rP   ©r_   s    r'   Ú	toolchainzDirs.toolchainŽ   sX   € õ Œ<˜8Ò#Ð#Ý  d¤iÐ0Ñ0Ô0Ð0ÝŒ\˜WÒ$Ð$Ý  d¤iÐ0Ñ0Ô0Ð0å  ¤¨D¬IÑ6Ô6Ð6r)   c                ó~   — t           j        dk    r
| j        › d�S t           j        dk    r
| j        › d�S | j        › d�S ©Nrc   z-macosrd   z-winz
-linux-gnu©re   r,   rP   rf   s    r'   Ú_tripletzDirs._triplet˜   óO   € åŒ<˜8Ò#Ð#Ø”iÐ'Ð'Ð'Ð'ÝŒ\˜WÒ$Ð$Ø”iÐ%Ð%Ð%Ð%à”iÐ+Ð+Ð+Ð+r)   úpathlib.Pathc                ó4   — | j         | j        › d| j        › �z  S ©z$Get the build prefix directory path.ú-)rU   r@   rk   rf   s    r'   rS   zDirs.prefix¡   s#   € ð Œz˜tœ|Ð=Ð=¨d¬mÐ=Ð=Ñ=Ð=r)   údict[str, Any]c           	     óh   — | j         | j        | j        | j        | j        | j        | j        | j        dœS )z[
        Return an object used for pickling.

        :return: The picklable state
        ©r*   rP   rT   rU   rW   rX   rZ   r]   rs   rf   s    r'   Ú__getstate__zDirs.__getstate__¦   s;   € ð ”IØ”IØ”IØ”ZØœØ”IØ”|Øœð	
ð 	
ð 		
r)   Ústatec                óÖ   — |d         | _         |d         | _        |d         | _        |d         | _        |d         | _        |d         | _        |d         | _        |d         | _        d	S )
z„
        Unwrap the object returned from unpickling.

        :param state: The state to unpickle
        :type state: dict
        r*   rP   rT   rW   rX   rZ   rU   r]   N)r*   rP   rT   rW   rX   rZ   rU   r]   )r_   ru   s     r'   Ú__setstate__zDirs.__setstate__·   sc   € ð ˜&”MˆŒ	Ø˜&”MˆŒ	Ø˜&”MˆŒ	Ø˜{Ô+ˆŒØ˜&”MˆŒ	Ø˜YÔ'ˆŒØ˜7”^ˆŒ
Ø˜jÔ)ˆŒˆˆr)   c                ó    ‡ — ˆ fd„dD ¦   «         S )z£
        Get a dictionary representation of the directories in this collection.

        :return: A dictionary of all the directories
        :rtype: dict
        c                ó2   •— i | ]}|t          ‰|¦  «        “ŒS r%   )Úgetattr)r3   r8   r_   s     €r'   ú
<dictcomp>z Dirs.to_dict.<locals>.<dictcomp>Î   s5   ø€ ð 
ð 
ð 
àð �w�t˜QÑÔð
ð 
ð 
r)   )rT   rS   rW   rX   rZ   rU   rg   r%   rf   s   `r'   Úto_dictzDirs.to_dictÇ   s0   ø€ ð
ð 
ð 
ð 
ðð
ñ 
ô 
ð 	
r)   N)
r    r   r*   r+   rP   r+   r@   r+   r"   r#   ©r"   ra   ©r"   r+   ©r"   rm   )r"   rq   )ru   rq   r"   r#   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r`   Úpropertyrg   rk   rS   rt   rw   r|   r%   r)   r'   r!   r!   t   sÎ   € € € € € ð	ð 	ð0ð 0ð 0ð 0ð ð7ð 7ð 7ñ „Xð7ð ð,ð ,ð ,ñ „Xð,ð ð>ð >ð >ñ „Xð>ð
ð 
ð 
ð 
ð"*ð *ð *ð *ð 
ð 
ð 
ð 
ð 
ð 
r)   c                  ó2   — e Zd ZU dZded<   ded<   ded<   dS )	ÚRecipez*Typed description of a build recipe entry.z9Callable[[MutableMapping[str, str], Dirs, IO[str]], None]Ú
build_funcú	list[str]Úwait_onúDownload | NonerV   N)r€   r�   r‚   rƒ   Ú__annotations__r%   r)   r'   r†   r†   Ü   s<   € € € € € € Ø4Ð4àIÐIÐIÑIØÐÐÑØÐÐÑÐÐr)   r†   c                  ó
  — e Zd ZdZ	 	 	 	 	 	 d>d?d„Zd@d„ZedAd„¦   «         ZedBd„¦   «         ZedCd„¦   «         Z	edBd„¦   «         Z
	 	 	 dDdEd!„Z	 	 	 dFdGd.„ZdHd/„ZdHd0„Z	 	 	 	 dIdJd4„Z	 	 	 	 	 dKdLd7„ZdMd9„Z	 	 	 	 	 	 	 	 	 dNdOd=„ZdS )PÚBuilderaÀ  
    Utility that handles the build process.

    :param root: The root of the working directories for this build
    :type root: str
    :param recipies: The instructions for the build steps
    :type recipes: list
    :param build_default: The default build function, defaults to ``build_default``
    :type build_default: types.FunctionType
    :param populate_env: The default function to populate the build environment, defaults to ``populate_env``
    :type populate_env: types.FunctionType
    :param force_download: If True, forces downloading the archives even if they exist, defaults to False
    :type force_download: bool
    :param arch: The architecture being built
    :type arch: str
    NÚx86_64r?   rT   úPathLike | NoneÚrecipiesúdict[str, Recipe] | Noner   ú@Callable[[MutableMapping[str, str], Dirs, IO[str]], None] | NoneÚpopulate_envú7Callable[[MutableMapping[str, str], Dirs], None] | NonerP   r+   r@   r"   r#   c                óŠ  — || _         t          |¦  «        | _        t          ¦   «         | _        t	          | j        ¦  «        | _        || _        | j        j        | _        | j        j	        | _
        |€i | _        n|| _        |�|nt          | _        |�|nt          | _        || _        |                      | j        ¦  «         d S )N)rT   r   r    r   r   Úbuild_tripletrP   rY   rZ   rV   rW   r�   Ú_default_build_funcr   r(   r“   r@   Úset_arch)r_   rT   r�   r   r“   rP   r@   s          r'   r`   zBuilder.__init__ö   sº   € ð ˆŒ	Ý'¨™oœoˆŒ	Ý$™,œ,ˆŒÝ(¨¬Ñ9Ô9ˆÔØˆŒ	Ø”y”}ˆŒØœÔ+ˆŒàÐØ/1ˆDŒMˆMà$ˆDŒMð +Ð6ˆMˆMÕ<Oð 	Ôð )Ð4ˆLˆLÕ:Oð 	Ôð ˆŒØ�Š�d”iÑ Ô Ð Ð Ð r)   c                ó"   — || _         d| _        dS )zu
        Set the architecture for the build.

        :param arch: The arch to build
        :type arch: str
        N)rP   Ú
_toolchain)r_   rP   s     r'   r˜   zBuilder.set_arch  s   € ð ˆŒ	Ø/3ˆŒˆˆr)   ra   c                óŠ   — | j         €6t          j        dk    r&ddlm}  || j        | j        j        ¦  «        | _         | j         S )z(Lazily fetch toolchain only when needed.NÚlinuxr   )r   )rš   re   r,   Úrelenv.commonr   rP   r    rT   )r_   r   s     r'   rg   zBuilder.toolchain#  sK   € ð Œ?Ð"¥s¤|°wÒ'>Ð'>Ø3Ð3Ð3Ð3Ð3Ð3à+˜m¨D¬I°t´y´~ÑFÔFˆDŒOØŒÐr)   c                ó*   — t          | j        ¦  «        S )z4Get the target triplet for the current architecture.)r   rP   rf   s    r'   ÚtripletzBuilder.triplet,  s   € õ ˜4œ9Ñ%Ô%Ð%r)   rm   c                ó>   — | j         j        | j        › d| j        › �z  S ro   )r    rU   r@   rŸ   rf   s    r'   rS   zBuilder.prefix1  s%   € ð ŒyŒ D¤LÐ!AÐ!A°4´<Ð!AÐ!AÑAÐAr)   c                ó~   — t           j        dk    r
| j        › d�S t           j        dk    r
| j        › d�S | j        › d�S ri   rj   rf   s    r'   rk   zBuilder._triplet6  rl   r)   r*   r‡   úCallable[..., Any] | Noner‰   úSequence[str] | NonerV   údict[str, Any] | Nonec                óŒ   — |€g }nt          |¦  «        }|€| j        }d}|�t          |fd| j        i|¤Ž}|||dœ| j        |<   dS )añ  
        Add a step to the build process.

        :param name: The name of the step
        :type name: str
        :param build_func: The function that builds this step, defaults to None
        :type build_func: types.FunctionType, optional
        :param wait_on: Processes to wait on before running this step, defaults to None
        :type wait_on: list, optional
        :param download: A dictionary of download information, defaults to None
        :type download: dict, optional
        NÚdestination)r‡   r‰   rV   )Úlistr   r   rW   r�   )r_   r*   r‡   r‰   rV   Úwait_on_listÚdownload_objs          r'   ÚaddzBuilder.add?  sr   € ð& ˆ?Ø&(ˆLˆLå ™=œ=ˆLØÐØÔ+ˆJØ(,ˆØÐÝ# DÐQÐQ°d´nÐQÈÐQÐQˆLà$Ø#Ø$ð
ð 
ˆŒ�dÑÐÐr)   FÚWARNINGÚeventú!multiprocessing.synchronize.EventúCallable[..., Any]rŠ   Úshow_uiÚboolÚ	log_levelÚline_countsúMutableMapping[str, int] | Noner   c                ó8  — t          j        d¦  «        }t          j        dk    rQ|sOt          j        ¦   «         }	|	                     t          j        |¦  «        ¦  «         |                     |	¦  «         |j        D ]G}
t          |
t           j        ¦  «        r+|
 
                    t          j        d|› d�¦  «        ¦  «         ŒH| j        j                             ¦   «         s t          j        | j        j        d¬¦  «         t#          | j        || j        | j        ¦  «        }t          j        |j        d¬¦  «         t          j        |j        d¬¦  «         t          j        |j        d¬¦  «         |                     ¦   «         du r*t1          j        d¦  «         |                     ¦   «         du °*t5          t          j                             |j        |› d	�¦  «        d
¦  «        }t          j        |j        |› d	�z  ¦  «        }|                     |¦  «         |                     t           j        ¦  «         d}|�%t?          ||¦  «        }|                     |¦  «         t          j         ¦   «         }|rstC          |j        tE          |j#        ¦  «        ¦  «         |j        |j#        j$         %                    d¦  «        d         z  |_&        t          j'        |j&        ¦  «         nt          j'        |j        ¦  «         t          j        dk    rt          j(         )                    ¦   «         }ndt          j(        d         i}d|d<   d|d<   | j*        |d<   | j        |d<   | j+        |d<   | j,        |d<   | j-        d          .                    d¦  «        }|€t_          d¦  «        ‚|j        |d<   |d          0                    dd¦  «        d         |d<   dt          j(        v rt          j(        d         |d<   | j,        | j        k    r"tb          dz  }tE          |dz  dz  ¦  «        |d <   |  2                    ||¦  «         | 3                    ¦   «         }|D ]$}th           5                    d!|||         ¦  «         Œ%|D ]$}th           5                    d"|||         ¦  «         Œ%	  ||||¦  «        }|�|�||v r||         }tm          ||¦  «         |t          j'        |¦  «         |�| 7                    |¦  «         | 7                    |¦  «         | 8                    ¦   «          S # tr          $ r1 th           :                    d#¦  «         t          j;        d¦  «         Y nw xY w	 t          j'        |¦  «         |�| 7                    |¦  «         | 7                    |¦  «         | 8                    ¦   «          dS # t          j'        |¦  «         |�| 7                    |¦  «         | 7                    |¦  «         | 8                    ¦   «          w xY w)$a…  
        Run a build step.

        :param name: The name of the step to run
        :type name: str
        :param event: An event to track this process' status and alert waiting steps
        :type event: ``multiprocessing.Event``
        :param build_func: The function to use to build this step
        :type build_func: types.FunctionType
        :param download: The ``Download`` instance for this step
        :type download: ``Download``
        :param line_counts: Optional shared dict for tracking log line counts
        :type line_counts: Optional[MutableMapping[str, int]]

        :return: The output of the build function
        Nrd   z%(asctime)s z %(message)sT©Úexist_okFç333333Ó?ú.logÚwz.tarr   ÚPATHÚ1ÚRELENV_DEBUGÚRELENV_BUILDENVÚRELENV_HOSTÚRELENV_HOST_ARCHÚRELENV_BUILDÚRELENV_BUILD_ARCHÚpythonrV   z/Python recipe is missing download configurationÚRELENV_PY_VERSIONr6   r   ÚRELENV_PY_MAJOR_VERSIONÚRELENV_DATAÚnativeÚbinÚpython3ÚRELENV_NATIVE_PYzDirectory %s %szEnvironment %s %szBuild failure)<ÚloggingÚ	getLoggerre   r,   ÚStreamHandlerÚsetLevelÚgetLevelNameÚ
addHandlerÚhandlersÚ
isinstanceÚsetFormatterÚ	Formatterr    rU   rA   ÚosÚmakedirsr!   rP   r@   rZ   rX   rS   Úis_setÚtimeÚsleepÚopenÚpathÚjoinÚFileHandlerÚNOTSETr   Úgetcwdr   r+   Úfilepathr*   r7   r^   ÚchdirÚenvironÚcopyrŸ   r–   r   r�   rE   r   Úrsplitr	   r“   r|   ÚlogrK   r   ÚremoveHandlerÚcloseÚ	ExceptionÚ	exceptionÚexit)r_   r*   r¬   r‡   rV   r¯   r±   r²   Úroot_logÚstream_handlerÚhr    ÚlogfpÚfile_handlerÚline_count_handlerÚcwdr   Úpython_downloadÚnative_rootr&   ÚkrL   Úfinal_counts                          r'   ÚrunzBuilder.runa  sÒ  € õ4 Ô$ TÑ*Ô*ˆÝŒ<˜7Ò"Ð"Øð 4Ý!(Ô!6Ñ!8Ô!8�Ø×'Ò'­Ô(<¸YÑ(GÔ(GÑHÔHÐHØ×#Ò# NÑ3Ô3Ð3àÔ"ð 	Uð 	UˆAÝ˜!�WÔ2Ñ3Ô3ð UØ—’�wÔ0Ð1RÀÐ1RÐ1RÐ1RÑSÔSÑTÔTÐTøàŒyŒ×%Ò%Ñ'Ô'ð 	8ÝŒK˜œ	œ°$Ð7Ñ7Ô7Ð7å�D”I˜t T¤Y°´Ñ=Ô=ˆÝ
Œ�D”L¨4Ð0Ñ0Ô0Ð0Ý
Œ�D”I¨Ð-Ñ-Ô-Ð-Ý
Œ�D”K¨$Ð/Ñ/Ô/Ð/à�lŠl‰nŒn Ð%Ð%ÝŒJ�s‰OŒOˆOð �lŠl‰nŒn Ð%Ð%õ •R”W—\’\ $¤)°¨]¨]¨]Ñ;Ô;¸SÑAÔAˆÝÔ*¨4¬9¸$°}°}°}Ñ+DÑEÔEˆØ×Ò˜LÑ)Ô)Ð)Ø×Ò�'œ.Ñ)Ô)Ð)ð 7;ÐØÐ"Ý!1°$¸Ñ!DÔ!DÐØ×ÒÐ 2Ñ3Ô3Ð3õ
 Œi‰kŒkˆØð 	"Ý˜DœL­#¨hÔ.?Ñ*@Ô*@ÑAÔAÐAØœ,¨Ô):Ô)?×)EÒ)EÀfÑ)MÔ)MÈaÔ)PÑPˆDŒKÝŒH�T”[Ñ!Ô!Ð!Ð!åŒH�T”[Ñ!Ô!Ð!åŒ<˜7Ò"Ð"Ý”*—/’/Ñ#Ô#ˆCˆCð �œ
 6Ô*ðˆCð "ˆˆNÑØ!$ˆÐÑØ!œ\ˆˆMÑØ"&¤)ˆÐÑØ"Ô0ˆˆNÑØ#'¤?ˆÐÑ Øœ-¨Ô1×5Ò5°jÑAÔAˆØÐ"Ý$Ð%VÑWÔWÐWØ#2Ô#:ˆÐÑ Ø),Ð-@Ô)A×)HÒ)HÈÈaÑ)PÔ)PÐQRÔ)SˆÐ%Ñ&Ø�BœJÐ&Ð&Ý!#¤¨MÔ!:ˆC�ÑØŒ?˜dœiÒ'Ð'Ý" XÑ-ˆKÝ&)¨+¸Ñ*=À	Ñ*IÑ&JÔ&JˆCÐ"Ñ#à×Ò˜#˜tÑ$Ô$Ð$à�LŠL‰NŒNˆØð 	1ð 	1ˆAÝ�HŠHÐ&¨¨1¨Q¬4Ñ0Ô0Ð0Ð0Øð 	5ð 	5ˆAÝ�HŠHÐ(¨!¨S°¬VÑ4Ô4Ð4Ð4ð	Ø�Z  T¨5Ñ1Ô1ˆFà!Ð-°+Ð2IØ˜;Ð&Ð&Ø"-¨dÔ"3�KÝ& t¨[Ñ9Ô9Ð9Øõ
 ŒH�S‰MŒMˆMØ!Ð-Ø×&Ò&Ð'9Ñ:Ô:Ð:Ø×"Ò" <Ñ0Ô0Ð0Ø�KŠK‰MŒMˆMˆMøõ ð 	ð 	ð 	Ý�MŠM˜/Ñ*Ô*Ð*ÝŒH�Q‰KŒKˆKˆKˆKð	øøøàåŒH�S‰MŒMˆMØ!Ð-Ø×&Ò&Ð'9Ñ:Ô:Ð:Ø×"Ò" <Ñ0Ô0Ð0Ø�KŠK‰MŒMˆMˆMˆMøõ	 ŒH�S‰MŒMˆMØ!Ð-Ø×&Ò&Ð'9Ñ:Ô:Ð:Ø×"Ò" <Ñ0Ô0Ð0Ø�KŠK‰MŒMˆMˆMøøøs%   Ò+.T. Ô.8U)Õ&W Õ(U)Õ)W ×AXc                ó8   — t          j        | j        ¦  «         dS )z1
        Clean up the build directories.
        N)ÚshutilÚrmtreerS   rf   s    r'   ÚcleanupzBuilder.cleanup×  s   € õ 	Œ�d”kÑ"Ô"Ð"Ð"Ð"r)   c                ó6  — | j         | j        fD ]T}	 t          j        |¦  «         Œ# t          $ r% t
          j                             d|› �¦  «         Y ŒFt          $ r Y ŒQw xY w| j         › d�}|fD ]'}	 t          j
        |¦  «         Œ# t          $ r Y Œ$w xY wdS )zE
        Completely clean up the remnants of a relenv build.
        zUnable to remove directory: z.tar.xzN)rS   rZ   r÷   rø   ÚPermissionErrorre   ÚstderrÚwriteÚFileNotFoundErrorrÔ   Úremove)r_   r&   Úarchives      r'   ÚcleanzBuilder.cleanÝ  sï   € ð
 ”+˜tœ|Ð,ð 	ð 	ˆAðÝ”˜aÑ Ô Ð Ð øÝ"ð Eð Eð EÝ”
× Ò Ð!CÀÐ!CÐ!CÑDÔDÐDÐDÐDÝ$ð ð ð Ø�ðøøøð ”[Ð)Ð)Ð)ˆØ�ð 	ð 	ˆAðÝ”	˜!‘”��øÝ$ð ð ð Ø�ðøøøð	ð 	s'   ’'§,A!Á	A!Á A!Á4B	Â	
BÂBÚstepsÚforce_downloadÚexpanded_uic           	     ó‚  — |�t          |¦  «        nt          | j        ¦  «        }g }i }i }t          j        ¦   «         }	|	                     ¦   «         }
i }|r!|st
          j                             d¦  «         t           	                    d¦  «         |r|st          |||¦  «         |D ]�}| j        |         d         }|€Œt          j        ¦   «         }|                     ¦   «          |||<   dd„}||ddœ}|r |||
¦  «        |d<   t          j        |||¬¦  «        }|                     ¦   «          |||<   Œ�|r¬t          |                     ¦   «         ¦  «        D ]ˆ}|                     d¦  «         |r(|rt#          ||||
|d¦  «         nt          |||¦  «         |j        €ŒI|                     |j        ¦  «         |j        dk    r|                     |j        ¦  «         Œ‰|°¬|rG|rt#          ||||
|d¦  «         nt          |||¦  «         t
          j                             d¦  «         |r�|rt          |||¦  «         t
          j                             d¦  «         |D ]$}t
          j                             |dz   ¦  «         Œ%t
          j                             ¦   «          t          j        d¦  «         dS dS )a  
        Download all of the needed archives.

        :param steps: The steps to download archives for, defaults to None
        :type steps: list, optional
        :param expanded_ui: Whether to use expanded UI with progress bars
        :type expanded_ui: bool, optional
        NzStarting downloads 
zStarting downloadsrV   Ú	step_namer+   Úshared_dictúMutableMapping[str, int]r"   úCallable[[int, int], None]c                ó   ‡ ‡— dˆˆ fd„}|S )NÚ
downloadedr2   Útotalr"   r#   c                ó"   •— | ‰‰<   |‰‰› d�<   d S )NÚ_totalr%   )r  r  r  r  s     €€r'   Úprogress_callbackzQBuilder.download_files.<locals>.make_progress_callback.<locals>.progress_callback  s&   ø€ Ø-7�K 	Ñ*Ø8=�K 9Ð 4Ð 4Ð 4Ñ5Ð5Ð5r)   )r  r2   r  r2   r"   r#   r%   )r  r  r  s   `` r'   Úmake_progress_callbackz6Builder.download_files.<locals>.make_progress_callback  s/   øø€ ð>ð >ð >ð >ð >ð >ð >ð )Ð(r)   T)r  r¯   Úexit_on_failurer  )r*   ÚtargetÚkwargsr·   r   ú
ú%The following failures were reported
r   )r  r+   r  r  r"   r	  )r§   r�   ÚmultiprocessingÚManagerÚdictre   Ústdoutrý   rä   rK   r   ÚEventÚsetÚProcessÚstartÚvaluesrÛ   r   ÚexitcodeÚpopr*   Úappendrü   Úflushré   )r_   r  r  r¯   r  Ú
step_namesÚfailsÚ	processesÚeventsÚmanagerr²   Úbuild_statsr*   rV   r¬   r  Údownload_kwargsÚprocÚfails                      r'   Údownload_fileszBuilder.download_filesñ  s@  € ð %*Ð$5•T˜%‘[”[�[½4ÀÄÑ;NÔ;Nˆ
àˆØ8:ˆ	Ø!#ˆõ "Ô)Ñ+Ô+ˆØ07·²±´ˆØ-/ˆàð 	:Øð :Ý”
× Ò Ð!8Ñ9Ô9Ð9Ý�ŠÐ%Ñ&Ô&Ð&Øð 	/˜;ð 	/Ý�V˜Y¨Ñ.Ô.Ð.Øð  	#ð  	#ˆDØ”} TÔ*¨:Ô6ˆHØÐØÝ#Ô)Ñ+Ô+ˆEØ�IŠI‰KŒKˆKØ ˆF�4‰Lð)ð )ð )ð )ð #1Ø"Ø#'ð/ð /ˆOð
 ð aØ7MÐ7MÈdÐT_Ñ7`Ô7`�Ð 3Ñ4å"Ô*ØØØ&ðñ ô ˆDð
 �JŠJ‰LŒLˆLØ"ˆI�d‰OˆOàð 	,Ý˜Y×-Ò-Ñ/Ô/Ñ0Ô0ð ,ð ,�Ø—	’	˜#‘”�àð ;Ø"ð 
;Ý)Ø"Ø%Ø!Ø'Ø'Ø&ñô ð ð õ ! ¨°EÑ:Ô:Ð:Ø”=Ð(ØØ—’˜dœiÑ(Ô(Ð(Ø”= AÒ%Ð%Ø—L’L ¤Ñ+Ô+Ð+øð) ð 	,ð* ð 	#Øð 3Ý! &¨)°U¸KÈÐV`ÑaÔaÐaÐaå˜ ¨EÑ2Ô2Ð2ÝŒJ×Ò˜TÑ"Ô"Ð"Øð 	Øð 3Ý˜ ¨EÑ2Ô2Ð2ÝŒJ×ÒÐEÑFÔFÐFØð .ð .�Ý”
× Ò  ¨¡Ñ-Ô-Ð-Ð-ÝŒJ×ÒÑÔÐÝŒH�Q‰KŒKˆKˆKˆKð	ð 	r)   Trù   c           	     óN  — g }i }i }i }	t          j        ¦   «         }
|
                     ¦   «         }i }|rt          ¦   «         }|r3|rn0t          j                             d¦  «         t          ||	|¦  «         t           	                    d¦  «         |�t          |¦  «        nt          | j        ¦  «        }|D ]÷}t          j        ¦   «         }|||<   | j        |         }t          |¦  «        }||d<   ||d<   ||d<   t          d|                     dg ¦  «        ¦  «        }t          |¦  «        }|dd…         D ]}||vr|                     |¦  «         Œ|||<   ||         s|                     ¦   «          t          j        || j        ||f|¬	¦  «        }|                     ¦   «          ||	|<   Œø|	�rXt          |	                     ¦   «         ¦  «        D �]2}|                     d
¦  «         |r(|rt-          ||	|||d¦  «         nt          ||	|¦  «         |j        €ŒJ|	                     |j        ¦  «         |j        dk    r|                     |j        ¦  «         d}nd}|D ]¡}|j        ||         v rT|r2||	v r.|	|                              ¦   «          t7          j        d¦  «         ||                              |j        ¦  «         ||         s4||                              ¦   «         s||                              ¦   «          Œ¢�Œ4|	�°X|�rêt          j                             d¦  «         i }|D �]a}| j        j         |› d�z  }	 tC          |¦  «        5 }| "                    dd¦  «         | #                    ¦   «         }|dz
  }|dk    r| "                    |¦  «         n| "                    d¦  «         | $                    ¦   «         }|r`t          j                             dd|› d�z   dz   dz   ¦  «         t          j                             | $                    ¦   «         dz   ¦  «         ddd¦  «         n# 1 swxY w Y   n# tJ          $ r d|› �||<   Y nw xY wt           &                    d|¦  «         t           &                    |¦  «         �Œc|rt          j         '                    ¦   «          |r.t           (                    d¦  «         |  )                    ¦   «          t	          j*        d¦  «         |ryt7          j        d
¦  «         |rt-          ||	|||d¦  «         nt          ||	|¦  «         t          j                             d¦  «         t          j         '                    ¦   «          |r0t           (                    d¦  «         |  )                    ¦   «          dS dS )aU  
        Build!

        :param steps: The steps to run, defaults to None
        :type steps: list, optional
        :param cleanup: Whether to clean up or not, defaults to True
        :type cleanup: bool, optional
        :param expanded_ui: Whether to use expanded UI with progress bars
        :type expanded_ui: bool, optional
        zStarting builds
zStarting buildsNr¯   r±   r²   rˆ   r‰   )r*   r  Úargsr  r·   rU   r   TFgš™™™™™¹?r  r¸   é   i   z====================ú r  z

zLog file not found: zBuild step %s has failedzPerforming cleanup.r   )+r  r  r  r   re   r  rý   r   rä   rK   r§   r�   r  r   r   rÿ   r  r  rõ   r  r  rÛ   r   r  r*   r!  Ú	terminater×   rØ   rÖ   rü   r    rX   rÙ   ÚseekÚtellÚreadrþ   Úerrorr"  Údebugrù   ré   )r_   r  rù   r¯   r±   r  r$  r&  Úwaitsr%  r'  r²   r(  r#  r*   r¬   Úreciper  Úwait_on_seqr¨   Ú
dependencyr*  Ú
is_failureÚ	last_outsr+  Úlog_fileÚfpÚendÚindÚlast_outs                                 r'   rU   zBuilder.buildW  s$  € ð$ ˆØ!#ˆØ&(ˆØ8:ˆ	õ "Ô)Ñ+Ô+ˆØ07·²±´ˆØ-/ˆØð 	-Ý*Ñ,Ô,ˆKàð 	3Øð 3àå”
× Ò Ð!4Ñ5Ô5Ð5å˜ ¨EÑ2Ô2Ð2Ý�ŠÐ"Ñ#Ô#Ð#à$)Ð$5•T˜%‘[”[�[½4ÀÄÑ;NÔ;Nˆ
àð 	#ð 	#ˆDÝ#Ô)Ñ+Ô+ˆEØ ˆF�4‰LØ”] 4Ô(ˆFÝ˜&‘\”\ˆFØ 'ˆF�9ÑØ"+ˆF�;ÑØ$/ˆF�=Ñ!õ ˜{¨F¯JªJ°yÀ"Ñ,EÔ,EÑFÔFˆKÝ Ñ,Ô,ˆLØ*¨1¨1¨1œoð 4ð 4�
Ø ZÐ/Ð/Ø ×'Ò'¨
Ñ3Ô3Ð3øà&ˆE�$‰KØ˜”;ð Ø—	’	‘”�å"Ô*°¸T¼XÈTÐSXÈMÐbhÐiÑiÔiˆDØ�JŠJ‰LŒLˆLØ"ˆI�d‰OˆOð ñ 	+Ý˜Y×-Ò-Ñ/Ô/Ñ0Ô0ð +ñ +�Ø—	’	˜#‘”�Øð ;à"ð ;Ý)¨&°)¸UÀKÐQ\Ð^eÑfÔfÐfÐfå  ¨°EÑ:Ô:Ð:Ø”=Ð(ØØ—’˜dœiÑ(Ô(Ð(Ø”= AÒ%Ð%Ø—L’L ¤Ñ+Ô+Ð+Ø!%�J�Jà!&�JØ!ð +ð +�DØ”y E¨$¤KÐ/Ð/Ø%ð 0Ø# yÐ0Ð0Ø )¨$¤× 9Ò 9Ñ ;Ô ;Ð ;Ý $¤
¨3¡¤ Ø˜dœ×*Ò*¨4¬9Ñ5Ô5Ð5Ø  œ;ð +¨v°d¬|×/BÒ/BÑ/DÔ/Dð +Ø˜tœ×(Ò(Ñ*Ô*Ð*øñ+ð# ñ 	+ð6 ñ 	ÝŒJ×ÒÐEÑFÔFÐFØˆIØð $ñ $�Øœ9œ>¨t¨M¨M¨MÑ9�ðHÝ˜h™œð A¨2ØŸš  1™œ˜Ø Ÿgšg™iœi˜Ø! D™j˜Ø š7˜7ØŸGšG C™LœL˜L˜LàŸGšG A™JœJ˜JØ#%§7¢7¡9¤9˜Ø"ð AÝœJ×,Ò,¨X¸¸D¸¸¸Ñ-CÀhÑ-NÐQUÑ-UÑVÔVÐVÝœJ×,Ò,¨R¯WªW©Y¬Y¸Ñ-?Ñ@Ô@Ð@ðAð Að Añ Aô Að Að Að Að Að Að Aøøøð Að Að Að Aøøõ )ð Hð Hð HØ&G¸XÐ&GÐ&G�I˜d‘O�O�OðHøøøå—	’	Ð4°dÑ;Ô;Ð;Ý—	’	˜(Ñ#Ô#Ð#Ñ#Øð #Ý”
× Ò Ñ"Ô"Ð"Øð Ý—	’	Ð/Ñ0Ô0Ð0Ø—’‘”�ÝŒH�Q‰KŒKˆKØð 	ÝŒJ�s‰OŒOˆOØð 3Ý! &¨)°U¸KÈÐV]Ñ^Ô^Ð^Ð^å˜ ¨EÑ2Ô2Ð2ÝŒJ×Ò˜TÑ"Ô"Ð"ÝŒJ×ÒÑÔÐØð 	Ý�IŠIÐ+Ñ,Ô,Ð,Ø�LŠL‰NŒNˆNˆNˆNð	ð 	s7   ÍQÍCP9Ð-QÐ9P=	Ð=QÑ P=	ÑQÑQÑQrˆ   c                ó¦   — g }t           j        dk    r>| j        r| j                             ¦   «         s|                     d| j        › d�¦  «         |S )zÝ
        Check pre-requsists for build.

        This method verifies all requrements for a successful build are satisfied.

        :return: Returns a list of string describing failed checks
        :rtype: list
        rœ   zToolchain for z) does not exist. Please pip install ppbt.)re   r,   rg   rA   r!  rP   )r_   r+  s     r'   Úcheck_prereqszBuilder.check_prereqsÞ  s\   € ð ˆÝŒ<˜7Ò"Ð"Ø”>ð c¨¬×)>Ò)>Ñ)@Ô)@ð cØ—’Ða¨T¬YÐaÐaÐaÑbÔbÐbØˆr)   ú
str | Noner  Údownload_onlyc
                óî  — t          j        d¦  «        }
|
                     t           j        ¦  «         d}|sOt          j        ¦   «         }|                     t          j        |¦  «        ¦  «         |
                     |¦  «         t          j        | j	        j
        d¬¦  «         t          j        | j	        j
        dz  ¦  «        }|                     t           j        ¦  «         |
                     |¦  «         |r|                      |¦  «         |�t          |¦  «        nt          | j        ¦  «        }|                      ¦   «         }|s[|rY|D ]$}t"          j                             |› d�¦  «         Œ%t"          j                             ¦   «          t#          j        d¦  «         |r|                      ¦   «          | j        | j        k    r_t2          dz  }|                     ¦   «         sAdt          j        v rt          j        d         }n| j        }d	d
lm}  |dt2          |¬¦  «         	 |                      ||||	¬¦  «         |r1	 |
                      |¦  «         |�|
                      |¦  «         dS dS |  !                    |||||	¬¦  «         |
                      |¦  «         |�|
                      |¦  «         dS dS # |
                      |¦  «         |�|
                      |¦  «         w w xY w)a  
        Set the architecture, define the steps, clean if needed, download what is needed, and build.

        :param steps: The steps to run, defaults to None
        :type steps: list, optional
        :param arch: The architecture to build, defaults to None
        :type arch: str, optional
        :param clean: If true, cleans the directories first, defaults to True
        :type clean: bool, optional
        :param cleanup: Cleans up after build if true, defaults to True
        :type cleanup: bool, optional
        :param force_download: Whether or not to download the content if it already exists, defaults to True
        :type force_download: bool, optional
        :param expanded_ui: Whether to use expanded UI with progress bars
        :type expanded_ui: bool, optional
        NTrµ   z	build.logr  r   rÆ   ÚRELENV_NATIVE_PY_VERSIONr   )Úcreate)r@   )r  r¯   r  )r¯   r±   r  )"rÊ   rË   rÍ   rÝ   rÌ   rÎ   rÏ   rÔ   rÕ   r    rX   rÜ   ÚINFOr˜   r§   r�   rC  re   rü   rý   r"  ré   r  r   rP   r	   rA   rá   r@   Úrelenv.createrH  r,  rå   rU   )r_   r  rP   r  rù   r  rE  r¯   r±   r  rä   rë   rî   r#  Úfailuresr&   rò   r@   rH  s                      r'   Ú__call__zBuilder.__call__í  s"  € õ8 Ô Ñ%Ô%ˆØ�Š•W”^Ñ$Ô$Ð$à15ˆØð 	+Ý$Ô2Ñ4Ô4ˆNØ×#Ò#¥GÔ$8¸Ñ$CÔ$CÑDÔDÐDØ�NŠN˜>Ñ*Ô*Ð*å
Œ�D”I”N¨TÐ2Ñ2Ô2Ð2ÝÔ*¨4¬9¬>¸KÑ+GÑHÔHˆØ×Ò�gœlÑ+Ô+Ð+Ø�Š�|Ñ$Ô$Ð$àð 	 Ø�MŠM˜$ÑÔÐà$)Ð$5•T˜%‘[”[�[½4ÀÄÑ;NÔ;Nˆ
à×%Ò%Ñ'Ô'ˆØð 	 ð 	Øð +ð +�Ý”
× Ò  A   Ñ*Ô*Ð*Ð*ÝŒJ×ÒÑÔÐÝŒH�Q‰KŒKˆKàð 	Ø�JŠJ‰LŒLˆLàŒ?˜dœiÒ'Ð'Ý" XÑ-ˆKØ×%Ò%Ñ'Ô'ð <Ø-µ´Ð;Ð;Ý œjÐ)CÔD�G�Gà"œl�GØ0Ð0Ð0Ð0Ð0Ð0à��x¥°7Ð;Ñ;Ô;Ð;ð	2Ø×ÒØØ-ØØ'ð	  ñ ô ð ð ð Øð ×Ò˜lÑ+Ô+Ð+ØÐ)Ø×!Ò! .Ñ1Ô1Ð1Ð1Ð1ð *Ð)ð �JŠJØØØØ#Ø'ð ñ ô ð ð ×Ò˜lÑ+Ô+Ð+ØÐ)Ø×!Ò! .Ñ1Ô1Ð1Ð1Ð1ð *Ð)øð ×Ò˜lÑ+Ô+Ð+ØÐ)Ø×!Ò! .Ñ1Ô1Ð1Ð1ð *øøøs   È/K É;K Ë/K4)NNNNrŽ   r?   )rT   r�   r�   r‘   r   r’   r“   r”   rP   r+   r@   r+   r"   r#   )rP   r+   r"   r#   r}   r~   r   )NNN)
r*   r+   r‡   r¢   r‰   r£   rV   r¤   r"   r#   )Fr«   N)r*   r+   r¬   r­   r‡   r®   rV   rŠ   r¯   r°   r±   r+   r²   r³   r"   r   ©r"   r#   )NFFF)
r  r£   r  r°   r¯   r°   r  r°   r"   r#   )NTFr«   F)r  r£   rù   r°   r¯   r°   r±   r+   r  r°   r"   r#   )r"   rˆ   )	NNTTFFFr«   F)r  r£   rP   rD  r  r°   rù   r°   r  r°   rE  r°   r¯   r°   r±   r+   r  r°   r"   r#   )r€   r�   r‚   rƒ   r`   r˜   r„   rg   rŸ   rS   rk   rª   rõ   rù   r  r,  rU   rC  rL  r%   r)   r'   r�   r�   ä   s	  € € € € € ðð ð& !%Ø-1ØZ^ØPTØØð!!ð !!ð !!ð !!ð !!ðF4ð 4ð 4ð 4ð ðð ð ñ „Xðð ð&ð &ð &ñ „Xð&ð ðBð Bð Bñ „XðBð ð,ð ,ð ,ñ „Xð,ð 15Ø(,Ø*.ð 
ð  
ð  
ð  
ð  
ðP Ø"Ø7;ðtð tð tð tð tðl#ð #ð #ð #ðð ð ð ð, '+Ø$ØØ!ðdð dð dð dð dðP '+ØØØ"Ø!ðEð Eð Eð Eð EðNð ð ð ð" '+ØØØØ$Ø#ØØ"Ø!ðY2ð Y2ð Y2ð Y2ð Y2ð Y2ð Y2r)   r�   c                  ó"   — e Zd ZdZdd„Zdd„ZdS )ÚBuildsz)Collection of platform-specific builders.r"   r#   c                ó   — i | _         dS )z+Initialize an empty collection of builders.N)Úbuildsrf   s    r'   r`   zBuilds.__init__L  s   € à*,ˆŒˆˆr)   r,   r+   r.  r   r  r�   c                ó¬   — d|v r9|                      d¦  «        }|s|rt          d¦  «        ‚t          d|¦  «        }nt          |i |¤Ž}|| j        |<   |S )z&Add a builder for a specific platform.Úbuilderz9builder keyword can not be used with other kwargs or argsr�   )r   ÚRuntimeErrorr   r�   rQ  )r_   r,   r.  r  Úbuild_candidaterU   s         r'   rª   z
Builds.addP  sr   € à˜ÐÐØ$Ÿjšj¨Ñ3Ô3ˆOØð `�vð `Ý"Ð#^Ñ_Ô_Ð_Ý˜ OÑ4Ô4ˆEˆEå˜TÐ, VÐ,Ð,ˆEØ %ˆŒ�HÑØˆr)   NrM  )r,   r+   r.  r   r  r   r"   r�   )r€   r�   r‚   rƒ   r`   rª   r%   r)   r'   rO  rO  I  sB   € € € € € Ø3Ð3ð-ð -ð -ð -ð
ð 
ð 
ð 
ð 
ð 
r)   rO  )r   r   r    r!   r"   r#   )r*   r+   r,   r+   r"   r-   )9rƒ   Ú
__future__r   rB   rÊ   r  rÔ   r÷   re   r[   r×   Útypingr   r   r   r   r   r�   r	   r
   r   r   r   r   r   r   r   Úbuildersr   r—   rV   r   Úuir   r   r   r   r   r   ÚpathlibÚcollections.abcr   r   r   r+   ÚPathLikerË   r€   rä   r(   rN   r“   r!   r†   r�   rO  rQ  r%   r)   r'   ú<module>r]     sä  ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø Ð Ð Ð Ø 	€	€	€	Ø €€€Ø 
€
€
€
Ø €€€Ø €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð ;Ð :Ð :Ð :Ð :Ð :Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð CØ€N€N€NØBÐBÐBÐBÐBÐBÐBÐBÐBÐBð �”˜SÔ!Ñ!€à€gÔ˜Ñ!Ô!€ðð ð ð ð)ð )ð )ð )ðZ %€ðe
ð e
ð e
ð e
ð e
ñ e
ô e
ð e
ðPð ð ð ð ˆYñ ô ð ðb	2ð b	2ð b	2ð b	2ð b	2ñ b	2ô b	2ð b	2ðJð ð ð ð ñ ô ð ð( 
ˆ‰Œ€€€r)   