Fix stomp version checks#2718
Open
BharatDeva wants to merge 1 commit into
Open
Conversation
Use importlib metadata and packaging.version.Version for stomp.py version checks instead of comparing stomp.__version__ directly. stomp.py 8.2.0 changed __version__ from a tuple to a string, which made the collector and output bots fail when comparing the version with tuple literals. A shared helper keeps the version parsing in one place and falls back to the module attribute for environments where distribution metadata is unavailable. Signed-off-by: BharatDeva <278575558+BharatDeva@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2600.
stomp.py8.2.0 changedstomp.__version__from a tuple to a string. The STOMP collector and output bots compared that value directly with tuple literals, so the version checks could fail before the bots finished initialization or connection setup.This change adds a small shared
stomp_version()helper in the STOMP mixin module. It prefersimportlib.metadata.version(stomp.py), which is the stable package metadata interface, and falls back tostomp.__version__for environments where only the module version is available. The collector and output bot now comparepackaging.version.Versionobjects instead of comparing raw module attributes.The fallback keeps compatibility with older tuple-style module versions while supporting newer string-style versions.
Testing
Ran locally in WSL Ubuntu with Python 3.12.3:
PYTHONPATH=. .venv-wsl-pr/bin/python -m pytest -o addopts= intelmq/tests/lib/test_stomp_mixin.py intelmq/tests/bots/outputs/stomp/test_output.py3 passedPYTHONPATH=. .venv-wsl-pr/bin/python -m compileall -q intelmq/bots/collectors/stomp intelmq/bots/outputs/stomp intelmq/lib/mixins/stomp.py intelmq/tests/lib/test_stomp_mixin.pygit diff --check origin/develop...HEAD