diff options
author | Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua> | 2018-11-27 00:44:05 +0100 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2018-11-26 15:44:05 -0800 |
commit | cee7642188c31d1980d6f19f29ef0302e779a435 (patch) | |
tree | 6879c7021cc8c731e3a9748e6dd6c91a4e51df2e | |
parent | 2f8d3fcf41107efafc14d51ab6e14531ca8f8c87 (diff) | |
download | ansible-cee7642188c31d1980d6f19f29ef0302e779a435.tar.gz |
[stable-2.7] pip: Fix the mistake replacement from 'distribute' to 'setuptools' (#47403) (#49132)
* [stable-2.7] pip: Fix the mistake replacement from 'distribute' to 'setuptools' (#47403)
* Fix the mistake replace from distribute to setuptools
* Add a testcase for this bug
(cherry picked from commit 93c5781)
Co-authored-by: Zhikang Zhang <zzhang63@ncsu.edu>
* Add a change note
-rw-r--r-- | changelogs/fragments/47198-fix-setuptools-distutils.yaml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/packaging/language/pip.py | 4 | ||||
-rw-r--r-- | test/integration/targets/pip/tasks/pip.yml | 12 |
3 files changed, 16 insertions, 2 deletions
diff --git a/changelogs/fragments/47198-fix-setuptools-distutils.yaml b/changelogs/fragments/47198-fix-setuptools-distutils.yaml new file mode 100644 index 0000000000..fe686eecbe --- /dev/null +++ b/changelogs/fragments/47198-fix-setuptools-distutils.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "pip module - fix setuptools/distutils replacement (https://github.com/ansible/ansible/issues/47198)" diff --git a/lib/ansible/modules/packaging/language/pip.py b/lib/ansible/modules/packaging/language/pip.py index 313103b633..39088feaf2 100644 --- a/lib/ansible/modules/packaging/language/pip.py +++ b/lib/ansible/modules/packaging/language/pip.py @@ -503,8 +503,8 @@ class Package: name_string = separator.join((name_string, version_string)) try: self._requirement = Requirement.parse(name_string) - # old pkg_resource will replace 'setuptools' with 'distribute' when it already installed - if self._requirement.project_name == "distribute": + # old pkg_resource will replace 'setuptools' with 'distribute' when it's already installed + if self._requirement.project_name == "distribute" and "setuptools" in name_string: self.package_name = "setuptools" self._requirement.project_name = "setuptools" else: diff --git a/test/integration/targets/pip/tasks/pip.yml b/test/integration/targets/pip/tasks/pip.yml index ed7740e9a0..d0695b747f 100644 --- a/test/integration/targets/pip/tasks/pip.yml +++ b/test/integration/targets/pip/tasks/pip.yml @@ -499,3 +499,15 @@ pip: name: "{{ pip_test_packages }}" state: absent + +# https://github.com/ansible/ansible/issues/47198 +- name: try to remove distribute + pip: + state: "absent" + name: "distribute" + ignore_errors: yes + register: remove_distribute + +- name: inspect the cmd + assert: + that: "'distribute' in remove_distribute.cmd" |