
    VhI                     |    d dl mZmZmZ eZdZdZd dlZd dl	Zd dl
Z
d dlmZ d Zd ZddZd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functionas  
module: easy_install
short_description: Installs Python libraries
description:
  - Installs Python libraries, optionally in a C(virtualenv).
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  name:
    type: str
    description:
      - A Python library name.
    required: true
  virtualenv:
    type: str
    description:
      - An optional O(virtualenv) directory path to install into. If the O(virtualenv) does not exist, it is created automatically.
  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: false
  virtualenv_command:
    type: str
    description:
      - The command to create the virtual environment with. For example V(pyvenv), V(virtualenv), V(virtualenv2).
    default: virtualenv
  executable:
    type: str
    description:
      - The explicit executable or a pathname to the executable to be used to run easy_install for a specific version of Python
        installed in the system. For example V(easy_install-3.3), if there are both Python 2.7 and 3.3 installations in the
        system and you want to run easy_install for the Python 3.3 installation.
    default: easy_install
  state:
    type: str
    description:
      - The desired state of the library. V(latest) ensures that the latest version is installed.
    choices: [present, latest]
    default: present
notes:
  - Please note that the C(easy_install) module can only install Python libraries. Thus this module is not able to remove
    libraries. It is generally recommended to use the M(ansible.builtin.pip) module which you can first install using M(community.general.easy_install).
  - Also note that C(virtualenv) must be installed on the remote host if the O(virtualenv) parameter is specified.
requirements: ["virtualenv"]
author: "Matt Wright (@mattupstate)"
z
- name: Install or update pip
  community.general.easy_install:
    name: pip
    state: latest

- name: Install Bottle into the specified virtualenv
  community.general.easy_install:
    name: bottle
    virtualenv: /webapps/myapp/venv
N)AnsibleModulec                 h    |ddj                  |      d|}| j                  |      \  }}}|||fS )N )joinrun_command)modulenameeasy_installexecutable_argumentscmdrcouterrs           r/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/easy_install.pyinstall_packager   U   s:    $chh/C&Dd
KC%%c*LBSsC<    c                     |d d  }|j                  d       t        | |||      \  }}}|r| j                  |       d|vS )Nz	--dry-run)msgDownloading)appendr   	fail_json)r   r   r   r   r   r   r   s          r   _is_package_installedr   [   sQ    /2,"64?STLBS	S!##r   c                    dg}d }|4t         j                  j                  |      r|}n|j                  d|       |)|g }nd|z  g}|D ]  }| j	                  |d|      }| n ||d   }| j	                  |d      }|S )Nr   r   z%s/binFT)ospathisabsinsertget_bin_path)r   env
executablecandidate_easy_inst_basenamesr   opt_dirsbasenames          r   _get_easy_installr'   e   s    %3$4!L77==$%L)00J?;H !3'H5 	H!..xIL'	 03**8T8Dr   c                  D   t        t        d      t        ddddgd      t        d d      t        dd	
      t        dd      t        dd            } t        | d      }|j                  d   }|j                  d   }|j                  d   }|j                  d   }|j                  d   }g }|j                  d   dk(  r|j                  d       d}d}	d}
|r|j	                  |d      }t
        j                  j                  t
        j                  j                  |dd            sf|j                  r|j                  d       |d|}|r|dz  }t        j                         }|j                  ||      \  }}}||z  }|
|z  }
|	|z  }	t        |||      }d }d}t        ||||      }|sA|j                  r|j                  d       t!        ||||      \  }}}||z  }|
|z  }
|	|z  }	d}|dk7  r|j#                  |	|       |j                  ||||       y )NT)requiredFpresentlateststr)r)   defaultchoicestype)r-   r)   bool)r-   r/   
virtualenvr   )r   stater1   virtualenv_site_packagesvirtualenv_commandr#   )argument_specsupports_check_moder   r#   r3   r4   r2   z	--upgrader    binactivate)changedr   z --system-site-packages)cwd)r   r   )r:   binaryr   r1   )dictr   paramsr   r!   r   r   existsr	   
check_mode	exit_jsontempfile
gettempdirr
   r'   r   r   r   )arg_specr   r   r"   r#   site_packagesr4   r   r   r   r   r1   commandr;   rc_venvout_venverr_venvr   r   r:   	installedrc_easy_instout_easy_insterr_easy_insts                           r   mainrN      sG   4 E$%x0 u5!%e&!AuE?
H tLF== D
--
%C|,JMM"<=M';<}}W)##K0	
B
C
C
(();TB
ww~~bggll3zBC     .!+S1G44%%'C*0*<*<W#*<*N'GXx'MB8OC8OC$VS*=L
CG%fdLBVWIT*5DVTS_au5v2m]
l}}	QwSc*
W\3  0r   __main__)NN)
__future__r   r   r   r/   __metaclass__DOCUMENTATIONEXAMPLESr   os.pathrB   ansible.module_utils.basicr   r   r   r'   rN   __name__ r   r   <module>rX      sZ    A @5n
 
   4$4A0H zF r   