File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/pip.cpython-310.pyc
o
�N�g�� � @ s d Z ddlZddlZddlZddlZddlZddlZddlZddlZ ddl
Z ddlZ ddlZ ddl
Z ddlZ ddlZ ddlZ ddlmZmZ e�e�ZddiZg d�Ze�dej�Ze�dej�Zd d
� Zdd� Zd6d
d�Zdd� Z dd� Z!dd� Z"dd� Z#dd� Z$dd� Z%dd� Z&dd� Z' d7d!d"�Z( d8d#d$�Z)d9d%d&�Z* d:d'd(�Z+d:d)d�Z,d;d*d+�Z-d;d,d-�Z.d;d.d/�Z/d;d0d1�Z0d<d2d3�Z1 d=d4d5�Z2dS )>a
Install Python packages with pip to either the system or a virtualenv
Windows Support
===============
.. versionadded:: 2014.7.4
Salt now uses a portable python. As a result the entire pip module is now
functional on the salt installation itself. You can pip install dependencies
for your custom modules. You can even upgrade salt itself using pip. For this
to work properly, you must specify the Current Working Directory (``cwd``) and
the Pip Binary (``bin_env``) salt should use. The variable ``pip_bin`` can be
either a virtualenv path or the path to the pip binary itself.
For example, the following command will list all software installed using pip
to your current salt environment:
.. code-block:: bat
salt <minion> pip.list cwd='C:\salt\bin\Scripts' bin_env='C:\salt\bin\Scripts\pip.exe'
Specifying the ``cwd`` and ``bin_env`` options ensures you're modifying the
salt environment. If these are omitted, it will default to the local
installation of python. If python is not installed locally it will fail saying
it couldn't find pip.
State File Support
------------------
This functionality works in states as well. If you need to pip install colorama
with a state, for example, the following will work:
.. code-block:: yaml
install_colorama:
pip.installed:
- name: colorama
- cwd: 'C:\salt\bin\scripts'
- bin_env: 'C:\salt\bin\scripts\pip.exe'
- upgrade: True
Upgrading Salt using Pip
------------------------
You can now update salt using pip to any version from the 2014.7 branch
forward. Previous version require recompiling some of the dependencies which is
painful in windows.
To do this you just use pip with git to update to the version you want and then
restart the service. Here is a sample state file that upgrades salt to the head
of the 2015.5 branch:
.. code-block:: yaml
install_salt:
pip.installed:
- cwd: 'C:\salt\bin\scripts'
- bin_env: 'C:\salt\bin\scripts\pip.exe'
- editable: git+https://github.com/saltstack/salt@2015.5#egg=salt
- upgrade: True
restart_service:
service.running:
- name: salt-minion
- enable: True
- watch:
- pip: install_salt
.. note::
If you're having problems, you might try doubling the back slashes. For
example, cwd: 'C:\\salt\\bin\\scripts'. Sometimes python thinks the single
back slash is an escape character.
There is a known incompatibility between Python2 pip>=10.* and Salt <=2018.3.0.
The issue is described here: https://github.com/saltstack/salt/issues/46163
� N)�CommandExecutionError�CommandNotFoundError�list_�list)�http�https�ftp�filez"(?:-r\s|--requirement[=\s])(.*)\n?z
(?:^|\s+)#.*$c C s dS )z�
There is no way to verify that pip is installed without inspecting the
entire filesystem. If it's not installed in a conventional location, the
user is required to provide the location of pip each time it is used.
�pip� r r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/pip.py�__virtual__o s r
c C s<