HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/modules/__pycache__/pip.cpython-39.pyc
a

�)g�w�@s�ddlmZmZmZeZdZdZdZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZdZzddlmZdZWney�d	Ze��ZYn0dd
lmZddlmZmZmZddlm Z dd
l!m"Z"ddd�Z#e
�$d�Z%e
j&e
j'e
j(e
j)e
j*e
j+e
j&d�Z,dd�Z-dd�Z.dd�Z/dd�Z0dd�Z1dd�Z2d.dd �Z3d!d"�Z4d#d$�Z5d/d%d&�Z6d'd(�Z7Gd)d*�d*�Z8d+d,�Z9e:d-k�r�e9�dS)0�)�absolute_import�division�print_functiona�
---
module: pip
short_description: Manages Python library dependencies
description:
     - "Manage Python library dependencies. To use this module, one of the following keys is required: C(name)
       or C(requirements)."
version_added: "0.7"
options:
  name:
    description:
      - The name of a Python library to install or the url(bzr+,hg+,git+,svn+) of the remote package.
      - This can be a list (since 2.2) and contain version specifiers (since 2.7).
    type: list
    elements: str
  version:
    description:
      - The version number to install of the Python library specified in the I(name) parameter.
    type: str
  requirements:
    description:
      - The path to a pip requirements file, which should be local to the remote system.
        File can be specified as a relative path if using the chdir option.
    type: str
  virtualenv:
    description:
      - An optional path to a I(virtualenv) directory to install into.
        It cannot be specified together with the 'executable' parameter
        (added in 2.1).
        If the virtualenv does not exist, it will be created before installing
        packages. The optional virtualenv_site_packages, virtualenv_command,
        and virtualenv_python options affect the creation of the virtualenv.
    type: path
  virtualenv_site_packages:
    description:
      - Whether the virtual environment will inherit packages from the
        global site-packages directory.  Note that if this setting is
        changed on an already existing virtual environment it will not
        have any effect, the environment must be deleted and newly
        created.
    type: bool
    default: "no"
    version_added: "1.0"
  virtualenv_command:
    description:
      - The command or a pathname to the command to create the virtual
        environment with. For example C(pyvenv), C(virtualenv),
        C(virtualenv2), C(~/bin/virtualenv), C(/usr/local/bin/virtualenv).
    type: path
    default: virtualenv
    version_added: "1.1"
  virtualenv_python:
    description:
      - The Python executable used for creating the virtual environment.
        For example C(python3.5), C(python2.7). When not specified, the
        Python version used to run the ansible module is used. This parameter
        should not be used when C(virtualenv_command) is using C(pyvenv) or
        the C(-m venv) module.
    type: str
    version_added: "2.0"
  state:
    description:
      - The state of module
      - The 'forcereinstall' option is only available in Ansible 2.1 and above.
    type: str
    choices: [ absent, forcereinstall, latest, present ]
    default: present
  extra_args:
    description:
      - Extra arguments passed to pip.
    type: str
    version_added: "1.0"
  editable:
    description:
      - Pass the editable flag.
    type: bool
    default: 'no'
    version_added: "2.0"
  chdir:
    description:
      - cd into this directory before running the command
    type: path
    version_added: "1.3"
  executable:
    description:
      - The explicit executable or pathname for the pip executable,
        if different from the Ansible Python interpreter. For
        example C(pip3.3), if there are both Python 2.7 and 3.3 installations
        in the system and you want to run pip for the Python 3.3 installation.
      - Mutually exclusive with I(virtualenv) (added in 2.1).
      - Does not affect the Ansible Python interpreter.
      - The setuptools package must be installed for both the Ansible Python interpreter
        and for the version of Python specified by this option.
    type: path
    version_added: "1.3"
  umask:
    description:
      - The system umask to apply before installing the pip package. This is
        useful, for example, when installing on systems that have a very
        restrictive umask by default (e.g., "0077") and you want to pip install
        packages which are to be used by all users. Note that this requires you
        to specify desired umask mode as an octal string, (e.g., "0022").
    type: str
    version_added: "2.1"
extends_documentation_fragment:
  -  action_common_attributes
attributes:
    check_mode:
        support: full
    diff_mode:
        support: none
    platform:
        platforms: posix
notes:
   - Python installations marked externally-managed (as defined by PEP668) cannot be updated by pip versions >= 23.0.1 without the use of
     a virtual environment or setting the environment variable ``PIP_BREAK_SYSTEM_PACKAGES=1``.
   - The virtualenv (U(http://www.virtualenv.org/)) must be
     installed on the remote host if the virtualenv parameter is specified and
     the virtualenv needs to be created.
   - Although it executes using the Ansible Python interpreter, the pip module shells out to
     run the actual pip command, so it can use any pip version you specify with I(executable).
     By default, it uses the pip version for the Ansible Python interpreter. For example, pip3 on python 3, and pip2 or pip on python 2.
   - The interpreter used by Ansible
     (see R(ansible_python_interpreter, ansible_python_interpreter))
     requires the setuptools package, regardless of the version of pip set with
     the I(executable) option.
requirements:
- pip
- virtualenv
- setuptools
author:
- Matt Wright (@mattupstate)
ad
- name: Install bottle python package
  ansible.builtin.pip:
    name: bottle

- name: Install bottle python package on version 0.11
  ansible.builtin.pip:
    name: bottle==0.11

- name: Install bottle python package with version specifiers
  ansible.builtin.pip:
    name: bottle>0.10,<0.20,!=0.11

- name: Install multi python packages with version specifiers
  ansible.builtin.pip:
    name:
      - django>1.11.0,<1.12.0
      - bottle>0.10,<0.20,!=0.11

- name: Install python package using a proxy
  ansible.builtin.pip:
    name: six
  environment:
    http_proxy: 'http://127.0.0.1:8080'
    https_proxy: 'https://127.0.0.1:8080'

# You do not have to supply '-e' option in extra_args
- name: Install MyApp using one of the remote protocols (bzr+,hg+,git+,svn+)
  ansible.builtin.pip:
    name: svn+http://myrepo/svn/MyApp#egg=MyApp

- name: Install MyApp using one of the remote protocols (bzr+,hg+,git+)
  ansible.builtin.pip:
    name: git+http://myrepo/app/MyApp

- name: Install MyApp from local tarball
  ansible.builtin.pip:
    name: file:///path/to/MyApp.tar.gz

- name: Install bottle into the specified (virtualenv), inheriting none of the globally installed modules
  ansible.builtin.pip:
    name: bottle
    virtualenv: /my_app/venv

- name: Install bottle into the specified (virtualenv), inheriting globally installed modules
  ansible.builtin.pip:
    name: bottle
    virtualenv: /my_app/venv
    virtualenv_site_packages: yes

- name: Install bottle into the specified (virtualenv), using Python 2.7
  ansible.builtin.pip:
    name: bottle
    virtualenv: /my_app/venv
    virtualenv_command: virtualenv-2.7

- name: Install bottle within a user home directory
  ansible.builtin.pip:
    name: bottle
    extra_args: --user

- name: Install specified python requirements
  ansible.builtin.pip:
    requirements: /my_app/requirements.txt

- name: Install specified python requirements in indicated (virtualenv)
  ansible.builtin.pip:
    requirements: /my_app/requirements.txt
    virtualenv: /my_app/venv

- name: Install specified python requirements and custom Index URL
  ansible.builtin.pip:
    requirements: /my_app/requirements.txt
    extra_args: -i https://example.com/pypi/simple

- name: Install specified python requirements offline from a local directory with downloaded packages
  ansible.builtin.pip:
    requirements: /my_app/requirements.txt
    extra_args: "--no-index --find-links=file:///my_downloaded_packages_dir"

- name: Install bottle for Python 3.3 specifically, using the 'pip3.3' executable
  ansible.builtin.pip:
    name: bottle
    executable: pip3.3

- name: Install bottle, forcing reinstallation if it's already installed
  ansible.builtin.pip:
    name: bottle
    state: forcereinstall

- name: Install bottle while ensuring the umask is 0022 (to ensure other users can use it)
  ansible.builtin.pip:
    name: bottle
    umask: "0022"
  become: True
a�
cmd:
  description: pip command used by the module
  returned: success
  type: str
  sample: pip2 install ansible six
name:
  description: list of python modules targeted by pip
  returned: success
  type: list
  sample: ['ansible', 'six']
requirements:
  description: Path to the requirements file
  returned: success, if a requirements file was provided
  type: str
  sample: "/srv/git/project/requirements.txt"
version:
  description: Version of the package specified in 'name'
  returned: success, if a name and version were provided
  type: str
  sample: "2.5.1"
virtualenv:
  description: Path to the virtualenv
  returned: success, if a virtualenv path was provided
  type: str
  sample: "/tmp/virtualenv"
N)�LooseVersion)�RequirementTF��	to_native)�
AnsibleModule�
is_executable�missing_required_lib)�get_best_parsable_locale)�PY3z0import setuptools; print(setuptools.__version__)zJimport pkg_resources; print(pkg_resources.get_distribution("pip").version)��
setuptools�pipz(svn|git|hg|bzr)\+)z>=z<=�>�<�==z!=z~=cCst�t|�S)z(Test whether a name is a vcs url or not.)�re�match�_VCS_RE��name�r�7/usr/lib/python3.9/site-packages/ansible/modules/pip.py�_is_vcs_url3srcCs|���tt����S)z?Test whether the name is a package name or a version specifier.)�lstrip�
startswith�tuple�op_dict�keysrrrr�_is_package_name8sr!cCs�g}|D]}|�|�d��q|}g}g}d}|D]N}t|�rZ|sZ|rV|�d�|��g}d|vrfd}|rvd|vrvd}|�|�q2|�d�|��|S)a�Recover package names as list from user's raw input.

    :input: a mixed and invalid list of names or version specifiers
    :return: a list of valid package name

    eg.
    input: ['django>1.11.1', '<1.11.3', 'ipaddress', 'simpleproject>1.1.0', '<2.0.0']
    return: ['django>1.11.1,<1.11.3', 'ipaddress', 'simpleproject>1.1.0,<2.0.0']

    input: ['django>1.11.1,<1.11.3,ipaddress', 'simpleproject>1.1.0,<2.0.0']
    return: ['django>1.11.1,<1.11.3', 'ipaddress', 'simpleproject>1.1.0,<2.0.0']
    �,F�[T�])�extend�splitr!�append�join)�names�tmpZone_lineZ
name_partsZ
package_namesZin_bracketsrrrr�_recover_package_name=s&r+cCsV|d}|�|�\}}}|dkr8|jd|||fd�|����}dd�|D�}|S)Nz --helprz Could not get output from %s: %s��msgcSsg|]}|�d�r|�qS)z--�r)�.0�xrrr�
<listcomp>i�z$_get_cmd_options.<locals>.<listcomp>)�run_command�	fail_json�stripr&)�module�cmdZthiscmd�rc�stdout�stderr�wordsZcmd_optionsrrr�_get_cmd_optionsbsr<c	Cs�|ddg}t|�}|||d�}|j|||d�\}}}|dkrr|dg}|j||d�\}}}|dkrrt||||�d�|�||fS)	z.Return results of pip command to get packages.�listz--format=freeze)�LANG�LC_ALL�LC_MESSAGES)�cwdZenviron_updaterZfreeze�rA� )rr3�_failr()	r6r�chdirZcommand�localeZlang_envr8�out�errrrr�
_get_packagesms
rIcCsL|D]B}d|vr|�d�\}}t�|�}nq||jkr|�|�rdSqdS)z+Return whether or not package is installed.rTF)r&�Package�canonicalize_name�package_name�is_satisfied_by)r6ZreqZinstalled_pkgsZpkg_command�pkg�pkg_nameZpkg_versionrrr�_is_presentsrPc	Cs.d}trd}d}|dur2tj�|�r*|}qT|f}n"|durT|durTt�rTtjddg}|du�r|dur�g}|D]}|�|d|�}|durnq�qn|jdd�	|�d�nrtj�	|d	�}|d
df}|D]0}tj�	||�}tj�
|�r�t|�r�|}�qq�|jd|d
d�	|�dd�t|t
��s*|g}|S)N)Zpip2r)Zpip3z-mzpip.__main__Fz<Unable to find any of %s to use.  pip needs to be installed.z, r,�binrrz*Unable to find pip in the virtualenv, %s, zunder any of these names: %s. z+Make sure pip is present in the virtualenv.)r
�os�path�isabs�_have_pip_module�sys�
executable�get_bin_pathr4r(�existsr
�
isinstancer=)	r6�envrWZcandidate_pip_basenamesr�opt_dirs�basenameZvenv_dir�	candidaterrr�_get_pip�sF
�

��r_cCs�zddlm}Wnty&d}Yn0|rVzt|d��}Wq�tyRd}Yq�0n2ddl}z|�d�Wnty�d}Yn0d}|S)zjReturn True if the `pip` module can be found using the current Python interpreter, otherwise return False.r)�	find_specNrFT)�importlib.utilr`�ImportError�bool�	Exception�imp�find_module)r`�foundrerrrrU�s 

rUcCs:d}|r|d|f7}|r(|d|f7}|j||d�dS)N�z
stdout: %sz
:stderr: %s)r7r-)r4)r6r7rGrHr-rrrrD�srDc	Csh|rd|g}ng}|�dd|�}|dur0d}n4|�|dt|g�\}}}|rTd}nd||��f}|S)aThis is only needed for special packages which do not show up in pip freeze

    pip and setuptools fall into this category.

    :returns: a string containing the version number if the package is
        installed.  None if the package is not installed.
    z%s/binZpythonFNz-cz%s==%s)rXr3�_SPECIAL_PACKAGE_CHECKERSr5)	r6�packager[r\Z
python_bin�
formatted_depr8rGrHrrr�_get_package_info�srlcs2�jr�jdd�t��jd�}tj�|d�|dkrN��|dd�|d<�jdrd|�	d�n t
�|d�}d|vr�|�	d��jd}t�fd	d
�dD��s�|r�|�	d|�q�tr�|�	dt
j�n�jdr�jd
d�|�	|��j||d�\}}	}
||	7}||
7}|dk�r*t�|||�||fS)NT��changed�virtualenv_commandr�virtualenv_site_packagesz--system-site-packagesz--no-site-packages�virtualenv_pythonc3s|]}|�jdvVqdS)roN)�params)r/�ex�r6rr�	<genexpr>"r2z#setup_virtualenv.<locals>.<genexpr>)Zpyvenvz-m venvz-p%sz_virtualenv_python should not be used when using the venv module or pyvenv as virtualenv_commandr,rB)�
check_mode�	exit_json�shlexr&rrrRrSr]rXr'r<�anyr
rVrWr4r3rD)r6r[rErGrHr7Zcmd_optsrqr8Zout_venvZerr_venvrrtr�setup_virtualenv	s6



�

rzc@sLeZdZdZe�d�Zddd�Zedd��Z	dd	�Z
ed
d��Zdd
�Z
dS)rJz�Python distribution package metadata wrapper.

    A wrapper class for Requirement, which provides
    API to parse package name, version specifier,
    test whether a package is already satisfied.
    z[-_.]+Nc
Cs�d|_||_d|_|r@|��}|d��r.dnd}|�||f�}zJt�|�|_|jjdkrrd|vrrd|_d|j_nt	�
|jj�|_d|_Wn$ty�}zWYd}~n
d}~00dS)NFrrrCZ
distributerT)�_plain_packagerL�_requirementr�isdigitr(r�parseZproject_namerJrK�
ValueError)�selfZname_stringZversion_string�	separator�errr�__init__Is 

zPackage.__init__cCs|jrt|jj�SdS)NF)r{rcr|�specs�r�rrr�has_version_specifier^szPackage.has_version_specifiercsX|js
dSz|jjj�dd�WStyRt���t�fdd�|jjD��YS0dS)NFT)Zprereleasesc3s$|]\}}t|�t|��VqdS�N)rr)r/�opZver��version_to_testrrruls�z*Package.is_satisfied_by.<locals>.<genexpr>)r{r|Z	specifier�contains�AttributeErrorr�allr�)r�r�rr�rrMds�zPackage.is_satisfied_bycCstj�d|���S)N�-)rJ�_CANONICALIZE_RE�sub�lowerrrrrrKqszPackage.canonicalize_namecCs|jrt|j�S|jSr�)r{rr|rLr�rrr�__str__vs
zPackage.__str__)N)�__name__�
__module__�__qualname__�__doc__r�compiler�r��propertyr�rM�staticmethodrKr�rrrrrJ?s




rJc!Cs�tdgddgddggd�d�}tttddt|���d	�td
dd�tdd�tdd�td
d�tddd�td
dd�tdd�tdd�tddd�td
d�td
d�tdd�d�
ddggddgddggdd�}ts�|jtd�td�|jd}|jd}|jd}|jd}|jd}|jd}|jd}|jd}	d}
|	�rD|�rDt	j
�||	�}	|�r�t|t
��s�zt
|d�}Wn.t�y�|jd tt��d!�d"�Yn0d}|du�r�t	�|�}�z|d#k�r�|du�r�|jd$d%�|du�r�t��}d&}d&}
|	�r"t	j
�t	j
�|	d'd(���s"d}
t||	||
|�\}
}t||	|jd�}|||}d}|	�rXt	j
�|	d'�}d}|�r�|D] }|�rft|��rfd}�q��qfd)d*�t|�D�}|du�r�t|�d!k�r�|jd+d%�|d,j�r�|jd-d%�tt|d,�|�|d,<|jd.�r*g}|�r|�d/�}d0|v�r*|�d0�d/�|�}|�r@|�t �|��|�r\|�d1d2�|D��n&|�rr|�d3|g�n|j!dd4gd5�|j"�r�|�s�|�s�|d#k�s�|�s�|j!dd6�t#|||�\}}}|
|7}
||7}d}|�r�d7d*�|
�d8�D�}|�$d9��rTd:|v�sd|v�rTd;D]<}||v�rt%|||	�}|du�r|�|�|
d<|7}
�q|D]>}t&||||�}|dk�rz|�r�|d=k�rX|�rXd}�q��qX|j!|||
|d>�d}|�s�|�r�t#|||�\}}}|j'|||d?�\}}}|
|7}
||7}|d!k�r|d=k�rd@|v�s4d@|v�rn|d,k�r4t(|||
|�|d=k�rHdA|v}n.|du�r\dB|v}nt#|||�\}} }|| k}|�p~|
}|j!|||||||	|
|dC�	W|du�r�t	�|�n|du�r�t	�|�0dS)DN�installZ	uninstallz-y�-U)r�r�z--force-reinstall)�present�absent�latestZforcereinstall�strr�)�type�default�choicesr=)r��elements)r�rSrcF)r�r��
virtualenv)
�stater�version�requirementsr�rprorq�
extra_args�editablerErW�umaskrr�rWT)Z
argument_specZrequired_one_ofZmutually_exclusiveZsupports_check_moder)r-�	exceptionr�r�r�rEr��zumask must be an octal integer�)r-�detailsr�z)version is incompatible with state=latestr,rhrQZactivatecSsg|]}t|��qSr)rJ)r/rNrrrr1�r2zmain.<locals>.<listcomp>z�'version' argument is ambiguous when installing multiple package distributions. Please specify version restrictions next to each package in 'name' argument.rz�The 'version' argument conflicts with any version specifier provided along with a package name. Please keep the version specifier, but remove the 'version' argument.r�rCz-ecss|]}t|�VqdSr�r�r/�prrrru�r2zmain.<locals>.<genexpr>z-rz)No valid name or requirements file found.)rn�warningsrmcSs(g|] }|�d�s|�d�s|r|�qS)z
You are usingzYou should considerr.r�rrrr1
r2�
z freezerrz%s
r�)rnr7r9r:)�path_prefixrAz
not installedzSuccessfully uninstalledzSuccessfully installed)	rnr7rr�r�r�r�r9r:))�dictr	r=r �HAS_SETUPTOOLSr4r�SETUPTOOLS_IMP_ERRrrrRrSr(rZ�intrdrrV�exc_infor��tempfileZ
gettempdirrYrzr_rr+�lenr�rJr&r'r%rxrwrvrI�endswithrlrPr3rD)!Z	state_mapr6r�rr�r�r�rEr�r[Zvenv_createdZ	old_umaskrHrGrr7r�Zhas_vcsrNZpackagesZ	args_listZpkg_cmdZout_pipZerr_piprnZpkg_listrkrjZ
is_presentZout_freeze_before�_r8Zout_freeze_afterrrr�main|s0�



��
�







�




��



� 


 
��





�
�
r��__main__)NN)N);Z
__future__rrrr�Z
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNrRrrVr��operatorrx�	traceback�typesZ#ansible.module_utils.compat.versionrr�Z
pkg_resourcesrr�rb�
format_excZansible.module_utils._textrZansible.module_utils.basicr	r
rZ"ansible.module_utils.common.localerZansible.module_utils.sixr
rir�r�ge�le�gt�lt�eq�nerrr!r+r<rIrPr_rUrDrlrzrJr�r�rrrr�<module>s`a�
�%
;	
6=F