From e850d9fbecc0e7a2f79af1c0440ab45663abd562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dautheribes=20=28Schneider=20Electric?= =?UTF-8?q?=29?= Date: Wed, 13 May 2026 15:20:58 +0200 Subject: [PATCH 1/2] cli: Support zstd-compressed SBOMs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Dautheribes (Schneider Electric) --- pyproject.toml | 4 ++++ src/spdx_diff/cli.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 598df49..c9c0c63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,10 @@ classifiers = [ "Topic :: Software Development :: Build Tools", ] +dependencies = [ + "backports.zstd; python_version < '3.14'" +] + [project.scripts] spdx-diff = "spdx_diff.cli:main" diff --git a/src/spdx_diff/cli.py b/src/spdx_diff/cli.py index 0505025..83f1968 100644 --- a/src/spdx_diff/cli.py +++ b/src/spdx_diff/cli.py @@ -16,6 +16,11 @@ from collections import defaultdict from typing import Any +if sys.version_info >= (3, 14): + from compression import zstd +else: + from backports import zstd + from . import __version__ _logger = logging.getLogger(__name__) @@ -53,9 +58,14 @@ def _parse(self, json_path: pathlib.Path) -> None: :param json_path: Path the JSON file. """ _logger.info("Opening SPDX file: %s", json_path) + try: - with json_path.open(encoding="utf-8") as f: - data = json.load(f) + if json_path.suffix == ".zst": + with zstd.open(json_path, "rt") as f: + data = json.load(f) + else: + with json_path.open(encoding="utf-8") as f: + data = json.load(f) except (OSError, ValueError) as e: raise ValueError("Failed to read or parse %s", json_path) from e From 989f5fef8d413a7f15609febe38d41fcea30c291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dautheribes=20=28Schneider=20Electric?= =?UTF-8?q?=29?= Date: Wed, 13 May 2026 15:21:17 +0200 Subject: [PATCH 2/2] CHANGELOG: Mention zstd compression feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Dautheribes (Schneider Electric) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e6a3f3..77e438a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. ### Added + - Support zstd-compressed SPDX files. + ### Changed - Add custom `HelpFormatter` to render boolean flags in a compact `--[no-]flag` format instead of the default `--flag, --no-flag`.