pip: Fix the mistake replacement from 'distribute' to 'setuptools' (#47403)

* Fix the mistake replace from distribute to setuptools

* Add a testcase for this bug
This commit is contained in:
Zhikang Zhang 2018-11-26 11:12:36 -05:00 committed by Sviatoslav Sydorenko
parent 3a9eadb22f
commit 93c5781f61
2 changed files with 14 additions and 2 deletions

View file

@ -513,8 +513,8 @@ class Package:
name_string = separator.join((name_string, version_string)) name_string = separator.join((name_string, version_string))
try: try:
self._requirement = Requirement.parse(name_string) self._requirement = Requirement.parse(name_string)
# old pkg_resource will replace 'setuptools' with 'distribute' when it already installed # old pkg_resource will replace 'setuptools' with 'distribute' when it's already installed
if self._requirement.project_name == "distribute": if self._requirement.project_name == "distribute" and "setuptools" in name_string:
self.package_name = "setuptools" self.package_name = "setuptools"
self._requirement.project_name = "setuptools" self._requirement.project_name = "setuptools"
else: else:

View file

@ -499,3 +499,15 @@
pip: pip:
name: "{{ pip_test_packages }}" name: "{{ pip_test_packages }}"
state: absent 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"