Collect WHEEL files for installed python wheels #4214#4776
Open
kaokab33 wants to merge 2 commits intoaboutcode-org:developfrom
Open
Collect WHEEL files for installed python wheels #4214#4776kaokab33 wants to merge 2 commits intoaboutcode-org:developfrom
kaokab33 wants to merge 2 commits intoaboutcode-org:developfrom
Conversation
693c668 to
f0ec49e
Compare
Parse the WHEEL file in .dist-info directories to extract wheel tags needed to reconstruct the original wheel filename for building more detailed PURLs. Changes: - Add parse_wheel_tags() to parse .dist-info/WHEEL files - Add reconstruct_wheel_filename() to rebuild wheel filenames - Modify parse_metadata() to collect wheel data into extra_data - Add new test fixtures and tests for wheel tag collection - Update existing expected test JSONs with wheel tag data Signed-off-by: Kareem Samy <karim.elsayed401@eng-st.cu.edu.eg>
f0ec49e to
937be2a
Compare
Add a check to detect if the current thread is the main thread before attempting to set up signal handlers. On Python 3.14+, signal handlers can only be set up in the main thread of the main interpreter. If not in the main thread, fall back to non-interruptible execution. This fixes the test failure in test_interruptible_can_run_function which was failing with: ValueError: signal only works in main thread of the main interpreter Signed-off-by: Kareem Samy <karim.elsayed401@eng-st.cu.edu.eg>
4fa528d to
7314e58
Compare
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
Fixes #4214
Parse the WHEEL file in
.dist-infodirectories to extract wheel tags neededto reconstruct the original wheel filename for building more detailed PURLs.
A WHEEL file contains a
Tagfield that encodes the Python version, ABI, andplatform information:
Wheel-Version: 1.0
Generator: bdist_wheel (0.37.1)
Root-Is-Purelib: false
Tag: cp310-cp310-manylinux_2_17_x86_64
This tag is essential to reconstruct the original wheel filename
(e.g.,
numpy-1.23.0-cp310-cp310-manylinux_2_17_x86_64.whl) which is neededfor constructing proper detailed PURLs.
Changes
New Functions in
src/packagedcode/pypi.py:parse_wheel_tags(dist_info_path).dist-info/WHEELfileTag,Wheel-Version,Generator,Root-Is-PurelibTag:lines (e.g.,py2-none-any+py3-none-any)reconstruct_wheel_filename(name, version, tag)numpy-1.23.0-cp310-cp310-manylinux_2_17_x86_64.whlModified Function:
parse_metadata().dist-info/WHEELfile when availableextra_dataBug Fix:
src/scancode/interrupt.pyattempting to set up signal handlers
of the main interpreter
ValueError: signal only works in main thread of the main interpreterBefore & After
Before:
{ "name": "numpy", "version": "1.23.0", "purl": "pkg:pypi/numpy@1.23.0", "extra_data": {} }After:
Tests Added
New
TestWheelTagCollectionclass with 11 tests:test_parse_wheel_tags_with_platform_specific_tagcp310-cp310-manylinux)test_parse_wheel_tags_with_multi_tagsTag:lines in WHEEL filetest_parse_wheel_tags_with_pure_wheelpy3-none-any)test_parse_wheel_tags_with_no_wheel_filetest_reconstruct_wheel_filename_platform_specifictest_reconstruct_wheel_filename_pure_wheeltest_reconstruct_wheel_filename_with_hyphenated_nametest_parse_metadata_with_platform_wheel_tagtest_parse_metadata_with_multi_wheel_tagstest_parse_metadata_with_pure_wheel_tagtest_parse_metadata_without_wheel_fileTest Fixtures Added:
numpy-1.23.0.dist-info— Platform-specific wheel (cp310-cp310-manylinux_2_17_x86_64)cryptography-41.0.0.dist-info— Multi-tag wheel (twoTag:lines)requests-2.28.0.dist-info— Pure wheel (py3-none-any)no-wheel-1.0.0.dist-info— No WHEEL file (edge case)Updated Expected JSONs:
Existing test expected JSON files updated to include wheel tag data from
WHEEL files that were already present in test fixtures.
Checklist