Skip to content

Commit a3f9d87

Browse files
committed
replace package_resources with importlib
1 parent e89c033 commit a3f9d87

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fooof/tests/settings.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
"""Settings for testing fooof."""
22

33
import os
4-
import pkg_resources as pkg
4+
5+
# Use importlib to get package related paths, importing depending on Python version
6+
# Note: can drop if/else when support goes to >= 3.9 (see: https://stackoverflow.com/a/75503824)
7+
import sys
8+
if sys.version_info >= (3, 9):
9+
import importlib.resources as importlib_resources
10+
else:
11+
import importlib_resources
512

613
###################################################################################################
714
###################################################################################################
815

916
# Path Settings
10-
BASE_TEST_FILE_PATH = pkg.resource_filename(__name__, 'test_files')
17+
BASE_TEST_FILE_PATH = importlib_resources.files(__name__.split('.')[0]) / 'tests/test_files'
1118
TEST_DATA_PATH = os.path.join(BASE_TEST_FILE_PATH, 'data')
1219
TEST_REPORTS_PATH = os.path.join(BASE_TEST_FILE_PATH, 'reports')
1320
TEST_PLOTS_PATH = os.path.join(BASE_TEST_FILE_PATH, 'plots')

0 commit comments

Comments
 (0)