Repository navigation
Stop wheel filename parsing from retrying every hyphen split - #5347
Open
Cherith1222 wants to merge 1 commit into
Open
Cherith1222 wants to merge 1 commit into
Cherith1222 wants to merge 1 commit into
Conversation
A long run of hyphens made the old pattern slower as the run grew. Components other than the platform now stop at a hyphen, as in pypa/wheel, and spec-legal names still parse to the same fields. Fixes pypa#4087. AI-assisted (Cursor).
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
setuptools.wheel.Wheelparses filenames withWHEEL_NAME. The old pattern used several.+?groups, so one long run of hyphens retried every split and got slower as the run grew. The name, version, optional build, Python tag, and ABI now use[^\s-], so they stop at a hyphen or whitespace. The platform group is\S+, so a compressed tag can still contain dots, and a hyphen in that last field stays in the platform. The version still has to start with a digit (\d), whichWHEEL_NAMEalready required. This is the same hyphen and whitespace constraint asWHEEL_INFO_REin pypa/wheel, except wheel does not require the version to start with a digit.Wheel('0-0' + '-' * 200)raisesValueErrorbefore and after this change. On Windows with Python 3.13.3, that call took about 0.601 seconds before and about 0.000010 seconds after.test_wheel_filename_hyphen_run_is_quickrejects a 200-hyphen run, with and without.whl, in under 0.5 seconds.The existing
WHEEL_INFO_TESTSfilenames stay, includingsimple.dist-0.1-py2.py3-none-any.whl, a build tag, andPyQt5. Added cases parsefoo-2-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whlandtest-1.0+what-py3-none-any.whl(versionis1.0+what).test-1.0-py2.whl,test-1.0-py2-none.whl, andtest-1.0-py2-none-anyraiseValueError.A distribution name that itself contains a hyphen no longer parses.
my-project-1.0-py3-none-any.whlused to parse withproject_namemy-projectandversion1.0. The name group cannot cross a hyphen, and the following field is not a version starting with a digit, soWheelnow raisesValueError. A space in a tag also no longer parses:test-1.0-py 2-none-any.whlused to parse withpy_versionpy 2and now raisesValueError.bdist_wheel.wheel_dist_namebuilds the written distribution name withsafer_nameandsafer_version, and both replace-with_before that name is used.get_tagreplaces-,., and spaces in the platform tag with_.newsfragments/4087.bugfix.rstis named with issue 4087, which is whatnewsfragments/README.rstasks for when an issue exists. The fragment does not need this pull request's number:On Windows, Python 3.13.3, pytest 8.4.2,
setuptools/tests/test_wheel.pywithtest_wheel_install[extension]deselected reported 29 passed and 1 deselected. That deselected test compiles an extension.setuptools/tests/test_dist.py::test_dist_fetch_build_eggpassed. That test callsWheelon the wheel pip wrote.Closes #4087.
Pull Request Checklist
newsfragments/.(See documentation for details)
AI-assisted (Cursor).