diff --git a/CHANGELOG.md b/CHANGELOG.md index 77cba765b..5cf38f03a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o ### Configuration ### Core +- `intelmq.bin.intelmqctl`: Use `importlib.metadata` instead of deprecated `pkg_resources` to determine the installed version, fixing bot module discovery failing on Debian 13 (PR#2721 by Sebastian Wagner, fixes #2648). ### Development @@ -40,6 +41,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o - Updates to Contrib and Overview pages (PR#2672 by Sebastian Wagner). ### Packaging +- `debian/rules`: Run tests with `PYTHONPATH` pointing to the pybuild build directory, fixing the intelmq distribution not being detected during `dh_auto_test` on Debian 13 (PR#2721 by Sebastian Wagner, fixes #2675). ### Tests - `intelmq.tests.bots.parsers.openphish.test_parser_commercial`: Replace dummy key with more obvious dummy key, generate raw from input (PR#2665 by Sebastian Wagner, fixes #2663). diff --git a/debian/rules b/debian/rules index 01bc3be2a..0aa4293c9 100755 --- a/debian/rules +++ b/debian/rules @@ -34,6 +34,14 @@ override_dh_auto_build: dh_auto_build # $(MAKE) docs +override_dh_auto_test: + # https://github.com/certtools/intelmq/issues/2675 + # on Debian 13's pybuild-driven dh_auto_test, the package's installed metadata (entry points / distribution info) isn't visible to the test run, since it happens against a build-dir copy without the source tree's egg-info on PYTHONPATH. + # make sure the build directory (which does contain the generated egg-info) is importable, fixing distribution/entry-point discovery + PYBUILD_SYSTEM=custom \ + PYBUILD_TEST_ARGS="cd {build_dir}; PYTHONPATH={build_dir} python{version} -m pytest --no-cov intelmq/tests/" \ + dh_auto_test + override_dh_auto_install: $(BOTDOCS) sed -i -e '/#!\/usr\/bin\//d' intelmq/bin/*.py sed -i -f debian/sedfile intelmq/etc/* setup.py contrib/logrotate/intelmq contrib/logcheck/logcheck.logfiles diff --git a/intelmq/bin/intelmqctl.py b/intelmq/bin/intelmqctl.py index 9668e0327..1c9f29d3b 100644 --- a/intelmq/bin/intelmqctl.py +++ b/intelmq/bin/intelmqctl.py @@ -17,9 +17,13 @@ import traceback import time -import pkg_resources from ruamel.yaml import YAML +try: + from importlib.metadata import version as _pkg_version, PackageNotFoundError +except ImportError: # pragma: no cover + from importlib_metadata import version as _pkg_version, PackageNotFoundError + from intelmq import (DEFAULT_LOGGING_LEVEL, # noqa: F401 HARMONIZATION_CONF_FILE, RUNTIME_CONF_FILE, VAR_RUN_PATH, STATE_FILE_PATH, @@ -127,10 +131,10 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp APPNAME = "intelmqctl" try: - VERSION = pkg_resources.get_distribution("intelmq").version - except pkg_resources.DistributionNotFound: # pragma: no cover + VERSION = _pkg_version("intelmq") + except PackageNotFoundError: # pragma: no cover # can only happen in interactive mode - self._logger.error('No valid IntelMQ installation found: DistributionNotFound') + self._logger.error('No valid IntelMQ installation found: PackageNotFoundError') sys.exit(1) DESCRIPTION = """ description: intelmqctl is the tool to control intelmq system.