mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2875 from yeukhon/devel
Pip's name key can now accept remote package address.
This commit is contained in:
commit
9a19e8a8ae
1 changed files with 36 additions and 6 deletions
|
@ -26,12 +26,13 @@ DOCUMENTATION = '''
|
||||||
module: pip
|
module: pip
|
||||||
short_description: Manages Python library dependencies.
|
short_description: Manages Python library dependencies.
|
||||||
description:
|
description:
|
||||||
- Manage Python library dependencies.
|
- Manage Python library dependencies. To use this module, one of the following keys is required: C(name)
|
||||||
|
or C(requirements).
|
||||||
version_added: "0.7"
|
version_added: "0.7"
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
- The name of a Python library to install
|
- The name of a Python library to install or the url of the remote package.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
version:
|
version:
|
||||||
|
@ -93,6 +94,8 @@ examples:
|
||||||
description: Install I(flask) python package.
|
description: Install I(flask) python package.
|
||||||
- code: "pip: name=flask version=0.8"
|
- code: "pip: name=flask version=0.8"
|
||||||
description: Install I(flask) python package on version 0.8.
|
description: Install I(flask) python package on version 0.8.
|
||||||
|
- code: "pip: name='svn+http://myrepo/svn/MyApp#egg=MyApp'"
|
||||||
|
description: Install I(MyApp) using one of the remote protocols (bzr+,hg+,git+,svn+) or tarballs (zip, gz, bz2) C(pip) supports. You do not have to supply '-e' option in extra_args. For these source names, C(use_mirrors) is ignored and not applicable.
|
||||||
- code: "pip: name=flask virtualenv=/my_app/venv"
|
- code: "pip: name=flask virtualenv=/my_app/venv"
|
||||||
description: "Install I(Flask) (U(http://flask.pocoo.org/)) into the specified I(virtualenv), inheriting none of the globally installed modules"
|
description: "Install I(Flask) (U(http://flask.pocoo.org/)) into the specified I(virtualenv), inheriting none of the globally installed modules"
|
||||||
- code: "pip: name=flask virtualenv=/my_app/venv virtualenv_site_packages=yes"
|
- code: "pip: name=flask virtualenv=/my_app/venv virtualenv_site_packages=yes"
|
||||||
|
@ -180,8 +183,22 @@ def main():
|
||||||
|
|
||||||
if state == 'latest' and version is not None:
|
if state == 'latest' and version is not None:
|
||||||
module.fail_json(msg='version is incompatible with state=latest')
|
module.fail_json(msg='version is incompatible with state=latest')
|
||||||
if name and '=' in name:
|
|
||||||
module.fail_json(msg='version must be specified in the version parameter')
|
# pip can accept a path to a local project or a VCS url beginning
|
||||||
|
# with svn+, git+, hg+, or bz+ and these sources usually do not qualify
|
||||||
|
# --use-mirrors. Furthermore, the -e option is applied only when
|
||||||
|
# source is a VCS url. Therefore, we will have branch cases for each
|
||||||
|
# type of sources.
|
||||||
|
#
|
||||||
|
# is_vcs includes those begin with svn+, git+, hg+ or bzr+
|
||||||
|
# is_tar ends with .zip, .tar.gz, or .tar.bz2
|
||||||
|
is_vcs = False
|
||||||
|
is_tar = False
|
||||||
|
if name.endswith('.tar.gz') or name.endswith('.tar.bz2') or name.endswith('.zip'):
|
||||||
|
is_tar = True
|
||||||
|
elif name.startswith('svn+') or name.startswith('git+') or \
|
||||||
|
name.startswith('hg+') or name.startswith('bzr+'):
|
||||||
|
is_vcs = True
|
||||||
|
|
||||||
err = ''
|
err = ''
|
||||||
out = ''
|
out = ''
|
||||||
|
@ -208,7 +225,20 @@ def main():
|
||||||
pip = _get_pip(module, env)
|
pip = _get_pip(module, env)
|
||||||
|
|
||||||
cmd = '%s %s' % (pip, state_map[state])
|
cmd = '%s %s' % (pip, state_map[state])
|
||||||
if state != 'absent' and use_mirrors:
|
|
||||||
|
|
||||||
|
# If is_vcs=True, we must add -e option (we assume users won't add that to extra_args).
|
||||||
|
if is_vcs:
|
||||||
|
args_list = [] # used if extra_args is not used at all
|
||||||
|
if extra_args:
|
||||||
|
args_list = extra_args.split(' ')
|
||||||
|
if '-e' not in args_list:
|
||||||
|
args_list.append('-e')
|
||||||
|
# Ok, we will reconstruct the option string
|
||||||
|
extra_args = ' '.join(args_list)
|
||||||
|
# for tarball or vcs source, applying --use-mirrors doesn't really make sense
|
||||||
|
is_package = is_vcs or is_tar # just a shortcut for bool
|
||||||
|
if not is_package and state != 'absent' and use_mirrors:
|
||||||
cmd += ' --use-mirrors'
|
cmd += ' --use-mirrors'
|
||||||
if extra_args:
|
if extra_args:
|
||||||
cmd += ' %s' % extra_args
|
cmd += ' %s' % extra_args
|
||||||
|
|
Loading…
Reference in a new issue