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/states/__pycache__/pip_state.cpython-310.pyc
o

�N�gʙ�@sdZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
zddlZdZWne
y5dZYnwdd�Zdd	�Zd
d�ZzddlZdZWne
yXdZe�Ynwedur�eed�sgeje_nejejkrxe�ddlZeje_ejjjejd
dd�r�ddlmZnejjjejd
dd�r�ddlmZneZe�e�ZdZ dd�Z!dd�Z"dd�Z#dd�Z$	d%dd�Z%d%dd�Z&																																													d&dd �Z'								d'd!d"�Z(d(d#d$�Z)dS))a�
Installation of Python Packages Using pip
=========================================

These states manage system installed python packages. Note that pip must be
installed for these states to be available, so pip states should include a
requisite to a pkg.installed state for the package which provides pip
(``python-pip`` in most cases). Example:

.. code-block:: yaml

    python-pip:
      pkg.installed

    virtualenvwrapper:
      pip.installed:
        - require:
          - pkg: python-pip
�N)�CommandExecutionError�CommandNotFoundErrorTFcCs�dtjvrdSdd�tj��D�}|D]\}}tj�|�~qdt�vr(t�d=dt�vr1t�d=tj�dd�}|dur?~dSdS)z'
    Purge pip and its sub-modules
    �pipNcSsBg|]\}}t|dd��d�st|tj�r|j�d�r||f�qS)�
__module__�zpip.)�getattr�
startswith�
isinstance�types�
ModuleType�__name__)�.0�k�v�r�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/pip_state.py�
<listcomp>0s�
�
��zpurge_pip.<locals>.<listcomp>)�sys�modules�items�pop�globals�locals)Zpip_related_entries�name�entryZsys_modules_piprrr�	purge_pip)s 
�

�rcCstjjj|ddd�S)zM
    True when the pip version has the `pip._internal.exceptions` module
    �>=�10.0��ver1�oper�ver2)�salt�utils�versions�compare��verrrr�pip_has_internal_exceptions_modCs
�r(cCs t|�rdStjjj|ddd�S)zC
    True when the pip version has the `pip.exceptions` module
    Fr�1.0r)r(r"r#r$r%r&rrr�pip_has_exceptions_modNsr*�__pip_ver__rrr)�InstallationErrorr)rcOs�ddl}tjjj|jddd�rddl}|jjj	j
|i|��Stjjj|jddd�r8ddl}|jjjj
|i|��Sddl}|jjj
|i|��S)Nrrz18.1rr)rr"r#r$r%�__version__Zpip._internal.req.constructorsZ	_internal�reqZconstructorsZinstall_req_from_lineZpip._internal.req�InstallRequirementZ	from_lineZpip.req)�args�kwargsrrrr�
_from_linezsr2cCstdurdSdtvrtSdS)z>
    Only load if the pip module is available in __salt__
    F)Fz1The pkg_resources python library is not installed�pip.list)�HAS_PKG_RESOURCES�__salt__�__virtualname__rrrr�__virtual__�s
r7cCs8|D]\}}|durqtjjj|||td�sdSqdS)z�
    Check version number against version specification info and return a
    boolean value based on whether or not the version number meets the
    specified version.
    N)rr r!Zcmp_funcFT)r"r#r$r%�_pep440_version_cmp)�version�version_specr �specrrr�_fulfills_version_spec�s��r<c
Cs�ddddd�}tsd|d<|Sd}zDz
t�dtj�t|�}Wn4tySt�d�d}|�|�rM|D]}|�|�rKd	}t|�|�d
��d�}nq4nt|�}YnwWn;t	t
fy�}z-d|d<|s|d
|vr|d|vr|d�|�|d<|WYd}~Sd�||�|d<|WYd}~Sd}~ww|jdur�d	|d<d|d<g|d<|Sd	|d<z|jj
|d<|jj|d<W|Sty�t�dd|j�|d<t|d�r�|j}n|jj}dd�|D�|d<Y|Sw)zj
    Takes a package name and version specification (if any) and checks it using
    the pip library.
    FN)�result�comment�prefixr:z�An importable Python pip module is required but could not be found on your system. This usually means that the system's pip package is not installed properly.r>zInstalled pip version: %sz'Installed pip version is lower than 1.2)�git�svnZhgZbzrT�+���r=�=�==zTInvalid version specification in package {}. '=' is not supported, use '==' instead.z.pip raised an exception while parsing '{}': {}rr?r:z[^A-Za-z0-9.]+�-�	specifiercSsg|]}|j|jf�qSr)�operatorr9)r
r;rrrr�sz-_check_pkg_version_format.<locals>.<listcomp>)�HAS_PIP�logger�debugrr-r2�AttributeErrorr�split�
ValueErrorr,�formatr.Zproject_nameZspecs�	Exception�re�subr�hasattrrG)�pkg�retZfrom_vcsZinstall_reqZ
supported_vcsZvcs�excrGrrr�_check_pkg_version_format�sp�


���������

�	�
�rWc
Ks�ddd�}tjj�|ptd|f||||	d�|
���}|dur�||vr�|durE|sEt|�r4t|||�s8t|�sEd|d<d�|�|d	<|S|dur�|r�d}d}d}t|�rr|D]}d
|dvrad}d|dvrid}d
|dvrqd}qWtd||||||||
|d�	}d}t|�r�|r�t|�D]}t||�r�|}nq�n|r�|d}|s�d|d<d�|�|d	<|St	|||�dkr�d|d<d�|�|d	<|S|S)a"
    Takes a package name and version specification (if any) and checks it is
    installed

    Keyword arguments include:
        pip_list: optional dict of installed pip packages, and their versions,
            to search through to check if the package is installed. If not
            provided, one will be generated in this function by querying the
            system.

    Returns:
     result: None means the command failed to run
     result: True means the package is installed
     result: False means the package is not installed
    FN�r=r>r3��bin_env�user�cwd�env_varsTr=z'Python package {} was already installedr>�a��b�rczpip.list_all_versions)rZ�
include_alpha�include_beta�
include_rcr[r\�	index_url�extra_index_urlrrCzkPython package {} was already installed and
the available upgrade doesn't fulfills the version requirementsr)
r"r#�data�CaseInsensitiveDictr5�anyr<rO�reversedr8)r?�state_pkg_namer:�ignore_installed�force_reinstall�upgrader[r\rZr]rerf�pip_listr1rUrbrcrdr;Zavailable_versionsZdesired_versionr9rrr�_check_if_installed�s�
����	������
����rpc
s�tdurt�d�dS�fdd�}||�}||�}z*t�|�t�|�kr'WdSt�|�t�|�kr4WdSt�|�t�|�krAWdSWdSty^}zt�d	|||�WYd}~dSd}~ww)
z�
    Compares two version strings using pkg_resources.parse_version.
    Return -1 if version1 < version2, 0 if version1 ==version2,
    and 1 if version1 > version2. Return None if there was a problem
    making the comparison.
    FzEThe pkg_resources packages was not loaded. Please install setuptools.Ncs �rt|��dd�dSt|�S)N�!r_rC)�strrM)�x��ignore_epochrr�	normalizefs z&_pep440_version_cmp.<locals>.normalizerCrr_z7Comparison of package versions "%s" and "%s" failed: %s)r4rJ�warning�
pkg_resourcesZ
parse_versionrP�	exception)Zpkg1Zpkg2rurvrVrrtrr8Ys0������r8c.Qs	|r|s|}|rt|t�s|didd�Sn|g}dd���fdd�|D�}d�|�d	d
id�}/ztd|�}0Wn$ttfy[}1zd|/d
<d|�d|1��|/d<|/WYd	}1~1Sd	}1~1ww|r�d}2d}3tjjj	|0d|2d�}4tjjj	|0d|3d�}5|4sz|5r�d|/d
<d�
|2|3|0�|/d<|/S|r�d}2d}3tjjj	|0d|2d�}4tjjj	|0d|3d�}5|4s�|5r�d|/d
<d�
|2|3|0�|/d<|/S|,r�d}2tjjj	|0d|2d�}4|4r�d|/d
<d�
|2|0�|/d<|/Sg}6|�r!|�s!|�s!g}7t|�D]+}8t|8�}9|9d
dur�d|/d
<|7�
|9d�q�|9d
du�r|6�
|9d|8|9df�q�|/d
du�r!d�|7�|/d<|/S|�r>dtv�r>td|��s>d|/d
<d|�d �|/d<|/Sg}:g};|�sH|�rtg}7td!�rsd	|/d
<|�r_|7�
d"|�d#��|�rj|7�
d$�
|��d%�|7�|/d<|/Sn�ztd&||| |'d'�}<Wnt�y�}=zt�d(|=�d}<WYd	}=~=nd	}=~=ww|6D]�\}>}?}@|>�r�t|>|?|@||||| ||'|
||<f
i|.��}9|9d
d	u�r�d|/d
<|9d|/d<|/Sndd	d)�}9|9d
}A|Adu�r|:�
|>|?�d*d�f�td!�rt|6�d+k�rd,}B|6D]}8|Bd7}B|B|8d+7}B|B|/d<�q�n	d-}B|B�
|?�|/d<d	|/d
<|/S�q�|Adu�r-|;�
|9d��q�|Ad	u�r@d	|/d
<|9d|/d<|/S�q�|:�sfd|/d
<d�|;�}Cd.|�rTd/nd
}D|C|C�r]dnd
|D|/d<|/Sd*�d0d�|:D��}Etd1d{id2|E�r||E�nd
�d3|�d4|�d5|�d6|�d7|,�d8|�d9|�d:|	�d;|�d<|�d=|
�d>|�d?|�d@|�dA|�dB|�dC|�dD|�dE|�dF|�dG|�dH|�dI|�dJ|�dK|�dL|�dM|�dN|�dO|�dP| �dQ|!�dR|"�dS|#�dT|$�dU|%�dV|&�dWt�dX|'�dY|(�dZ|)�d[|*�d\|-�d]d�|.��}F|F�r|F�d^d+�d_k�rd|/d
<|�s|�rqg}7|�rWgd`�}G|F�dad
��d�D]�t�fdbd�|GD���s?d|/dcd3<�q+|/dc�d3��rR|7�
dd�
|��n|7�
de�|�rh|7�
df�
|��d|/dcd;<d%�|7�|/d<|/Sg}Ht�}I|F�dad
��d�D]���dg��r���dhd+�d+��d_}J|I�|J����q|:D]O\}>}K|>�r�tjj�td&|>|f|| |'di�|.���}L|L�s�|H�
dj�
|8���q�|>|Lv�r�|>��|Iv�r�|L|>}Mdk|/dc|>�dl|M��<�q�dk|/dc|K�dm�<�q�d�|;�}C|H�s�dnnd�|H�}N|C|C�rdnd
|N|/d<|/S|F�r~d|/d
<da|Fv�r#do�
|Fda|Fdp�}Ondq�
|Fd�}O|�s0|�rXg}7|�r>|7�
dr|�ds��|�rJ|7�
dt|�du��|7�
|O�d%�|7�|/d<|/Sdv�dwd�|:D��}Ed�|;�}Cdx|E�dy|O��}P|C|C�rudnd
|P|/d<|/Sd|/d
<dz|/d<|/S)|a�
    Make sure the package is installed

    name
        The name of the python package to install. You can also specify version
        numbers here using the standard operators ``==, >=, <=``. If
        ``requirements`` is given, this parameter will be ignored.

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - name: django >= 1.6, <= 1.7
            - require:
              - pkg: python-pip

    This will install the latest Django version greater than 1.6 but less
    than 1.7.

    requirements
        Path to a pip requirements file. If the path begins with salt://
        the file will be transferred from the master file server.

    user
        The user under which to run pip

    use_wheel : False
        Prefer wheel archives (requires pip>=1.4)

    no_use_wheel : False
        Force to not use wheel archives (requires pip>=1.4)

    no_binary
        Force to not use binary packages (requires pip >= 7.0.0)
        Accepts either :all: to disable all binary packages, :none: to empty the set,
        or a list of one or more packages

    Example:

    .. code-block:: yaml

        django:
          pip.installed:
            - no_binary: ':all:'

        flask:
          pip.installed:
            - no_binary:
              - itsdangerous
              - click

    log
        Log file where a complete (maximum verbosity) record will be kept

    proxy
        Specify a proxy in the form
        user:passwd@proxy.server:port. Note that the
        user:password@ is optional and required only if you
        are behind an authenticated proxy.  If you provide
        user@proxy.server:port then you will be prompted for a
        password.

    timeout
        Set the socket timeout (default 15 seconds)

    editable
        install something editable (i.e.
        git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed)

    find_links
        URL to look for packages at

    index_url
        Base URL of Python Package Index

    extra_index_url
        Extra URLs of package indexes to use in addition to ``index_url``

    no_index
        Ignore package index

    mirrors
        Specific mirror URL(s) to query (automatically adds --use-mirrors)

    build
        Unpack packages into ``build`` dir

    target
        Install packages into ``target`` dir

    download
        Download packages into ``download`` instead of installing them

    download_cache
        Cache downloaded packages in ``download_cache`` dir

    source
        Check out ``editable`` packages into ``source`` dir

    upgrade
        Upgrade all packages to the newest available version

    force_reinstall
        When upgrading, reinstall all packages even if they are already
        up-to-date.

    ignore_installed
        Ignore the installed packages (reinstalling instead)

    exists_action
        Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
        (b)ackup

    no_deps
        Ignore package dependencies

    no_install
        Download and unpack all packages, but don't actually install them

    no_cache_dir:
        Disable the cache.

    cwd
        Current working directory to run pip from

    pre_releases
        Include pre-releases in the available versions

    cert
        Provide a path to an alternate CA bundle

    allow_all_external
        Allow the installation of all externally hosted files

    allow_external
        Allow the installation of externally hosted files (comma separated list)

    allow_unverified
        Allow the installation of insecure and unverifiable files (comma separated list)

    process_dependency_links
        Enable the processing of dependency links

    env_vars
        Add or modify environment variables. Useful for tweaking build steps,
        such as specifying INCLUDE or LIBRARY paths in Makefiles, build scripts or
        compiler calls.  This must be in the form of a dictionary or a mapping.

        Example:

        .. code-block:: yaml

            django:
              pip.installed:
                - name: django_app
                - env_vars:
                    CUSTOM_PATH: /opt/django_app
                    VERBOSE: True

    use_vt
        Use VT terminal emulation (see output while installing)

    trusted_host
        Mark this host as trusted, even though it does not have valid or any
        HTTPS.

    bin_env : None
        Absolute path to a virtual environment directory or absolute path to
        a pip executable. The example below assumes a virtual environment
        has been created at ``/foo/.virtualenvs/bar``.

        Example:

        .. code-block:: yaml

            django:
            pip.installed:
                - name: django >= 1.6, <= 1.7
                - bin_env: /foo/.virtualenvs/bar
                - require:
                - pkg: python-pip

        Or

        Example:

        .. code-block:: yaml

            django:
            pip.installed:
                - name: django >= 1.6, <= 1.7
                - bin_env: /foo/.virtualenvs/bar/bin/pip
                - require:
                - pkg: python-pip

    .. admonition:: Attention

        The following arguments are deprecated, do not use.

    pip_bin : None
        Deprecated, use ``bin_env``

    .. versionchanged:: 0.17.0
        ``use_wheel`` option added.

    install_options

        Extra arguments to be supplied to the setup.py install command.
        If you are using an option with a directory path, be sure to use
        absolute path.

        Example:

        .. code-block:: yaml

            django:
              pip.installed:
                - name: django
                - install_options:
                  - --prefix=/blah
                - require:
                  - pkg: python-pip

    global_options
        Extra global options to be supplied to the setup.py call before the
        install command.

        .. versionadded:: 2014.1.3

    .. admonition:: Attention

        As of Salt 0.17.0 the pip state **needs** an importable pip module.
        This usually means having the system's pip package installed or running
        Salt from an active `virtualenv`_.

        The reason for this requirement is because ``pip`` already does a
        pretty good job parsing its own requirements. It makes no sense for
        Salt to do ``pip`` requirements parsing and validation before passing
        them to the ``pip`` library. It's functionality duplication and it's
        more error prone.


    .. admonition:: Attention

        Please set ``reload_modules: True`` to have the salt minion
        import this module after installation.


    Example:

    .. code-block:: yaml

        pyopenssl:
            pip.installed:
                - name: pyOpenSSL
                - reload_modules: True
                - exists_action: i

    extra_args
        pip keyword and positional arguments not yet implemented in salt

        .. code-block:: yaml

            pandas:
              pip.installed:
                - name: pandas
                - extra_args:
                  - --latest-pip-kwarg: param
                  - --latest-pip-arg

        .. warning::

            If unsupported options are passed here that are not supported in a
            minion's version of pip, a `No such option error` will be thrown.


    .. _`virtualenv`: http://www.virtualenv.org/en/latest/

    If you are using onedir packages and you need to install python packages into
    the system python environment, you must provide the pip_bin or
    bin_env to the pip state module.


    .. code-block:: yaml

        lib-foo:
          pip.installed:
            - pip_bin: /usr/bin/pip3
        lib-bar:
          pip.installed:
            - bin_env: /usr/bin/python3
    Fz)pkgs argument must be formatted as a list)rr=�changesr>cSs4t|t�r|Sd�|��dd|��ddf�S)N� rr_)r	rr�joinr)rTrrr�prepro�s
��$�zinstalled.<locals>.preprocsg|]}�|��qSrr)r
rT)r}rrr��zinstalled.<locals>.<listcomp>�;Nr�rr=r>rzzpip.versionr=zError installing '�': r>z1.4z9.0.3�<r�>zfThe 'use_wheel' option is only supported in pip between {} and {}. The version of pip detected was {}.ziThe 'no_use_wheel' option is only supported in pip between {} and {}. The version of pip detected was {}.z7.0.0zaThe 'no_binary' option is only supported in pip {} and newer. The version of pip detected was {}.Tr?r:�
z	user.infozUser z does not exist�testzRequirements file 'z' will be processed.zTPackage will be installed in editable mode (i.e. setuptools "develop mode") from {}.r{r3rYz]Pre-caching of PIP packages during states.pip.installed failed by exception from pip.list: %srX�,r_z&Python package(s) set to be installed:z)Python package {0} is set to be installedz,All specified packages are already installedz and up-to-datecS�g|]\}}|�qSrr�r
�_�
state_namerrrr�r~zpip.install�pkgs�requirementsrZ�	use_wheel�no_use_wheel�	no_binary�log�proxy�timeout�editable�
find_linksrerf�no_index�mirrors�build�target�download�download_cache�sourcernrmrl�
exists_action�no_deps�
no_install�no_download�install_options�global_optionsr[r\�pre_releases�cert�allow_all_external�allow_external�allow_unverified�process_dependency_linksZsaltenvr]�use_vt�trusted_host�no_cache_dir�
extra_argsZdisable_version_check�retcoder)zRequirement already satisfiedzRequirement already up-to-datezRequirement not upgradedZ
CollectingZCloningzCleaning up...zLooking in indexes�stdoutcsg|]	}����|��qSr)�stripr)r
rs)�linerrr�srzz,Successfully processed requirements file {}.z$Requirements were already installed.z4Package successfully installed from VCS checkout {}.z Requirement already up-to-date: �:)r[r\r]z_There was no error installing package '{}' although it does not show when calling 'pip.freeze'.Z	InstalledrEz==???z(All packages were successfully installedzError: {} {}�stderrz	Error: {}z%Unable to process requirements file "�"z$Unable to install from VCS checkout �.z, cSr�rrr�rrrrZr~zFailed to install packages: z. zCould not install packager)r	�listr|r5rrr"r#r$r%rO�iterrW�append�__opts__rPrJryrp�replace�lenZ__env__�getrMri�setr�add�lowerrgrh)Qrr�Zpip_binr�rZr�r�r�r�r�Zrepor�r�rerfr�r�r�r�r�r�r�rnrmrlr�r�r�r�r�r�r[r\r�r�r�r�r�r�r]r�r�r�Z	cache_dirr�r�r1rUZcur_version�errZmin_versionZmax_versionZtoo_lowZtoo_highZpkgs_detailsZcommentsrT�outZtarget_pkgsZalready_installed_commentsrorVr?rkr:r=�msgZaicomms�	last_lineZpkgs_strZpip_install_callZPIP_REQUIREMENTS_NOCHANGEZ
pkg_404_commsZalready_installed_packages�packager�Z	pipsearchr'Z	succ_comm�errorZ
error_commr)r�r}r�	installedzs�Y
������
���
����

���
�������


��

�
����������	�
���
������������������� �!�"�#�$�%�&�'�(�)�*�+�,�0	����
��V������
�
�
��
�

�
�r�c	Cs|ddid�}	ztd|||d�}
Wn$ttfy6}zd|	d<d|�d	|��|	d
<|	WYd}~Sd}~ww||
vrEd|	d<d|	d
<|	Std
rWd|	d<d|�d�|	d
<|	Std|||||||||d�	rvd|	d<d|	d|<d|	d
<|	Sd|	d<d|	d
<|	S)a,
    Make sure that a package is not installed.

    name
        The name of the package to uninstall
    user
        The user under which to run pip
    bin_env : None
        the pip executable or virtualenenv to use
    use_vt
        Use VT terminal emulation (see output while installing)
    Nrr�r3�rZr[r\Fr=zError uninstalling 'r�r>TzPackage is not installed.r�zPackage z is set to be removedz
pip.uninstall)	r�r�rZr�r�r�r[r\r�ZRemovedrzz!Package was successfully removed.zCould not remove package.)r5rrr�)rr�rZr�r�r�r[r\r�rUror�rrr�removedesF����r�c	
Cs�|iddd�}ztd|||d�}Wnty,}zt|�|d<|WYd}~Sd}~ww|s9d|d<d	|d
<|StdrGd|d<d|d
<|Std
||||d�}|�d
�dur_|�|�|S|ro||d<d|d<d	|d
<|Sd|d<|S)ax
    .. versionadded:: 2015.5.0

    Verify that the system is completely up to date.

    name
        The name has no functional value and is only used as a tracking
        reference
    user
        The user under which to run pip
    bin_env
        the pip executable or virtualenenv to use
    use_vt
        Use VT terminal emulation (see output while installing)
    FzFailed to update.)rrzr=r>zpip.list_upgradesr�r>NzSystem is already up-to-date.Tr=r�zSystem update will be performedzpip.upgrade)rZr[r\r�rzzUpgrade successful.zUpgrade failed.)r5rPrrr�r��update)	rrZr[r\r�rUZpackages�e�updatedrrr�uptodate�s:���
��r�)F)-NNNNFFNNNNNNNNFNNNNNNFFFNFFFNNNNFNFNNFNFNFNNN)NNNNNNNF)NNNF)*�__doc__�loggingrQrr
Zsalt.utils.datar"Zsalt.utils.versionsZsalt.exceptionsrrrxr4�ImportErrorrr(r*rrIrSr-r+r#r$r%Zpip._internal.exceptionsr,Zpip.exceptionsrN�	getLoggerrrJr6r2r7r<rWrpr8r�r�r�rrrr�<module>s��	
�


V
�
j#
�r
�>