Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.1.5
- fix: compatibility with setuptools>=82 (no `pkg_resources`),
which is shipped with CKAN 2.11.6
1.1.4
- ref: replace "word-wrap" with "overflow-wrap"
- tests: own the docker image
Expand Down
12 changes: 11 additions & 1 deletion ckanext/__init__.py
Original file line number Diff line number Diff line change
@@ -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__)
6 changes: 3 additions & 3 deletions ckanext/dcor_theme/cli/i18n_branding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import OrderedDict
from importlib import resources as importlib_resources
import logging
import pathlib
import pkg_resources
import subprocess

import babel.messages.pofile
Expand Down Expand Up @@ -51,8 +51,8 @@ def replace_branding(msgid):

@click.command()
def dcor_theme_i18n_branding():
src = pathlib.Path(pkg_resources.resource_filename("ckan.i18n",
"ckan.pot"))
src = pathlib.Path(str(importlib_resources.files("ckan.i18n")
/ "ckan.pot"))
# load file and replace known strings
with src.open("r", encoding="utf-8") as fd:
poin = babel.messages.pofile.read_po(fd)
Expand Down
7 changes: 4 additions & 3 deletions ckanext/dcor_theme/css/make_dcor_main_css.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Map CKAN default colors to DCOR colors and generate dcor_theme_colors.css"""
import pkg_resources
from importlib import resources as importlib_resources
import pathlib

#: Path to CKAN's main.css
ckan_css_path = pathlib.Path(
pkg_resources.resource_filename("ckan", "public/base/css/main.css"))
ckan_css_path = pathlib.Path(str(
importlib_resources.files("ckan") / "public" / "base" / "css"
/ "main.css"))

#: Dictionary mapping default colors to DCOR colors
color_map = {
Expand Down
10 changes: 10 additions & 0 deletions ckanext/dcor_theme/tests/test_setuptools.py
Original file line number Diff line number Diff line change
@@ -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.dcor_theme.plugin")
subprocess.check_call([sys.executable, "-c", code])
Loading