diff --git a/src/diffpy/pdfgui/control/pdfguicontrol.py b/src/diffpy/pdfgui/control/pdfguicontrol.py index c6619417..f7d480f5 100644 --- a/src/diffpy/pdfgui/control/pdfguicontrol.py +++ b/src/diffpy/pdfgui/control/pdfguicontrol.py @@ -89,7 +89,7 @@ def run(self): def startQueue(self): """start queue manager""" - self.queueManager.setDaemon(True) + self.queueManager.daemon = True self.queueManager.start() def checkQueue(self): diff --git a/src/diffpy/pdfgui/gui/extendedplotframe.py b/src/diffpy/pdfgui/gui/extendedplotframe.py index 297a7670..bdc65f23 100644 --- a/src/diffpy/pdfgui/gui/extendedplotframe.py +++ b/src/diffpy/pdfgui/gui/extendedplotframe.py @@ -368,9 +368,9 @@ def legendBoxProperties(): return _lbp # figure out matplotlib version and appropriate names from matplotlib import __version__ as mplver - from pkg_resources import parse_version + from packaging.version import parse - if parse_version(mplver) >= parse_version("0.98.5"): + if parse(mplver) >= parse("0.98.5"): _lbp = { "loc": "upper right", "numpoints": 3, # number of points in the legend line diff --git a/src/diffpy/pdfgui/gui/pdfguiglobals.py b/src/diffpy/pdfgui/gui/pdfguiglobals.py index 96f20538..7de59ed0 100644 --- a/src/diffpy/pdfgui/gui/pdfguiglobals.py +++ b/src/diffpy/pdfgui/gui/pdfguiglobals.py @@ -16,8 +16,7 @@ """This module contains global parameters needed by PDFgui.""" import os.path - -from pkg_resources import Requirement, resource_filename +from importlib.resources import files from diffpy.pdfgui.gui import debugoptions @@ -31,23 +30,23 @@ isAltered = False # Resolve APPDATADIR base path to application data files. -_mydir = os.path.abspath(resource_filename(__name__, "")) +_mydir = os.path.abspath(str(files(__name__))) _upbasedir = os.path.normpath(_mydir + "/../../..") _development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile( - os.path.join(_upbasedir, "../setup.py") + os.path.join(_upbasedir, "../pyproject.toml") ) # Requirement must have egg-info. Do not use in _development_mode. -_req = Requirement.parse("diffpy.pdfgui") +_req = "diffpy.pdfgui" # pavol # APPDATADIR = (os.path.dirname(_upbasedir) if _development_mode -# else resource_filename(_req, "")) +# else str(files(_req))) # long if _development_mode: APPDATADIR = os.path.dirname(_mydir) else: - APPDATADIR = os.path.join(resource_filename(_req, ""), "diffpy/pdfgui") + APPDATADIR = str(files(_req)) APPDATADIR = os.path.abspath(APPDATADIR) diff --git a/src/diffpy/pdfgui/tests/__init__.py b/src/diffpy/pdfgui/tests/__init__.py index 863e9949..48cd2c62 100644 --- a/src/diffpy/pdfgui/tests/__init__.py +++ b/src/diffpy/pdfgui/tests/__init__.py @@ -35,13 +35,12 @@ def testsuite(pattern=""): The TestSuite object containing the matching tests. """ import re + from importlib.resources import files from itertools import chain from os.path import dirname - from pkg_resources import resource_filename - loader = unittest.defaultTestLoader - thisdir = resource_filename(__name__, "") + thisdir = str(files(__name__)) depth = __name__.count(".") + 1 topdir = thisdir for i in range(depth): diff --git a/src/diffpy/pdfgui/tests/testutils.py b/src/diffpy/pdfgui/tests/testutils.py index 70147319..bf0e832f 100644 --- a/src/diffpy/pdfgui/tests/testutils.py +++ b/src/diffpy/pdfgui/tests/testutils.py @@ -29,9 +29,9 @@ def datafile(filename): - from pkg_resources import resource_filename + from importlib.resources import files - rv = resource_filename(__name__, "testdata/" + filename) + rv = str(files(__name__).joinpath("testdata", filename)) return rv diff --git a/src/diffpy/pdfgui/version.py b/src/diffpy/pdfgui/version.py index 416dcb46..037c944b 100644 --- a/src/diffpy/pdfgui/version.py +++ b/src/diffpy/pdfgui/version.py @@ -25,16 +25,15 @@ __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] import os.path - -from pkg_resources import resource_filename +from importlib.resources import files # obtain version information from the version.cfg file cp = dict(version="", date="", commit="", timestamp="0") -fcfg = resource_filename(__name__, "version.cfg") +fcfg = str(files(__name__).joinpath("version.cfg")) if not os.path.isfile(fcfg): # pragma: no cover from warnings import warn - warn('Package metadata not found, execute "./setup.py egg_info".') + warn("Package metadata not found.") fcfg = os.devnull with open(fcfg) as fp: kwords = [[w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line]