HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/relenv/__pycache__/create.cpython-310.pyc
o

�N�gZ�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZej
dd��ZGdd	�d	e	�Zd
d�Zddd
�Zdd�ZdS)z 
The ``relenv create`` command.
�N�)�platform_versions)�RelenvException�arches�archived_build�
build_archc	cs8�t��}zt�|�dVWt�|�dSt�|�w)z�
    Context manager that changes to the specified directory and back.

    :param path: The path to temporarily change to
    :type path: str
    N)�os�getcwd�chdir)�path�cwd�r
�A/opt/saltstack/salt/lib/python3.10/site-packages/relenv/create.pyr
s�
r
c@seZdZdZdS)�CreateExceptionzJ
    Raised when there is an issue creating a new relenv environment.
    N)�__name__�
__module__�__qualname__�__doc__r
r
r
rr!srcCsd|jddd�}|jtd�|jddd�|jdt�ttjtd	d
�|jdt	�dt	�td
d
�dS)z�
    Setup the subparser for the ``create`` command.

    :param subparsers: The subparsers object returned from ``add_subparsers``
    :type subparsers: argparse._SubParsersAction
    �createzrCreate a Relenv environment. This will create a directory of the given name with newly created Relenv environment.)�description)�func�namez#The name of the directory to create)�helpz--archz,The host architecture [default: %(default)s])�default�choices�typerz--pythonrz)The python version [default: %(default)s]N)
�
add_parser�set_defaults�main�add_argumentrr�sys�platform�strr)Z
subparsersZ	subparserr
r
r�setup_parser's(��
�r#c
CsX|durt�}|rt�|�|}nt�|���}|dur!t�d}t�|���r,td��tj}|dkrD|t	|vr@d�
||�}n0td��|dkrX|t	|vrTd�
|�}ntd��|d	krl|t	|vrhd
�
|�}ntd��td��t|�d|���}|��s�td
|�d|�d���t�
|d��}|D]}	|�|	|�q�Wd�dS1s�wYdS)ai
    Create a relenv environment.

    :param name: The name of the environment
    :type name: str
    :param dest: The path the environment should be created under
    :type dest: str
    :param arch: The architecture to create the environment for
    :type arch: str

    :raises CreateException: If there is a problem in creating the relenv environment
    Nrz"The requested path already exists.�linuxz	{}-{}-gnuzUnknown arch�darwinz{}-macos�win32z{}-winzUnknown platform�-zError, build archive for z doesn't exist: z,
You might try relenv fetch to resolve this.zr:xz)r�pathlib�Path�resolver�existsrr r!r�formatr�tarfile�open�extract)
r�dest�arch�versionZwriteto�plat�triplet�tar�fp�fr
r
rrGsB

��"�rc
Csl|j}|jt�kr
td�zt||j|jd�WdSty5}zt|�t�d�WYd}~dSd}~ww)z�
    The entrypoint into the ``relenv create`` command.

    :param args: The args passed to the command
    :type args: argparse.Namespace
    zVWarning: Cross compilation support is experimental and is not fully tested or working!)r1r2rN)	rr1r�printr�pythonrr �exit)�argsr�excr
r
rr�s���r)NNN)r�
contextlibrr(r r-�buildr�commonrrrr�contextmanagerr
rr#rrr
r
r
r�<module>s

 :