HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/pyenv.cpython-310.pyc
o

�N�g>�@s�dZddlZddlZddlZddlZe�e�ZddiZddd�Z	d(dd�Z
d)d	d
�Zd)dd�Zd)d
d�Z
d)dd�Zd)dd�Zd*dd�Zd*dd�Zd)dd�Zd)dd�Zd)dd�Zd)dd�Zd*dd �Zd)d!d�Zd)d"d#�Zd*d$d%�Zd)d&d'�ZdS)+z�
Manage python installations with pyenv.

.. note::
    Git needs to be installed and available via PATH if pyenv is to be
    installed automatically by the module.

.. versionadded:: 2014.4.0
�N�list_�list)�
pyenv.root�pyenv.build_env�cCs�t|�sdSt|�}t|�}|rd|��}|pd}d|�|�d|��}td|�d|�d|��|d�}t|t�r?|�|�|S|ddkrI|d	SdS)
NF� rzenv PYENV_ROOT=�cmd.run_all��runas�retcoder�stdout)�is_installed�
_pyenv_bin�_pyenv_path�__salt__�
isinstance�dict�update)Zcommand�args�envr
�ret�binary�path�result�r�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/pyenv.py�_pyenv_execs
 

rcCst|�}|�d�S)Nz
/bin/pyenv)r�r
rrrrr4s
rcCsBd}|dvrtdd�p
d}ntdd�pd|�d�}tj�|�S)N)N�root�
config.optionrz/usr/local/pyenv�~z/.pyenv)r�osr�
expanduserrrrrr9s
rcCs*tj�|�rdSdtdd|��|d�kS)NTr�cmd.retcodez,git clone https://github.com/yyuu/pyenv.git r	)r!r�isdirr�rr
rrr�_install_pyenvCs

�r&cCs2tj�|�sdSdtddt�|��d�|d�kS)NFrr#�cd � && git pullr	�r!rr$r�shlex�quoter%rrr�
_update_pyenvLs
�r,cCs<|�d�}tj�|�s
dSdtddt�|��d�|d�kS)Nz/plugins/python-buildFrr#r'r(r	r)r%rrr�_update_python_buildUs
�r-cC�"|pt|�}tj�|�}t||�S)zn
    Install pyenv systemwide

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.install
    )rr!rr"r&rrrr�install_s

r/cCr.)z�
    Updates the current versions of pyenv and python-Build

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.update
    )rr!rr"r,rrrrrns

rcCstdt|��S)zw
    Check if pyenv is installed.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.is_installed
    zcmd.has_exec)rrr	rrrr
~s
r
cCs�t�dd|�}d}g}tddvr|�d�tdd�r%|�tdd��|r,d	�|�}i}td
||||d�}|dd
krFt|d�|dSt||d�dS)z�
    Install a python implementation.

    python
        The version of python to install, should match one of the
        versions listed by pyenv.list

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.install_python 2.0.0-p0
    �^python-rNr!)ZFreeBSDZNetBSDZOpenBSDz
MAKE=gmakerrrr/)rr
rrrr	�stderrF)	�re�subZ
__grains__�appendr�joinr�rehash�uninstall_python)�pythonr
r�env_listrrrr�install_python�s 


r:cCs*t�dd|�}d|��}td||d�dS)a)
    Uninstall a python implementation.

    python
        The version of python to uninstall. Should match one of the versions
        listed by :mod:`pyenv.versions <salt.modules.pyenv.versions>`

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.uninstall_python 2.0.0-p0
    r0rz--force Z	uninstallr	T)r2r3r)r8r
rrrrr7�s
r7cCs"tdd|d�}|dur
gS|��S)z}
    List the installed versions of python.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.versions
    �versionsz--barer	F)r�
splitlines)r
rrrrr;�s
r;cCs6|rtd||d�dStd|d�}|durdS|��S)a�
    Returns or sets the currently defined default python.

    python=None
        The version to set as the default. Should match one of the versions
        listed by :mod:`pyenv.versions <salt.modules.pyenv.versions>`. Leave
        blank to return the current default.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.default
        salt '*' pyenv.default 2.0.0-p0
    �globalr	TFr)r�strip)r8r
rrrr�default�s
r?cCs@g}tdd|d�}|r|��D]}|dkrq|�|���q|S)z{
    List the installable versions of python.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.list
    r/z--listr	zAvailable versions:)rr<r4r>)r
r�output�linerrrr�s
cCstd|d�dS)z�
    Run pyenv rehash to update the installed shims.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.rehash
    r6r	T)rr	rrrr6s
r6cCsvt|�}|��}d}|D]}|dt�|�}qtddt�|��d|��|dd�}|dd	kr9t|d
�|dSdS)
z�
    Execute a python command with pyenv's shims from the user or the system.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.do 'gem list bundler'
        salt '*' pyenv.do 'gem list bundler' deploy
    rrrz	env PATH=z
/shims:$PATH T)r
Zpython_shellrrr	rF)r�splitr*r+rr6)�cmdliner
rZ	cmd_splitZquoted_line�cmdrrrr�dos�
rEcCs&|rd|�d|��}n|}t||d�S)a
    Execute a python command with pyenv's shims using a specific python version.

    CLI Example:

    .. code-block:: bash

        salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler'
        salt '*' pyenv.do_with_python 2.0.0-p0 'gem list bundler' deploy
    zPYENV_VERSION=rr	)rE)r8rCr
rDrrr�do_with_python,srF)rNNN)N)NN)�__doc__�loggingr!r2r*�	getLogger�__name__�logZ__func_alias__Z__opts__rrrr&r,r-r/rr
r:r7r;r?rr6rErFrrrr�<module>s6

�





	
	





'