Skip to content

Commit

Permalink
Break up different exceptions and report specific error
Browse files Browse the repository at this point in the history
  • Loading branch information
notatallshaw committed Oct 12, 2024
1 parent 9fd6b86 commit 0c4cdf9
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/pip/_internal/models/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ def __init__(self, filename: str) -> None:
self.name = wheel_info.group("name").replace("_", "-")
_version = wheel_info.group("ver")
if "_" in _version:
_version = _version.replace("_", "-")

try:
parse_wheel_filename(filename)
except (PackagingInvalidWheelName, InvalidVersion):
except InvalidVersion as e:
deprecated(
reason=(
f"Wheel filename {filename!r} uses an invalid filename format, "
f"as the version part {_version!r} is not correctly "
"normalised, and contains an underscore character. Future "
"versions of pip will fail to recognise this wheel."
f"Wheel filename version part {_version!r} is not correctly "
"normalised, and contained an underscore character in the "
"version part. Future versions of pip will fail to recognise "
f"this wheel and report the error: {e.args[0]}."
),
replacement=(
"rename the wheel to use a correctly normalised "
Expand All @@ -59,6 +57,23 @@ def __init__(self, filename: str) -> None:
gone_in="25.1",
issue=12938,
)
except PackagingInvalidWheelName as e:
deprecated(
reason=(
f"The wheel filename {filename!r} is not correctly normalised. "
"Future versions of pip will fail to recognise this wheel. "
f"and report the error: {e.args[0]}."
),
replacement=(
"rename the wheel to use a correctly normalised "
"name (this may require updating the version in "
"the project metadata)"
),
gone_in="25.1",
issue=12938,
)

_version = _version.replace("_", "-")

self.version = _version
self.build_tag = wheel_info.group("build")
Expand Down

0 comments on commit 0c4cdf9

Please sign in to comment.