Skip to content

Commit 8f9267a

Browse files
committed
Add rstrip in def _strip_extras
1 parent bef3535 commit 8f9267a

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

news/13523.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix command parsing for ``pip install <path_to_whl_file> [<extras>]`` with whitespace between file path and extras section.

src/pip/_internal/req/constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _strip_extras(path: str) -> tuple[str, str | None]:
4747
m = re.match(r"^(.+)(\[[^\]]+\])$", path)
4848
extras = None
4949
if m:
50-
path_no_extras = m.group(1)
50+
path_no_extras = m.group(1).rstrip()
5151
extras = m.group(2)
5252
else:
5353
path_no_extras = path

tests/unit/test_req.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ def test_requirement_file(self) -> None:
768768
("pkg [ext] == 1.0; python_version<='3.6'", "pkg==1.0"),
769769
("pkg-all.allowed_chars0 ~= 2.0", "pkg-all.allowed_chars0~=2.0"),
770770
("pkg-all.allowed_chars0 [ext] ~= 2.0", "pkg-all.allowed_chars0~=2.0"),
771+
("simple-0.1-py2.py3-none-any.whl [ext]", "simple==0.1"),
771772
],
772773
)
773774
def test_install_req_drop_extras(self, inp: str, out: str) -> None:

0 commit comments

Comments
 (0)