Davide Sbetti 3 days ago committed by GitHub
commit d727732867
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- pip - Incorrect changed status was returned in case of installation from VCS where the target commit was different but the version was the same. The fix now evaluates also the commits used for installation from VCS (https://github.com/ansible/ansible/issues/81751).

@ -419,19 +419,20 @@ def _get_cmd_options(module, cmd):
def _get_packages(module, pip, chdir):
"""Return results of pip command to get packages."""
# Try 'pip list' command first.
command = pip + ['list', '--format=freeze']
list_command = pip + ['list', '--format=freeze']
locale = get_best_parsable_locale(module)
lang_env = {'LANG': locale, 'LC_ALL': locale, 'LC_MESSAGES': locale}
rc, out, err = module.run_command(command, cwd=chdir, environ_update=lang_env)
_rc, list_out, list_err = module.run_command(list_command, cwd=chdir, environ_update=lang_env)
# If there was an error (pip version too old) then use 'pip freeze'.
# Use also pip freeze, since pip list does not show the commit used
# in case of installation from VCS.
# We keep the already existing behaviour of failing only if the freeze command fails
freeze_command = pip + ['freeze']
rc, freeze_out, freeze_err = module.run_command(freeze_command, cwd=chdir)
if rc != 0:
command = pip + ['freeze']
rc, out, err = module.run_command(command, cwd=chdir)
if rc != 0:
_fail(module, command, out, err)
_fail(module, freeze_command, freeze_out, freeze_err)
return ' '.join(command), out, err
return ' '.join(list_command + [";"] + freeze_command), list_out + freeze_out, list_err + freeze_err
def _is_present(module, req, installed_pkgs, pkg_command):

@ -129,6 +129,53 @@
that:
- "not (url_installed is changed)"
# Note: this is needed due to an issue of pip 9.0.3 and python 3.6 to install
# non refs commit (reproduced on RHEL 8.8 trying to run 'pip3 install -e git+https://github.com/dvarrazzo/pyiso8601@8bfaaa3e5c63a9eda4449e606786802f4e95ba60#egg=iso8601')
- name: update git refs for backcompatibility with pip 9.0.3
shell: "git update-ref refs/heads/test 8bfaaa3e5c63a9eda4449e606786802f4e95ba60; git update-ref refs/heads/test1 a48aa33f9fe5aa77d40fa2a38584750570d38ad6"
args:
chdir: "{{ remote_tmp_dir }}/pipenv/src/iso8601/"
- name: install the same module from url pointing to a specific commit
pip:
name: "git+https://github.com/dvarrazzo/pyiso8601@test#egg=iso8601"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
editable: true
state: latest
register: url_installed_specific_commit
- name: verify we recorded a change
assert:
that:
- "url_installed_specific_commit is changed"
- name: install the same module from url pointing to the same specific commit
pip:
name: "git+https://github.com/dvarrazzo/pyiso8601@test#egg=iso8601"
virtualenv: "{{ remote_tmp_dir }}/pipenv"
editable: true
state: latest
register: url_installed_specific_commit_again
- name: verify we did not record a change
assert:
that:
- "not (url_installed_specific_commit_again is changed)"
- name: install the same module from url pointing to a different specific commit with same package version
pip:
name: "git+https://github.com/dvarrazzo/pyiso8601@test1#egg=iso8601"
state: latest
editable: true
virtualenv: "{{ remote_tmp_dir }}/pipenv"
register: url_installed_different_specific_commit_same_version
- name: verify we recorded a change
assert:
that:
- "url_installed_different_specific_commit_same_version is changed"
# Test pip package in check mode doesn't always report changed.
# Special case for pip

Loading…
Cancel
Save