GitHub | PyPI | Issues | Changelog
wheel-filename lets you verify wheel filenames and parse them into their
component fields.
This package adheres strictly to the standard, with the following exceptions:
- Version components may be any sequence of the relevant set of characters; they are not verified for PEP 440 compliance.
- The
.whlfile extension is matched case-insensitively.
wheel-filename requires Python 3.10 or higher. Just use pip for Python 3 (You have pip, right?) to install it:
python3 -m pip install wheel-filename
>>> from wheel_filename import WheelFilename
>>> pwf = WheelFilename.parse('pip-18.0-py2.py3-none-any.whl')
>>> str(pwf)
'pip-18.0-py2.py3-none-any.whl'
>>> pwf.project
'pip'
>>> pwf.version
'18.0'
>>> pwf.build is None
True
>>> pwf.python_tags
['py2', 'py3']
>>> pwf.abi_tags
['none']
>>> pwf.platform_tags
['any']
>>> list(pwf.tag_triples())
['py2-none-any', 'py3-none-any']WheelFilenameA dataclass representing the components of a wheel filename. It has the following attributes and methods:
WheelFilename.parse(filename)- (classmethod) Parses a wheel filename (a
str,bytes, oros.PathLike) and returns aWheelFilenameinstance. Any leading directory components are stripped from the argument before processing. If the filename is not a valid wheel filename, raises aParseError. project: str- The name of the project distributed by the wheel
version: str- The version of the project distributed by the wheel
build: str | None- The wheel's build tag (
Noneif not defined) build_tuple: tuple[int, str] | tuple[()]- The build tag as a tuple for use in sorting. If
buildis non-None, this is(build_leading, build_trailing); otherwise, it is the empty tuple. build_leading: int | None- If
buildis non-None, this is the leading integer portion of the build tag converted to anint; otherwise it isNone build_trailing: str | None- If
buildis non-None, this is the part after the leading integer portion of the build tag; otherwise it isNone python_tags: list[str]- A list of Python tags for the wheel
abi_tags: list[str]- A list of ABI tags for the wheel
platform_tags: list[str]- A list of platform tags for the wheel
str(pwf)- Stringifying a
WheelFilenamereturns the original filename tag_triples() -> Iterator[str]- Returns an iterator of all simple tag triples formed from the compatibility tags in the filename
ParseError- A subclass of
ValueErrorraised when an invalid wheel filename is passed toWheelFilename.parse(). It has afilenameattribute containing the basename of the invalid filename.
New in version 1.4.0
wheel-filename also provides a command of the same name that takes a wheel
filename (The actual wheel does not have to exist) and outputs the filename
components as JSON.
Example:
$ wheel-filename pip-18.0-py2.py3-none-any.whl
{
"project": "pip",
"version": "18.0",
"build": null,
"python_tags": [
"py2",
"py3"
],
"abi_tags": [
"none"
],
"platform_tags": [
"any"
]
}