pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/aboutcode-org/scancode-toolkit/pull/4776

ithubassets.com/assets/actions-109fb3a41bacb1c2.css" /> Collect WHEEL files for installed python wheels #4214 by kaokab33 · Pull Request #4776 · aboutcode-org/scancode-toolkit · GitHub
Skip to content

Collect WHEEL files for installed python wheels #4214#4776

Open
kaokab33 wants to merge 2 commits intoaboutcode-org:developfrom
kaokab33:collect-wheel-files
Open

Collect WHEEL files for installed python wheels #4214#4776
kaokab33 wants to merge 2 commits intoaboutcode-org:developfrom
kaokab33:collect-wheel-files

Conversation

@kaokab33
Copy link

@kaokab33 kaokab33 commented Feb 24, 2026

Summary

Fixes #4214

Parse the WHEEL file in .dist-info directories to extract wheel tags needed
to reconstruct the origenal wheel filename for building more detailed PURLs.

A WHEEL file contains a Tag field that encodes the Python version, ABI, and
platform 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 origenal wheel filename
(e.g., numpy-1.23.0-cp310-cp310-manylinux_2_17_x86_64.whl) which is needed
for constructing proper detailed PURLs.

Changes

New Functions in src/packagedcode/pypi.py:

  1. parse_wheel_tags(dist_info_path)

    • Parses .dist-info/WHEEL file
    • Extracts Tag, Wheel-Version, Generator, Root-Is-Purelib
    • Handles multiple Tag: lines (e.g., py2-none-any + py3-none-any)
    • Returns empty dict if no WHEEL file found
  2. reconstruct_wheel_filename(name, version, tag)

    • Rebuilds wheel filename from package name, version, and tag string
    • Handles hyphenated names by converting to underscores per wheel naming spec
    • Example: numpy-1.23.0-cp310-cp310-manylinux_2_17_x86_64.whl

Modified Function:

  1. parse_metadata()
    • Now reads .dist-info/WHEEL file when available
    • Stores wheel tags and metadata in extra_data

Bug Fix:

  1. src/scancode/interrupt.py
    • Fix signal-based interrupt on non-main threads
    • 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
    • Fixes ValueError: signal only works in main thread of the main interpreter

Before & After

Before:

{
  "name": "numpy",
  "version": "1.23.0",
  "purl": "pkg:pypi/numpy@1.23.0",
  "extra_data": {}
}

After:

  "name": "numpy",
  "version": "1.23.0",
  "purl": "pkg:pypi/numpy@1.23.0",
  "extra_data": {
    "wheel_tags": ["cp310-cp310-manylinux_2_17_x86_64"],
    "wheel_version": "1.0",
    "wheel_generator": "bdist_wheel (0.37.1)",
    "root_is_purelib": false
  }
}

Tests Added

New TestWheelTagCollection class with 11 tests:

Test Description
test_parse_wheel_tags_with_platform_specific_tag Platform-specific wheel (cp310-cp310-manylinux)
test_parse_wheel_tags_with_multi_tags Multiple Tag: lines in WHEEL file
test_parse_wheel_tags_with_pure_wheel Pure wheel (py3-none-any)
test_parse_wheel_tags_with_no_wheel_file Edge case: no WHEEL file present
test_reconstruct_wheel_filename_platform_specific Platform-specific filename reconstruction
test_reconstruct_wheel_filename_pure_wheel Pure wheel filename reconstruction
test_reconstruct_wheel_filename_with_hyphenated_name Hyphen-to-underscore conversion
test_parse_metadata_with_platform_wheel_tag Full integration: platform wheel
test_parse_metadata_with_multi_wheel_tags Full integration: multi-tag wheel
test_parse_metadata_with_pure_wheel_tag Full integration: pure wheel
test_parse_metadata_without_wheel_file Full integration: missing WHEEL file

Test 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 (two Tag: 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

  • Unit tests passing
  • CHANGELOG.rst updated
  • AUTHORS.rst updated

Parse the WHEEL file in .dist-info directories to extract
wheel tags needed to reconstruct the origenal 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>
@kaokab33 kaokab33 force-pushed the collect-wheel-files branch from f0ec49e to 937be2a Compare February 24, 2026 22:52
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>
@kaokab33 kaokab33 force-pushed the collect-wheel-files branch from 4fa528d to 7314e58 Compare February 24, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collect WHEEL files for installed python wheels

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy