From a763fbbdfd6486e372965b4009eb3fe5db346718 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Sat, 27 Apr 2024 10:24:01 -0700 Subject: [PATCH] replace distutils for python 3.12 --- doc/conf.py | 5 +---- fail2ban/server/filterpyinotify.py | 3 +-- fail2ban/server/filtersystemd.py | 3 +-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 20845a5a0..48d27f706 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -47,12 +47,9 @@ copyright = u'2014' # from fail2ban.version import version as fail2ban_version -from distutils.version import LooseVersion - -fail2ban_loose_version = LooseVersion(fail2ban_version) # The short X.Y version. -version = ".".join(str(_) for _ in fail2ban_loose_version.version[:2]) +version = ".".join(str(_) for _ in fail2ban_version.split(".")[:2]) # The full version, including alpha/beta/rc tags. release = fail2ban_version diff --git a/fail2ban/server/filterpyinotify.py b/fail2ban/server/filterpyinotify.py index 81bc7de39..c6972ced3 100644 --- a/fail2ban/server/filterpyinotify.py +++ b/fail2ban/server/filterpyinotify.py @@ -24,7 +24,6 @@ __copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2011-2012 Lee Clemens, 2012 Y __license__ = "GPL" import logging -from distutils.version import LooseVersion import os from os.path import dirname, sep as pathsep @@ -38,7 +37,7 @@ from ..helpers import getLogger if not hasattr(pyinotify, '__version__') \ - or LooseVersion(pyinotify.__version__) < '0.8.3': # pragma: no cover + or pyinotify.__version__.split(".") < '0.8.3'.split("."): # pragma: no cover raise ImportError("Fail2Ban requires pyinotify >= 0.8.3") # Verify that pyinotify is functional on this system diff --git a/fail2ban/server/filtersystemd.py b/fail2ban/server/filtersystemd.py index 5aea9fdad..2d4f862b9 100644 --- a/fail2ban/server/filtersystemd.py +++ b/fail2ban/server/filtersystemd.py @@ -24,10 +24,9 @@ __license__ = "GPL" import os import time -from distutils.version import LooseVersion from systemd import journal -if LooseVersion(getattr(journal, '__version__', "0")) < '204': +if getattr(journal, "__version__", "0").split(".") < "204".split("."): raise ImportError("Fail2Ban requires systemd >= 204") from .failmanager import FailManagerEmpty