Skip to content

Commit

Permalink
Merge pull request #12939 from notatallshaw/update-non-PEP-440-wheel-…
Browse files Browse the repository at this point in the history
…filename-deprecation-notice

Update non PEP 440 wheel filename deprecation notice
  • Loading branch information
sbidoul authored Oct 12, 2024
2 parents 0330f95 + 0c4cdf9 commit 348c428
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
1 change: 1 addition & 0 deletions news/12939.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update non PEP 440 wheel filename deprecation notice.
55 changes: 41 additions & 14 deletions src/pip/_internal/models/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from typing import Dict, Iterable, List

from pip._vendor.packaging.tags import Tag
from pip._vendor.packaging.utils import (
InvalidVersion,
parse_wheel_filename,
)
from pip._vendor.packaging.utils import (
InvalidWheelFilename as PackagingInvalidWheelName,
)

from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.utils.deprecation import deprecated
Expand All @@ -32,20 +39,40 @@ def __init__(self, filename: str) -> None:
self.name = wheel_info.group("name").replace("_", "-")
_version = wheel_info.group("ver")
if "_" in _version:
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 may "
"fail to recognise this wheel."
),
replacement=(
"rename the wheel to use a correctly normalised version part "
"(this may require updating the version in the project metadata)"
),
gone_in="25.1",
issue=12914,
)
try:
parse_wheel_filename(filename)
except InvalidVersion as e:
deprecated(
reason=(
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 "
"version part (this may require updating the version "
"in the project metadata)"
),
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
Expand Down

0 comments on commit 348c428

Please sign in to comment.