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

Replace custom wheel filename regex with standard packaging parse_wheel_filename #12917

Closed

Conversation

notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Aug 16, 2024

This will be marked ready for review once _ in wheel version file name has been deprecated, see #12914

@notatallshaw
Copy link
Member Author

test_install_from_wheel_with_headers appears to be flaky, I was able to reproduce the failure locally initially, but on rerun I can no longer reproduce it.

@sbidoul
Copy link
Member

sbidoul commented Aug 16, 2024

Looks good :)

@notatallshaw
Copy link
Member Author

test_install_from_wheel_with_headers appears to be flaky, I was able to reproduce the failure locally initially, but on rerun I can no longer reproduce it.

This fails consistently in CI, but inconsistently locally 🙁, I will investigate.

@ichard26
Copy link
Member

ichard26 commented Jan 29, 2025

@notatallshaw it fails consistently locally for me. I copied the old Wheel class, creating both the new and old classes to compare the final attributes. It looks like the packaging-based implementation is normalizing the wheel name hence the FileNotFoundError.

self.name='headers-dist', self.version='0.1', self.build_tag=(), self.file_tags=frozenset({<py3-none-any @ 139308783286464>, <py2-none-any @ 139308783286976>})
old_whl.name='headers.dist', old_whl.version='0.1', old_whl.build_tag=None, old_whl.file_tags={<py3-none-any @ 139308783287168>, <py2-none-any @ 139308783286848>}

The headers are placed in a directory with the normalized name (although the dist-info is still not normalized...)

diff --git a/tests/functional/test_install_wheel.py b/tests/functional/test_install_wheel.py
index 7e7aeaf7a..e01ecfb57 100644
--- a/tests/functional/test_install_wheel.py
+++ b/tests/functional/test_install_wheel.py
@@ -190,7 +190,7 @@ def test_install_from_wheel_with_headers(script: PipTestEnvironment) -> None:
     dist_info_folder = script.site_packages / "headers.dist-0.1.dist-info"
     result.did_create(dist_info_folder)
 
-    header_scheme_path = get_header_scheme_path_for_script(script, "headers.dist")
+    header_scheme_path = get_header_scheme_path_for_script(script, "headers-dist")
     header_path = header_scheme_path / "header.h"
     assert header_path.read_text() == header_text

@ichard26
Copy link
Member

Historically, tools have failed to replace dot characters or normalize case in the name field, or not perform normalization in the version field. Tools consuming .dist-info directories should expect those fields to be unnormalized, and treat them as equivalent to their normalized counterparts. New tools that write .dist-info directories MUST normalize both name and version fields using the rules described above, and existing tools are encouraged to start normalizing those fields.

https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-dist-info-directory

Ah, that checks out. Heh.

@notatallshaw notatallshaw force-pushed the replace-custom-wheel-regex branch from f2bd16d to 5dc5761 Compare February 9, 2025 20:27
@notatallshaw notatallshaw marked this pull request as ready for review February 9, 2025 21:21
@notatallshaw
Copy link
Member Author

This is ready for review and merge.

@notatallshaw
Copy link
Member Author

notatallshaw commented Feb 13, 2025

Holding off on merging this until the discussion in pypa/packaging#873 has concluded, may end up pushing this to a later pip release.

@notatallshaw
Copy link
Member Author

notatallshaw commented Feb 19, 2025

I've found a real world examples where this PR would currently throw an error but there is no deprecation warning:

$ pip install "en_core_web_sm @ https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl"
ERROR: Invalid wheel filename (invalid version): 'en_core_web_sm-any-py3-none-any

I don't think this is a supported use case, but I don't want to surprise users, so I plan to do the following in a new PR:

  1. Initially parse with parse_wheel_filename
  2. If fails fall back to old regex
    a. If succeed with old regex throw deprecation warning
    b. If fail with old regex throw with message from parse_wheel_filename

The new deprecation warning will be for it to be gone in pip 25.3.

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

Successfully merging this pull request may close these issues.

3 participants