From e875685458b3d96dacd19c52ce86d90c3c01e99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Mollier?= Date: Wed, 16 Oct 2024 10:53:22 +0200 Subject: [PATCH 1/2] Migrate to importlib.metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As initially identified in [Debian bug #1083383], Fastaq depends on the Python module pkg_resources, [deprecated] since python3.11 and obsoleted in python3.13, in favor of [importlib.metadata], available since python3.8. In case Fastaq still needs to cover ancient Python interpreter versions preceeding 3.8, the change also includes a fallback to pkg_resources if the importlib is not located properly. [Debian bug #1083383]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1083383 [deprecated]: https://setuptools.pypa.io/en/latest/pkg_resources.html [importlib.metadata]: https://docs.python.org/3.11/library/importlib.metadata.html#module-importlib.metadata Signed-off-by: Étienne Mollier --- pyfastaq/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyfastaq/__init__.py b/pyfastaq/__init__.py index 5ab54d0..bcb0488 100644 --- a/pyfastaq/__init__.py +++ b/pyfastaq/__init__.py @@ -1,6 +1,8 @@ -from pkg_resources import get_distribution - try: + from importlib.metadata import Distribution + __version__ = Distribution().from_name('pyfastaq').version +except ImportError: + from pkg_resources import get_distribution __version__ = get_distribution('pyfastaq').version except: __version__ = 'local' From 55ba3a7f0a147bd78364a49a5bd8046be2b1f434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Mollier?= Date: Wed, 16 Oct 2024 11:10:39 +0200 Subject: [PATCH 2/2] Accomodate properly for local tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When packaging information is missing, the initial proposal missed falling back to the 'local' version properly. This change adjusts the try/except logic to accomodate to that situation properly. Signed-off-by: Étienne Mollier --- pyfastaq/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyfastaq/__init__.py b/pyfastaq/__init__.py index bcb0488..b092802 100644 --- a/pyfastaq/__init__.py +++ b/pyfastaq/__init__.py @@ -1,11 +1,12 @@ try: from importlib.metadata import Distribution __version__ = Distribution().from_name('pyfastaq').version -except ImportError: - from pkg_resources import get_distribution - __version__ = get_distribution('pyfastaq').version except: - __version__ = 'local' + try: + from pkg_resources import get_distribution + __version__ = get_distribution('pyfastaq').version + except: + __version__ = 'local'