When support for SPDX 2.3 was added, it effectively dropped support for SPDX 2.2, which in retrospect was a bad idea since SPDX 2.2 is the version that is the current ISO/IEC standard. This commit adds a `--spdx-version` option to the `west spdx` command so that users can generate SPDX 2.2 documents if they want. Default is 2.3 given that's effectively what shipped for a few releases now, including latest LTS. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
21 lines
443 B
Python
21 lines
443 B
Python
# Copyright (c) 2025 The Linux Foundation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from packaging.version import Version
|
|
|
|
SPDX_VERSION_2_2 = Version("2.2")
|
|
SPDX_VERSION_2_3 = Version("2.3")
|
|
|
|
SUPPORTED_SPDX_VERSIONS = [
|
|
SPDX_VERSION_2_2,
|
|
SPDX_VERSION_2_3,
|
|
]
|
|
|
|
|
|
def parse(version_str):
|
|
v = Version(version_str)
|
|
if v not in SUPPORTED_SPDX_VERSIONS:
|
|
raise ValueError(f"Unsupported SPDX version: {version_str}")
|
|
return v
|