Wheel Filename Parser

2.1.0 · active · verified Wed Apr 15

wheel-filename is a Python library that enables verification and parsing of wheel filenames into their constituent fields. It strictly adheres to the wheel standard (PEP 427), with minor exceptions for version component validation and case-insensitive `.whl` extension matching. The current version is 2.1.0, and releases follow an as-needed cadence to maintain standard compliance and address any reported issues.

Warnings

Install

Imports

Quickstart

Demonstrates how to parse a valid wheel filename and access its components, and how to handle `ParseError` for invalid filenames.

from wheel_filename import WheelFilename, ParseError

filename = 'pip-18.0-py2.py3-none-any.whl'
try:
    pwf = WheelFilename.parse(filename)
    print(f"Project: {pwf.project}")
    print(f"Version: {pwf.version}")
    print(f"Python Tags: {pwf.python_tags}")
    print(f"ABI Tags: {pwf.abi_tags}")
    print(f"Platform Tags: {pwf.platform_tags}")
    print(f"String representation: {str(pwf)}")
    print(f"Tag Triples: {list(pwf.tag_triples())}")
except ParseError as e:
    print(f"Error parsing filename '{e.filename}': {e}")

invalid_filename = 'my_package-1.0.whl'
try:
    WheelFilename.parse(invalid_filename)
except ParseError as e:
    print(f"Caught expected error for '{e.filename}': {e}")

view raw JSON →