ShippingLabel
Shippinglabel is a Python library providing utilities for handling packages, including checksums, classifiers, and requirements management. It is actively maintained by domdfcoding with frequent releases, currently at version 2.3.0.
Common errors
-
ModuleNotFoundError: No module named 'shippinglabel.dependencies'
cause The `shippinglabel.dependencies` submodule was removed in version 2.0.0.fixUpdate your import statements and code to use `shippinglabel.requirements` or `packaging` for dependency-related functionality. -
SyntaxError: invalid syntax (on Python 3.6)
cause Attempting to run `shippinglabel` version 2.0.0 or higher on an unsupported Python 3.6 environment.fixUpgrade your Python interpreter to 3.7 or a later supported version. -
AttributeError: module 'shippinglabel' has no attribute 'entry_points'
cause The `shippinglabel.entry_points` module was removed in version 2.0.0.fixRefactor code to use `importlib.metadata` or the `entrypoints` library directly for entry point discovery.
Warnings
- breaking Version 2.0.0 dropped support for Python 3.6. Users on Python 3.6 will encounter `ImportError` or `SyntaxError`.
- breaking The `shippinglabel.dependencies` module was entirely removed in 2.0.0.
- breaking The `shippinglabel.entry_points` module was entirely removed in 2.0.0.
- gotcha While `trove-classifiers` is a declared dependency, `shippinglabel` includes a vendored copy. If you explicitly install a different version of `trove-classifiers`, `shippinglabel` will use that instead, potentially leading to inconsistencies if there are API changes.
Install
-
pip install shippinglabel
Imports
- get_valid_classifiers
from shippinglabel.classifiers import get_valid_classifiers
- parse_requirements
from shippinglabel.requirements import parse_requirements
- checksum_package
from shippinglabel.checksum import checksum_package
Quickstart
from shippinglabel.classifiers import get_valid_classifiers
# Get all valid PyPI classifiers as a frozenset
classifiers = get_valid_classifiers()
print(f"Total valid classifiers: {len(classifiers)}")
# Check if a specific classifier is valid
is_python3_only_valid = "Programming Language :: Python :: 3 :: Only" in classifiers
print(f"'Programming Language :: Python :: 3 :: Only' is valid: {is_python3_only_valid}")
is_non_existent_valid = "Operating System :: Brainfuck" in classifiers
print(f"'Operating System :: Brainfuck' is valid: {is_non_existent_valid}")