Parse wheel filenames
Project description
GitHub | PyPI | Issues | Changelog
wheel-filename lets you verify wheel filenames and parse them into their component fields.
This package adheres strictly to the relevant PEPs, with the following exceptions:
Unlike other filename components, version components may contain the characters ! and + for full PEP 440 support.
Version components may be any sequence of the relevant set of characters; they are not verified for PEP 440 compliance.
The .whl file extension is matched case-insensitively.
Installation
wheel-filename requires Python 3.6 or higher. Just use pip for Python 3 (You have pip, right?) to install wheel-filename:
python3 -m pip install wheel-filename
Example
>>> from wheel_filename import parse_wheel_filename >>> pwf = parse_wheel_filename('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']
API
- parse_wheel_filename(filename)
Parses a wheel filename (a str, bytes, or os.PathLike) and returns a ParsedWheelFilename instance. Any leading directory components are stripped from the argument before processing. If the filename is not a valid wheel filename, raises an InvalidFilenameError.
- ParsedWheelFilename
A namedtuple representing the components of a wheel filename. It has the following attributes and methods:
- project: str
The name of the project distributed by the wheel
- version: str
The version of the project distributed by the wheel
- build: Optional[str]
The wheel’s build tag (None if not defined)
- 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 ParsedWheelFilename returns the original filename
- tag_triples() -> Iterator[str]
Returns an iterator of all simple tag triples formed from the compatibility tags in the filename
- InvalidFilenameError
A subclass of ValueError raised when an invalid wheel filename is passed to parse_wheel_filename(). It has a filename attribute containing the basename of the invalid filename.
Command
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" ] }
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wheel-filename-1.4.1.tar.gz
.
File metadata
- Download URL: wheel-filename-1.4.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e1eb0780910a0148358252aad6394cc674250686c56c39aa379493438370b3 |
|
MD5 | 182cdc6f002d3ee85dd83b64a504a6f6 |
|
BLAKE2b-256 | 2a24ffb1fc1340edbfd03c9fa9179b3242aedf2bea6d79c56150b5f8354eff25 |
File details
Details for the file wheel_filename-1.4.1-py3-none-any.whl
.
File metadata
- Download URL: wheel_filename-1.4.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a53d8ece58822eb27b3a8841c6b4bebf357f19ff0dd83ce9179756f64a4bc0df |
|
MD5 | 6b359d428a44796520a8cdae7109039b |
|
BLAKE2b-256 | f4a88da5a73d450cae099ed02c98161d706e10593a0ffbd24c462c1f932f2964 |