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

Conversation

notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Aug 25, 2024

As requested in #12918 (comment) this creates an issue and points to the deprecation notice to that issue (#12938).

Further, upon testing pip main for a little bit I found several packages that use _ to separate the version and build number, which is valid, but the deprecation was pretty noisey as the current logic can't distinguish this, so I updated the deprecation to not fire unless parse_wheel_filename identified it as invalid.

E.g
$ pip install --dry-run marshmallow==1.0.0
  DEPRECATION: Wheel filename 'marshmallow-1.0.0_a-py2.py3-none-any.whl' uses an invalid filename format, as the version part '1.0.0_a' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
Collecting marshmallow==1.0.0
  Downloading marshmallow-1.0.0-py2.py3-none-any.whl.metadata (15 kB)
Downloading marshmallow-1.0.0-py2.py3-none-any.whl (45 kB)
Would install marshmallow-1.0.0


$ pip install --dry-run protobuf==4.21.0rc1
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp310-abi3-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp37-abi3-macosx_10_9_universal2.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp37-abi3-manylinux2014_aarch64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp37-abi3-manylinux2014_x86_64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp37-cp37m-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp38-cp38-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-cp39-cp39-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_1-py3-none-any.whl' uses an invalid filename format, as the version part '4.21.0_rc_1' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp310-abi3-win32.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp310-abi3-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp37-abi3-macosx_10_9_universal2.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp37-abi3-manylinux2014_aarch64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp37-abi3-manylinux2014_x86_64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp37-cp37m-win32.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp37-cp37m-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp38-cp38-win32.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp38-cp38-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp39-cp39-win32.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-cp39-cp39-win_amd64.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
  DEPRECATION: Wheel filename 'protobuf-4.21.0_rc_2-py3-none-any.whl' uses an invalid filename format, as the version part '4.21.0_rc_2' is not correctly normalised, and contains an underscore character. Future versions of pip may fail to recognise this wheel. pip 25.1 will enforce this behaviour change. A possible replacement is rename the wheel to use a correctly normalised version part (this may require updating the version in the project metadata). Discussion can be found at https:/pypa/pip/issues/12914
Collecting protobuf==4.21.0rc1
  Downloading protobuf-4.21.0_rc_1-cp37-abi3-manylinux2014_x86_64.whl.metadata (67 bytes)
Downloading protobuf-4.21.0_rc_1-cp37-abi3-manylinux2014_x86_64.whl (407 kB)
Would install protobuf-4.21.0-rc-1

These examples no longer fire the deprecation notice with this PR.

@notatallshaw notatallshaw force-pushed the update-non-PEP-440-wheel-filename-deprecation-notice branch from 686293f to fbe7924 Compare August 25, 2024 19:10
@notatallshaw notatallshaw added this to the 24.3 milestone Aug 26, 2024
@notatallshaw
Copy link
Member Author

CI is green, ready to review/merge.

I would say this one is pretty important to land for 24.3 as this message was a lot nosier than expected and this removes false positives.

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

try:
parse_wheel_filename(filename)
except (PackagingInvalidWheelName, InvalidVersion):
Copy link
Member

Choose a reason for hiding this comment

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

By just reading the code here, it's not obvious that all wheel filename parsing errors here are guaranteed to relate to an invalid version part.

Would it make sense to catch the two exception separately with a slightly different deprecation message?

Or is there a guarantee here that all exceptions are due to the version part? In that case a little comment explaining that might be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not guaranteed but it would have to occur under the following series of events:

  1. The wheel filename passes the existing regex
  2. There is a _ that is valid in what the regex parses as "version" but is not actually part of the version
  3. There is a different error in the filename that packaging catches

This would therefore have to be a currently unknown error that wheel filenames can have that packaging does not support but pip's regex was passing on anyway.

The reason I am catching both exceptions is because I did the same in #12327 and I was borrowing that code, but in that PR the code was scanning a directory that could find arbitrary names and I saw both errors in my testing.

Happy to split catching the two different exceptions up and give an appropriate message for PackagingInvalidWheelName .

Copy link
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

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

Thanks!

@sbidoul sbidoul merged commit 348c428 into pypa:main Oct 12, 2024
34 checks passed
Comment on lines +63 to +65
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]}."
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:/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants