From 28d9aef1a7aaf49ee688efc87096b96e7cfda291 Mon Sep 17 00:00:00 2001 From: Jack Rosenthal Date: Sun, 29 Sep 2024 14:24:15 -0600 Subject: [PATCH] Enable Python 3.8 compatibility --- kajiki/loader.py | 9 +++++++-- pyproject.toml | 5 +++-- tests/integration/test_tg2.py | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kajiki/loader.py b/kajiki/loader.py index 7e52687..8f9b227 100644 --- a/kajiki/loader.py +++ b/kajiki/loader.py @@ -1,9 +1,14 @@ from __future__ import annotations -import importlib.resources import os +import sys from pathlib import Path +if sys.version_info < (3, 9): + import importlib_resources +else: + import importlib.resources as importlib_resources + from kajiki.util import default_alias_for @@ -130,7 +135,7 @@ def __init__(self, reload=False, force_mode=None): # noqa: FBT002 def _find_resource(self, name): package, module = name.rsplit(".", 1) - package_resource = importlib.resources.files(package) + package_resource = importlib_resources.files(package) if package_resource.is_file(): msg = f"{package} refers to a module, not a package." diff --git a/pyproject.toml b/pyproject.toml index eee6469..87a73bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ version = "1.0.0.dev1" description = "Fast XML-based template engine with Genshi syntax and Jinja blocks" readme = "README.rst" license = "MIT" -requires-python = ">=3.9" +requires-python = ">=3.8" authors = [ { name = "Rick Copeland", email = "rick446@usa.net" }, { name = "Nando Florestan", email = "nandoflorestan@gmail.com" }, @@ -53,6 +53,7 @@ classifiers = [ ] dependencies = [ "linetable", + 'importlib_resources; python_version < "3.9"', ] [project.urls] @@ -70,7 +71,7 @@ extra-dependencies = [ ] [[tool.hatch.envs.hatch-test.matrix]] -python = ["3.9", "3.10", "3.11", "3.12"] +python = ["3.8", "3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.default] installer = "uv" diff --git a/tests/integration/test_tg2.py b/tests/integration/test_tg2.py index 10d725e..5debfd6 100644 --- a/tests/integration/test_tg2.py +++ b/tests/integration/test_tg2.py @@ -1,5 +1,7 @@ """Test we don't break TurboGears' usage of our Python API.""" +from __future__ import annotations + import dataclasses import wsgiref.util from pathlib import Path