[stable-2.7] Fix problem where pip module cannot accept multiple extras (#47449)
* [stable-2.7] Fix problem where pip module cannot accept multiple extras
PR #46937
Fixes #46519
(cherry picked from commit b697da3
)
Co-authored-by: Zhikang Zhang <zzhang63@ncsu.edu>
* Add changelog
This commit is contained in:
parent
238939b523
commit
702820d673
3 changed files with 14 additions and 2 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Fix pip module so that it can recognize multiple extras
|
|
@ -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
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
Loading…
Reference in a new issue