Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update non PEP 440 wheel filename deprecation notice #12939

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]}."
Comment on lines +63 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads poorly:

DEPRECATION: The wheel filename 'six-1.16.0_build1-py3-none-any.whl' is not correctly normalised. Future versions of pip will fail to recognise this wheel. and report the error: Invalid wheel filename (invalid version): six-1.16.0_build1-py3-none-any. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised name (this may require updating the version in the project metadata). Discussion can be found at https://github.com/pypa/pip/issues/12938
ERROR: Invalid requirement: 'six==1.16.0-build1': Expected end or semicolon (after version specifier)
    six==1.16.0-build1
       ~~~~~~~~~~^

That period seems superfluous? "pip will fail to recognise this wheel. and report the error"

Copy link
Member Author

@notatallshaw notatallshaw Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞 , yes, I should have done another read over of the error before pushing the commit, I didn't expect it to actually ever trigger though.

Does your example actually cause this error to trigger? i.e. it passes the regex but not the parse_wheel_filename?

I can make yet another follow up to improve the wording.

Copy link
Member

@ichard26 ichard26 Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it up by renaming the random six wheel I have lying around. It should not be considered a real world example :P

It did work in raising this error though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a PR tomorrow aimed to be as small as possible to clean up the wording. Thanks for pointing out.

),
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
Loading