From: Antti Kajander <kajaste@users.noreply.github.com>
Date: Fri, 17 Nov 2023 22:21:00 +0200
Subject: Remove runtime setuptools dependency

Prefer importlib.metadata core library on Python >= 3.8

This gets rid of setuptools dependency from stopit users. Recent
setuptools versions output a massive deprecation warning about
pkg_resources usage:
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Origin: other, https://github.com/glenfant/stopit/pull/30
Bug-Debian: https://bugs.debian.org/1083713
Last-Update: 2026-01-27
---
 src/stopit/__init__.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/stopit/__init__.py b/src/stopit/__init__.py
index 6ca0180..c75e5e3 100644
--- a/src/stopit/__init__.py
+++ b/src/stopit/__init__.py
@@ -7,18 +7,21 @@ stopit
 Public resources from ``stopit``
 """
 
-import pkg_resources
-
 from .utils import LOG, TimeoutException
 from .threadstop import ThreadingTimeout, async_raise, threading_timeoutable
 from .signalstop import SignalTimeout, signal_timeoutable
 
 # PEP 396 style version marker
 try:
-    __version__ = pkg_resources.get_distribution(__name__).version
+    from importlib.metadata import version  # Python >=3.8
+    __version__ = version(__name__)
 except:
-    LOG.warning("Could not get the package version from pkg_resources")
-    __version__ = 'unknown'
+    try:
+        import pkg_resources  # Deprecated in recent setuptools
+        __version__ = pkg_resources.get_distribution(__name__).version
+    except:
+        LOG.warning("Could not get the package version from importlib or pkg_resources")
+        __version__ = 'unknown'
 
 __all__ = (
     'ThreadingTimeout', 'async_raise', 'threading_timeoutable',
