Skip to content

Commit

Permalink
add py312 support and stop using private apis
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Feb 8, 2024
1 parent 488d8b5 commit 4fdf613
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy-3.8"
os:
- "ubuntu-latest"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bookenv/
/build
.coverage
.coverage.*
coverage.xml
dist/
/env*
Expand Down
14 changes: 14 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=================
Expand Down
1 change: 0 additions & 1 deletion rtd.txt

This file was deleted.

8 changes: 4 additions & 4 deletions src/pyramid_jinja2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/pyramid_jinja2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 4fdf613

Please sign in to comment.