Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(3.12): replace pkg_resources with importlib #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions kineticsTools/ipdModel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pkg_resources import Requirement, resource_filename
from importlib import resources
import logging
import gzip
import os.path as op
Expand Down Expand Up @@ -47,8 +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):
Expand Down
10 changes: 6 additions & 4 deletions kineticsTools/ipdSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,9 +43,11 @@ class Constants(object):


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):
Expand Down