From 905a37fdff51453fee000c8e8e188aea4420e613 Mon Sep 17 00:00:00 2001 From: Tieqiong <123656525+Tieqiong@users.noreply.github.com> Date: Thu, 22 Aug 2024 05:30:16 -0400 Subject: [PATCH] fix not a package type error for importlib (#193) * fix not a package type error for importlib * [pre-commit.ci] auto fixes from pre-commit hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/diffpy/pdfgui/gui/pdfguiglobals.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/diffpy/pdfgui/gui/pdfguiglobals.py b/src/diffpy/pdfgui/gui/pdfguiglobals.py index 7de59ed0..cbfdc911 100644 --- a/src/diffpy/pdfgui/gui/pdfguiglobals.py +++ b/src/diffpy/pdfgui/gui/pdfguiglobals.py @@ -30,7 +30,11 @@ isAltered = False # Resolve APPDATADIR base path to application data files. -_mydir = os.path.abspath(str(files(__name__))) +try: + _mydir = os.path.abspath(str(files(__name__))) +except TypeError: # For Python < 3.12 + _mydir = os.path.abspath(os.path.dirname(__file__)) + _upbasedir = os.path.normpath(_mydir + "/../../..") _development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile( os.path.join(_upbasedir, "../pyproject.toml")