1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix the editable condition into pip module (#19028) (#19688)

* Fix the editable condition into pip module (#19028)

* Add editable to tests

Default changed to False, so now editable: True is needed explicitly in
tests
This commit is contained in:
Lujeni 2017-07-14 11:54:04 +02:00 committed by John R Barker
parent 44730c28cc
commit 661791dcb7
2 changed files with 16 additions and 21 deletions

View file

@ -104,9 +104,9 @@ options:
version_added: "1.0" version_added: "1.0"
editable: editable:
description: description:
- Pass the editable flag for versioning URLs. - Pass the editable flag.
required: false required: false
default: yes default: false
version_added: "2.0" version_added: "2.0"
chdir: chdir:
description: description:
@ -161,10 +161,9 @@ EXAMPLES = '''
- pip: - pip:
name: svn+http://myrepo/svn/MyApp#egg=MyApp name: svn+http://myrepo/svn/MyApp#egg=MyApp
# Install MyApp using one of the remote protocols (bzr+,hg+,git+) in a non editable way. # Install MyApp using one of the remote protocols (bzr+,hg+,git+).
- pip: - pip:
name: git+http://myrepo/app/MyApp name: git+http://myrepo/app/MyApp
editable: false
# Install (MyApp) from local tarball # Install (MyApp) from local tarball
- pip: - pip:
@ -401,7 +400,7 @@ def main():
virtualenv_python=dict(type='str'), virtualenv_python=dict(type='str'),
use_mirrors=dict(default=True, type='bool'), use_mirrors=dict(default=True, type='bool'),
extra_args=dict(), extra_args=dict(),
editable=dict(default=True, type='bool'), editable=dict(default=False, type='bool'),
chdir=dict(type='path'), chdir=dict(type='path'),
executable=dict(type='path'), executable=dict(type='path'),
umask=dict(), umask=dict(),
@ -511,7 +510,7 @@ def main():
has_vcs = True has_vcs = True
break break
if has_vcs and module.params['editable']: if module.params['editable']:
args_list = [] # used if extra_args is not used at all args_list = [] # used if extra_args is not used at all
if extra_args: if extra_args:
args_list = extra_args.split(' ') args_list = extra_args.split(' ')
@ -533,8 +532,6 @@ def main():
if module.check_mode: if module.check_mode:
if extra_args or requirements or state == 'latest' or not name: if extra_args or requirements or state == 'latest' or not name:
module.exit_json(changed=True) module.exit_json(changed=True)
elif has_vcs:
module.exit_json(changed=True)
pkg_cmd, out_pip, err_pip = _get_packages(module, pip, chdir) pkg_cmd, out_pip, err_pip = _get_packages(module, pip, chdir)
@ -563,10 +560,9 @@ def main():
break break
module.exit_json(changed=changed, cmd=pkg_cmd, stdout=out, stderr=err) module.exit_json(changed=changed, cmd=pkg_cmd, stdout=out, stderr=err)
out_freeze_before = None
if requirements or has_vcs: if requirements or has_vcs:
_, out_freeze_before, _ = _get_packages(module, pip, chdir) _, out_freeze_before, _ = _get_packages(module, pip, chdir)
else:
out_freeze_before = None
rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=chdir) rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=chdir)
out += out_pip out += out_pip
@ -579,9 +575,6 @@ def main():
if state == 'absent': if state == 'absent':
changed = 'Successfully uninstalled' in out_pip changed = 'Successfully uninstalled' in out_pip
else:
if out_freeze_before is None:
changed = 'Successfully installed' in out_pip
else: else:
if out_freeze_before is None: if out_freeze_before is None:
changed = 'Successfully installed' in out_pip changed = 'Successfully installed' in out_pip

View file

@ -80,7 +80,7 @@
# Test virtualenv installations # Test virtualenv installations
- name: make sure the test env doesn't exist - name: "make sure the test env doesn't exist"
file: state=absent name={{ output_dir }}/pipenv file: state=absent name={{ output_dir }}/pipenv
- name: install a working version of setuptools in the virtualenv - name: install a working version of setuptools in the virtualenv
@ -100,22 +100,24 @@
that: that:
- "req_installed.changed" - "req_installed.changed"
- name: repeat installation to check status didn't change - name: "repeat installation to check status didn't change"
pip: requirements={{ output_dir}}/pipreq.txt pip: requirements={{ output_dir}}/pipreq.txt
virtualenv={{ output_dir }}/pipenv virtualenv={{ output_dir }}/pipenv
register: req_installed register: req_installed
- name: check that a change didn't occurr this time (bug ansible#1705) - name: "check that a change didn't occurr this time (bug ansible#1705)"
assert: assert:
that: that:
- "not req_installed.changed" - "not req_installed.changed"
- name: install the same module from url - name: install the same module from url
pip: name="git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601" pip:
virtualenv={{ output_dir }}/pipenv name: "git+https://github.com/dvarrazzo/pyiso8601#egg=pyiso8601"
virtualenv: "{{ output_dir }}/pipenv"
editable: True
register: url_installed register: url_installed
- name: check that a change didn't occurr (bug ansible-modules-core#1645) - name: "check that a change didn't occurr (bug ansible-modules-core#1645)"
assert: assert:
that: that:
- "not url_installed.changed" - "not url_installed.changed"