Skip to content

fix: compatibility with setuptools>=82 (no pkg_resources) - #9

Merged
paulmueller merged 1 commit into
DCOR-dev:masterfrom
paulmueller-agent:setuptools82-compat
Nov 3, 2026
Merged

paulmueller merged 1 commit into
DCOR-dev:masterfrom
paulmueller-agent:setuptools82-compat

Conversation

@paulmueller-agent

Copy link
Copy Markdown

Required for the upgrade of DCOR instances from CKAN 2.11.5 to 2.11.6.

Problem

The CKAN 2.11.6 package (python-ckan_2.11-noble_amd64.deb) ships setuptools 84.0.0, which no longer contains pkg_resources (CKAN 2.11.6 changelog: "Removed setuptools upper limit requirement"). I verified this by installing CKAN 2.11.6 in an environment that uses the site-packages of that package. With the current master, importing the plugins of ckanext-dcor_schemas, ckanext-dcor_depot and ckanext-dcor_theme fails with ModuleNotFoundError: No module named 'pkg_resources', so CKAN would not start with the DCOR plugins.

The extension CI did not catch this: the ckan/ckan-dev:2.11 image already runs CKAN 2.11.6, but it still ships an older setuptools with pkg_resources.

Changes

  • ckanext/__init__.py: the same namespace declaration that CKAN 2.11.6 uses itself. It still uses pkg_resources when available and falls back to pkgutil.extend_path otherwise.
  • cli/i18n_branding.py and css/make_dcor_main_css.py: pkg_resources.resource_filename → importlib.resources.files (i18n_branding is imported by plugin.py via cli/__init__.py, so the plugin could not be loaded at all)
  • New test tests/test_setuptools.py: imports the plugin in a subprocess with pkg_resources blocked (sys.modules['pkg_resources'] = None), independent of the setuptools version in the CI image.
  • CHANGELOG

Verification

In an environment with CKAN 2.11.6 and setuptools 84 (the site-packages of the 2.11.6 package), with all six DCOR extensions installed editable:

  • all plugins import (dcor_schemas, dcor_depot incl. CLI, dcor_theme incl. CLI, dc_serve, dc_view, dc_log_view)
  • the supplementary resource schemas load (6 sections), the figshare DOI list is readable, and ckan.pot and CKAN's main.css are found
  • the new test passes with this change and fails on master (for dcor_schemas, dcor_depot and dcor_theme)

Same change in all six extensions: ckanext-dcor_schemas, ckanext-dcor_depot, ckanext-dcor_theme, ckanext-dc_serve, ckanext-dc_view, ckanext-dc_log_view. They are independent of each other, but all of them need a release before production can be upgraded to CKAN 2.11.6.

🤖 Generated with Claude Code

CKAN 2.11.6 ships setuptools 84, which does not contain `pkg_resources`
anymore. Use the same namespace declaration in `ckanext/__init__.py`
as CKAN does and replace any other `pkg_resources` usage with
`importlib.resources`. Add a test that imports the plugin without
`pkg_resources`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulmueller
paulmueller merged commit 4f3bae7 into DCOR-dev:master Nov 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants