From 4fdf613d265c0d0fc045a6911bc099b3f1bbc494 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Wed, 7 Feb 2024 22:49:09 -0700 Subject: [PATCH] add py312 support and stop using private apis --- .github/workflows/ci-tests.yml | 1 + .gitignore | 1 + .readthedocs.yaml | 14 ++++++++++++++ CHANGES.rst | 4 +++- rtd.txt | 1 - src/pyramid_jinja2/__init__.py | 8 ++++---- src/pyramid_jinja2/settings.py | 5 +++-- tox.ini | 2 +- 8 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 .readthedocs.yaml delete mode 100644 rtd.txt diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 35b3016..a6eae5f 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -20,6 +20,7 @@ jobs: - "3.9" - "3.10" - "3.11" + - "3.12" - "pypy-3.8" os: - "ubuntu-latest" diff --git a/.gitignore b/.gitignore index de350c4..c3f9a20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ bookenv/ /build .coverage +.coverage.* coverage.xml dist/ /env* diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..90193a5 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,14 @@ +# https://docs.readthedocs.io/en/stable/config-file/v2.html +version: 2 +build: + os: ubuntu-22.04 + tools: + python: '3.12' +sphinx: + configuration: docs/conf.py +python: + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/CHANGES.rst b/CHANGES.rst index f3f0bc3..dfa48b3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,9 @@ Unreleased (2022-11-15) - Rename "master" git branch to "main" -- Add Python 3.11 support. +- Add Python 3.11 and 3.12 support. + +- Replace usage of private Pyramid APIs. 2.10 (2022-03-27) ================= diff --git a/rtd.txt b/rtd.txt deleted file mode 100644 index 142b6ca..0000000 --- a/rtd.txt +++ /dev/null @@ -1 +0,0 @@ --e .[docs] diff --git a/src/pyramid_jinja2/__init__.py b/src/pyramid_jinja2/__init__.py index 36bd3e6..7ef4023 100644 --- a/src/pyramid_jinja2/__init__.py +++ b/src/pyramid_jinja2/__init__.py @@ -7,8 +7,7 @@ from jinja2.exceptions import TemplateNotFound from jinja2.loaders import FileSystemLoader from jinja2.utils import open_if_exists -from pyramid.asset import abspath_from_asset_spec -from pyramid.path import DottedNameResolver +from pyramid.path import AssetResolver, DottedNameResolver from zope.deprecation import deprecated from zope.interface import Interface @@ -134,7 +133,7 @@ def list_templates(self): raise TypeError("this loader cannot iterate over all templates") def _get_absolute_source(self, template): - filename = abspath_from_asset_spec(template) + filename = AssetResolver().resolve(template).abspath() fi = FileInfo(filename, self.encoding) if os.path.isfile(fi.filename): return fi.contents, fi.filename, fi.uptodate @@ -327,8 +326,9 @@ def add_jinja2_search_path(config, searchpath, name=".jinja2", prepend=False): def register(): env = get_jinja2_environment(config, name) searchpaths = parse_multiline(searchpath) + resolve = AssetResolver(config.package).resolve for folder in searchpaths: - path = abspath_from_asset_spec(folder, config.package) + path = resolve(folder).abspath() if prepend: env.loader.searchpath.insert(0, path) else: diff --git a/src/pyramid_jinja2/settings.py b/src/pyramid_jinja2/settings.py index dbe5d7f..db72785 100644 --- a/src/pyramid_jinja2/settings.py +++ b/src/pyramid_jinja2/settings.py @@ -5,7 +5,7 @@ StrictUndefined, Undefined, ) -from pyramid.asset import abspath_from_asset_spec +from pyramid.path import AssetResolver from pyramid.settings import asbool from .i18n import GetTextWrapper @@ -67,8 +67,9 @@ def sget(name, default=None): input_encoding = sget("input_encoding", "utf-8") # get jinja2 directories + resolve = AssetResolver(package).resolve directories = parse_multiline(sget("directories") or "") - directories = [abspath_from_asset_spec(d, package) for d in directories] + directories = [resolve(d).abspath() for d in directories] return dict( debug=debug, diff --git a/tox.ini b/tox.ini index 5009d3d..8221970 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = lint, - py37,py38,py39,py310,py311,pypy3, + py37,py38,py39,py310,py311,py312,pypy3, py39-pyramid{13,14,15,16,17,18,110,20}, py39-jinja2legacy, coverage,