Skip to content

cli: add zstd import fallback via zstandard for Python < 3.14#5

Merged
jeremie-dautheribes merged 1 commit into
bootlin:mainfrom
sascgc:main
Jul 2, 2026
Merged

cli: add zstd import fallback via zstandard for Python < 3.14#5
jeremie-dautheribes merged 1 commit into
bootlin:mainfrom
sascgc:main

Conversation

@sascgc

@sascgc sascgc commented Jul 1, 2026

Copy link
Copy Markdown

The zstandard package is widely available across distributions and Python environments, while backports.zstd is not always packaged or readily accessible. So zstandard is added as import fallback.

The zstandard backend does not support text mode when opening compressed files through zstd.open().

Switch to binary mode and let json.load() consume the resulting binary steam, whcih is supported by both backends.

@sascgc sascgc force-pushed the main branch 3 times, most recently from c880470 to dbd802e Compare July 1, 2026 13:29
Comment thread src/spdx_diff/cli.py Outdated
@sascgc sascgc force-pushed the main branch 3 times, most recently from 45a6323 to 3e30a1d Compare July 1, 2026 15:57

@benjarobin benjarobin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have the zstd feature optional, but otherwise I am OK with the change

@sascgc sascgc force-pushed the main branch 6 times, most recently from 3346458 to 196736b Compare July 1, 2026 17:30
@jeremie-dautheribes

Copy link
Copy Markdown
Member

In the case we make zstd support optional, then could we keep both backports.zstd and zstandard?

@sascgc sascgc force-pushed the main branch 3 times, most recently from dd11586 to f651eb5 Compare July 2, 2026 13:47
The zstandard package is widely available across distributions and
Python environments, while backports.zstd is not always packaged or
readily accessible. Add zstandard as a fallback import.

Make the zstd support optional by deferring dependency checks until the
feature is actually used.

The zstandard backend does not support text mode when opening compressed files
through zstd.open().
Switch to binary mode and let json.load() consume the resulting binary steam,
which is supported by both backends.

Signed-off-by: Christophe Guerreiro <christophe.guerreiro@non.se.com>
@jeremie-dautheribes jeremie-dautheribes merged commit 7c042fd into bootlin:main Jul 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants