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

Fix problem where pip module cannot accept multiple extras

PR #46937
Fixes #46519
This commit is contained in:
Zhikang Zhang 2018-10-22 16:21:45 -04:00 committed by Sviatoslav Sydorenko
parent 4352a4e54d
commit b697da39c8
2 changed files with 12 additions and 2 deletions

View file

@ -292,11 +292,16 @@ def _recover_package_name(names):
# reconstruct the names
name_parts = []
package_names = []
in_brackets = False
for name in names:
if _is_package_name(name):
if _is_package_name(name) and not in_brackets:
if name_parts:
package_names.append(",".join(name_parts))
name_parts = []
if "[" in name:
in_brackets = True
if in_brackets and "]" in name:
in_brackets = False
name_parts.append(name)
package_names.append(",".join(name_parts))
return package_names
@ -498,6 +503,7 @@ class Package:
# old pkg_resource will replace 'setuptools' with 'distribute' when it already installed
if self._requirement.project_name == "distribute":
self.package_name = "setuptools"
self._requirement.project_name = "setuptools"
else:
self.package_name = self._requirement.project_name
self._plain_package = True
@ -639,7 +645,7 @@ def main():
"Please keep the version specifier, but remove the 'version' argument."
)
# if the version specifier is provided by version, append that into the package
packages[0] = Package(packages[0].package_name, version)
packages[0] = Package(to_native(packages[0]), version)
if module.params['editable']:
args_list = [] # used if extra_args is not used at all

View file

@ -470,6 +470,10 @@
assert:
that: "version13 is failed"
- name: try install package with setuptools extras
pip:
name: "{{pip_test_package}}[dev,test]"
- name: clean up
pip:
name: "{{ pip_test_packages }}"