license-expression is a comprehensive Python utility library designed to parse, compare, simplify, and normalize license expressions, particularly SPDX license expressions, using boolean logic. It actively maintains and updates its bundled license keys from the SPDX License List and ScanCode LicenseDB, with frequent patch releases for these updates and minor releases for broader changes.
pip install license-expressionVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the SPDX licensing engine and use it to parse, pretty-print, check equivalence, and validate license expressions. The `get_spdx_licensing()` call can be computationally intensive, so its result should be cached and reused.
Upgrade Python to 3.9 or newer.
Upgrade Python to 3.8 or newer.
Avoid installing version 30.4.2; install version 30.4.3 or later instead.
Cache and reuse the `licensing` object returned by `get_spdx_licensing()`.
Update any hardcoded GitHub repository URLs from `nexB/license-expression` to `aboutcode-org/license-expression`.
Ensure license keys are valid SPDX identifiers (e.g., 'MIT', 'Apache-2.0') and the expression strictly follows SPDX syntax, using valid operators like 'AND', 'OR', 'WITH', and adhering to specified character rules.
Install the library using pip: `pip install license-expression`. If already installed, ensure the correct Python environment is activated or use the standard import: `from license_expression import get_spdx_licensing`.
Refer to the official SPDX License List (https://spdx.org/licenses/) and use the exact short-form identifiers (e.g., 'GPL-2.0-only' instead of 'GPL2') in your license expressions.
No dependency data recorded yet.