diff --git a/CHANGELOG b/CHANGELOG index 37bd473..5a096cf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +1.0.3 + - fix: compatibility with setuptools>=82 (no `pkg_resources`), + which is shipped with CKAN 2.11.6 1.0.2 - enh: wrap long strings in tabular info view - tests: own the docker image diff --git a/ckanext/__init__.py b/ckanext/__init__.py index de40ea7..b9f5069 100644 --- a/ckanext/__init__.py +++ b/ckanext/__init__.py @@ -1 +1,11 @@ -__import__('pkg_resources').declare_namespace(__name__) +# encoding: utf-8 + +# this is a namespace package +# (same as in CKAN, compatible with setuptools<82 and setuptools>=82, +# which does not ship `pkg_resources` anymore) +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/ckanext/dc_view/tests/test_setuptools.py b/ckanext/dc_view/tests/test_setuptools.py new file mode 100644 index 0000000..8f5e1b0 --- /dev/null +++ b/ckanext/dc_view/tests/test_setuptools.py @@ -0,0 +1,10 @@ +import subprocess +import sys + + +def test_import_without_pkg_resources(): + """setuptools>=82 does not ship `pkg_resources` (e.g. CKAN 2.11.6)""" + code = ("import sys; " + "sys.modules['pkg_resources'] = None; " # import raises an error + "import ckanext.dc_view.plugin") + subprocess.check_call([sys.executable, "-c", code])