diff --git a/cssutils/tests/basetest.py b/cssutils/tests/basetest.py index 5a255755..ff628cbd 100644 --- a/cssutils/tests/basetest.py +++ b/cssutils/tests/basetest.py @@ -6,6 +6,11 @@ import sys import unittest +try: + from importlib import resources +except ImportError: + import importlib_resources as resources + import cssutils @@ -27,9 +32,8 @@ def get_resource_filename(resource_name): def get_sheet_filename(sheet_name): """Get the filename for the given sheet.""" - # Extract all sheets since they might use @import - sheet_dir = get_resource_filename('tests/sheets') - return os.path.join(sheet_dir, sheet_name) + # assume resources are on the file system + return resources.files('cssutils') / 'tests' / 'sheets' / sheet_name class BaseTestCase(unittest.TestCase): diff --git a/examples/style.py b/examples/style.py index 616277b2..0d8b7335 100644 --- a/examples/style.py +++ b/examples/style.py @@ -8,24 +8,14 @@ """ import codecs import cssutils -import os import sys import webbrowser -# lxml egg may be in a lib dir below this file (not in SVN though) -sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) -try: - import pkg_resources - - pkg_resources.require('lxml') -except pkg_resources.DistributionNotFound: - pass - try: from lxml import etree from lxml.cssselect import CSSSelector except ImportError as e: - print('You need lxml for this example:', e) + print('lxml is required:', e) sys.exit(1) diff --git a/setup.cfg b/setup.cfg index 044e92f7..f5d20261 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,7 +27,6 @@ include_package_data = true python_requires = >=3.6 install_requires = importlib_metadata; python_version < "3.8" - setuptools setup_requires = setuptools_scm[toml] >= 3.4.1 [options.packages.find] @@ -59,6 +58,7 @@ testing = mock lxml cssselect + importlib_resources; python_version < "3.9" docs = # upstream