From 6ceb062873748e94c6ebfa69835e854894146d25 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Fri, 8 May 2026 11:56:58 +0100 Subject: [PATCH 1/3] Replace pkg_resources with importlib.resources setuptools 81+ removed pkg_resources, so the legacy import broke diffenator2 on modern installs. Define a small resource_filename helper in utils.py that wraps importlib.resources.files() and import it where needed. --- src/diffenator2/__init__.py | 4 +--- src/diffenator2/__main__.py | 2 +- src/diffenator2/_diffbrowsers.py | 3 +-- src/diffenator2/_diffenator.py | 1 - src/diffenator2/shape.py | 3 +-- src/diffenator2/utils.py | 6 +++++- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/diffenator2/__init__.py b/src/diffenator2/__init__.py index 4f00787..bdae105 100644 --- a/src/diffenator2/__init__.py +++ b/src/diffenator2/__init__.py @@ -3,11 +3,9 @@ import os from ninja.ninja_syntax import Writer from diffenator2.renderer import FONT_SIZE -from diffenator2.utils import dict_coords_to_string +from diffenator2.utils import dict_coords_to_string, partition, resource_filename from diffenator2.font import DFont, get_font_styles -from diffenator2.utils import partition from diffenator2.matcher import FontMatcher -from pkg_resources import resource_filename import shutil import ninja diff --git a/src/diffenator2/__main__.py b/src/diffenator2/__main__.py index d841b78..d36c303 100644 --- a/src/diffenator2/__main__.py +++ b/src/diffenator2/__main__.py @@ -6,7 +6,7 @@ from diffenator2.font import DFont from diffenator2.html import build_index_page from diffenator2.renderer import FONT_SIZE -from pkg_resources import resource_filename +from diffenator2.utils import resource_filename from glob import glob diff --git a/src/diffenator2/_diffbrowsers.py b/src/diffenator2/_diffbrowsers.py index 5a41d2b..1b741d7 100755 --- a/src/diffenator2/_diffbrowsers.py +++ b/src/diffenator2/_diffbrowsers.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 from __future__ import annotations -from pkg_resources import resource_filename from diffenator2.html import proof_rendering, diff_rendering from diffenator2.font import DFont, get_font_styles from diffenator2.matcher import FontMatcher -from diffenator2.utils import re_filter_characters +from diffenator2.utils import re_filter_characters, resource_filename from glob import glob import os import sys diff --git a/src/diffenator2/_diffenator.py b/src/diffenator2/_diffenator.py index 2ddba63..c410c5d 100755 --- a/src/diffenator2/_diffenator.py +++ b/src/diffenator2/_diffenator.py @@ -11,7 +11,6 @@ ) from diffenator2.font import DFont from diffenator2.matcher import FontMatcher -from pkg_resources import resource_filename import os from diffenator2.shape import test_words, test_fonts from diffenator2 import jfont, THRESHOLD diff --git a/src/diffenator2/shape.py b/src/diffenator2/shape.py index 99bb503..d5825a1 100644 --- a/src/diffenator2/shape.py +++ b/src/diffenator2/shape.py @@ -8,8 +8,7 @@ from diffenator2 import THRESHOLD from diffenator2.renderer import FONT_SIZE, PixelDiffer from diffenator2.template_elements import Word, WordDiff, Glyph, GlyphDiff -from diffenator2.utils import gen_gif -from pkg_resources import resource_filename +from diffenator2.utils import gen_gif, resource_filename import tqdm from diffenator2.segmenting import textSegments from collections import defaultdict diff --git a/src/diffenator2/utils.py b/src/diffenator2/utils.py index 10a7d50..0edf2da 100644 --- a/src/diffenator2/utils.py +++ b/src/diffenator2/utils.py @@ -15,7 +15,7 @@ # from __future__ import annotations import os -from pkg_resources import resource_filename +from importlib.resources import files from PIL import Image from gflanguages import LoadLanguages from functools import lru_cache @@ -33,6 +33,10 @@ TEST_STRINGS_DATA = os.path.join(os.path.dirname(__file__), "data", "test_strings.json") +def resource_filename(package: str, resource: str) -> str: + return str(files(package).joinpath(resource)) + + def dict_coords_to_string(coords: dict[str, float]) -> str: return ",".join(f"{k}={v}" for k, v in coords.items()) From 24d0cc13f9b5a802d4ecc981a4ee52bd88100415 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Fri, 8 May 2026 11:57:54 +0100 Subject: [PATCH 2/3] Relax tight version pins on transitive deps The previous caret pins (^X.Y) and a hard cap on python-bidi forced downstream consumers (e.g. gftools) to backtrack heavily during pip resolution. Switch to >= lower bounds where the upstream APIs are stable enough. - blackrenderer: ^0.6.0 -> >=0.6.0 - unicodedata2: ^15.0.0 -> >=15.0.0 (unblocks fontTools 4.62+) - youseedee: ^0.5.0 -> >=0.5.0 - python-bidi: <0.5.0 -> * --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fcad74d..77b3b34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,11 +21,11 @@ ninja = "*" protobuf = ">=3.19.2, <=3.20.3" gflanguages = "*" freetype-py = "*" -blackrenderer = {extras = ["skia"], version = "^0.6.0"} -unicodedata2 = "^15.0.0" +blackrenderer = {extras = ["skia"], version = ">=0.6.0"} +unicodedata2 = ">=15.0.0" tqdm = "^4.64.1" -youseedee = "^0.5.0" -python-bidi = "<0.5.0" +youseedee = ">=0.5.0" +python-bidi = "*" [build-system] requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"] From 48dd58baf91606f668bfe687ca35faafc414d907 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Fri, 8 May 2026 12:14:35 +0100 Subject: [PATCH 3/3] ci: install libegl1 on Ubuntu runner skia-python (pulled in by blackrenderer[skia]) loads libEGL.so.1 at import time. Recent versions of skia-python no longer bundle it, so the Ubuntu runner must provide it via apt. macOS is unaffected. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fac4011..0b39c5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,9 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install system dependencies (Linux) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libegl1 - name: Install packages run: | pip install .