pip - Fix check_mode for prerelease packages (#68690)
* pip - Fix check_mode for prerelease packages Fixes #68592. Signed-off-by: Rick Elrod <rick@elrod.me> Co-authored-by: Matt Martz <matt@sivel.net>
This commit is contained in:
parent
f921b1e3bd
commit
82c60db49b
4 changed files with 39 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "pip - check_mode with ``state: present`` now returns the correct state for pre-release versioned packages"
|
|
@ -555,7 +555,7 @@ class Package:
|
|||
if not self._plain_package:
|
||||
return False
|
||||
try:
|
||||
return self._requirement.specifier.contains(version_to_test)
|
||||
return self._requirement.specifier.contains(version_to_test, prereleases=True)
|
||||
except AttributeError:
|
||||
# old setuptools has no specifier, do fallback
|
||||
version_to_test = LooseVersion(version_to_test)
|
||||
|
|
|
@ -516,3 +516,38 @@
|
|||
assert:
|
||||
that: "'distribute' in remove_distribute.cmd"
|
||||
when: ansible_python.version.major == 2
|
||||
|
||||
# https://github.com/ansible/ansible/issues/68592
|
||||
# Handle pre-release version numbers in check_mode for already-installed
|
||||
# packages.
|
||||
# TODO: Limiting to py3 test boxes for now so the example of 'black' installs,
|
||||
# we should probably find another package to use with a similar versioning
|
||||
# scheme or make a small one and enable this test for py2 as well.
|
||||
- block:
|
||||
- name: Install a beta version of a package
|
||||
pip:
|
||||
name: black
|
||||
version: 19.10b0
|
||||
state: present
|
||||
|
||||
- name: Use check_mode and ensure that the package is shown as installed
|
||||
check_mode: true
|
||||
pip:
|
||||
name: black
|
||||
state: present
|
||||
register: pip_prereleases
|
||||
|
||||
- name: Uninstall the beta package if we need to
|
||||
pip:
|
||||
name: black
|
||||
version: 19.10b0
|
||||
state: absent
|
||||
when: pip_prereleases is changed
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- pip_prereleases is successful
|
||||
- pip_prereleases is not changed
|
||||
- '"black==19.10b0" in pip_prereleases.stdout_lines'
|
||||
|
||||
when: ansible_python.version.major == 3
|
||||
|
|
|
@ -3,7 +3,7 @@ pip_test_packages:
|
|||
- sampleproject
|
||||
- jiphy
|
||||
pip_test_pkg_ver:
|
||||
- sampleproject<=100, !=9.0.0,>=0.0.1
|
||||
- sampleproject<=100, !=9.0.0,>=0.0.1
|
||||
- jiphy<100 ,!=9,>=0.0.1
|
||||
pip_test_pkg_ver_unsatisfied:
|
||||
- sampleproject>= 999.0.0
|
||||
|
|
Loading…
Reference in a new issue