{"library":"license-expression","title":"License-Expression","description":"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.","status":"active","version":"30.4.4","language":"en","source_language":"en","source_url":"https://github.com/aboutcode-org/license-expression","tags":["license","spdx","expression","parsing","validation","compliance"],"install":[{"cmd":"pip install license-expression","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"This function is the primary entry point for obtaining a licensing object configured with SPDX data.","symbol":"get_spdx_licensing","correct":"from license_expression import get_spdx_licensing"}],"quickstart":{"code":"from license_expression import get_spdx_licensing\n\n# Get a licensing object. This can be slow and should be reused.\nlicensing = get_spdx_licensing()\n\n# Parse a license expression\nexpression_str = 'GPL-2.0-only OR LGPL-2.1-only AND MIT'\nparsed_expression = licensing.parse(expression_str)\n\nprint(f\"Original: {expression_str}\")\nprint(f\"Parsed (pretty): {parsed_expression.pretty()}\")\n\n# Check for equivalence\nexpression_str_2 = 'MIT AND (GPL-2.0-only OR LGPL-2.1-only)'\nparsed_expression_2 = licensing.parse(expression_str_2)\nprint(f\"Is '{expression_str}' equivalent to '{expression_str_2}'? {licensing.is_equivalent(parsed_expression, parsed_expression_2)}\")\n\n# Validate an expression\nvalid = licensing.validate(expression_str)\nprint(f\"Is '{expression_str}' a valid expression? {valid.errors if valid.errors else True}\")\n\ninvalid_expression = 'Invalid-License AND Other-License'\ninvalid_valid = licensing.validate(invalid_expression)\nprint(f\"Is '{invalid_expression}' a valid expression? {invalid_valid.errors if invalid_valid.errors else True}\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade Python to 3.9 or newer.","message":"Support for Python 3.8 was dropped in version 30.4.0. Users on Python 3.8 or older must upgrade their Python environment to Python 3.9 or newer to use the latest versions of license-expression.","severity":"breaking","affected_versions":">=30.4.0"},{"fix":"Upgrade Python to 3.8 or newer.","message":"Support for Python 3.7 was dropped in version 30.3.0. Users on Python 3.7 or older must upgrade their Python environment to Python 3.8 or newer (preferably 3.9+) to use these versions.","severity":"breaking","affected_versions":">=30.3.0"},{"fix":"Avoid installing version 30.4.2; install version 30.4.3 or later instead.","message":"Version 30.4.2 was released with missing wheels, which could lead to installation issues. This was corrected in version 30.4.3.","severity":"gotcha","affected_versions":"30.4.2"},{"fix":"Cache and reuse the `licensing` object returned by `get_spdx_licensing()`.","message":"The `get_spdx_licensing()` function, which initializes the license parsing engine, can be slow to execute due to loading license data. It is recommended to call this function once and reuse the returned `licensing` object throughout your application for performance.","severity":"gotcha","affected_versions":"All"},{"fix":"Update any hardcoded GitHub repository URLs from `nexB/license-expression` to `aboutcode-org/license-expression`.","message":"The library's GitHub organization moved from 'nexB' to 'aboutcode-org' around version 30.3.1. While the `pypi` package name remains `license-expression`, any direct references to the GitHub repository in CI/CD or other tools should be updated.","severity":"gotcha","affected_versions":"All versions referencing the old GitHub URL"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}