Description: Remove usages of pkg_resources
 pkg_resources are no longer available in Python 3.12 due to setuptools
 removal from the default installation. This patch replaces the usages of
 pkg_resources with importlib.resources.
Author: Vladimir Petko <vladimir.petko@canonical.com>
Bug: https://github.com/PacificBiosciences/kineticsTools/pull/105
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/kineticstools/+bug/2095050
Last-Update: 2025-01-16

--- a/kineticsTools/ipdModel.py
+++ b/kineticsTools/ipdModel.py
@@ -1,4 +1,4 @@
-from pkg_resources import Requirement, resource_filename
+from importlib import resources
 import logging
 import gzip
 import os.path as op
@@ -47,9 +47,11 @@


 def _getAbsPath(fname):
-    return resource_filename(Requirement.parse(
-        'kineticsTools'), 'kineticsTools/%s' % fname)
-
+    try:
+        with resources.as_file(resources.files('kineticsTools') / fname) as path:
+            return str(path)
+    except:
+        return os.path.join(os.path.dirname(__file__), path)

 class GbmContextModel(object):

--- a/kineticsTools/ipdSummary.py
+++ b/kineticsTools/ipdSummary.py
@@ -20,7 +20,7 @@
 import numpy as np
 import queue
 import traceback
-from pkg_resources import Requirement, resource_filename
+from importlib import resources

 from pbcommand.common_options import add_debug_option
 from pbcommand.cli import get_default_argparser_with_base_opts, pacbio_args_runner
@@ -43,9 +43,11 @@


 def _getResourcePathSpec():
-    default_dir = resource_filename(Requirement.parse(
-        'kineticsTools'), 'kineticsTools/resources')
-    return loader.getResourcePathSpec(default_dir)
+    try:
+        with resources.as_file(resources.files('kineticTools') / 'resources') as path:
+            return loader.getResourcePathSpec(path)
+    except:
+        return loader.getResourcePathSpec(os.path.join(os.path.dirname(__file__), 'resources'))


 def _validateResource(func, p):
