dev-python/jinja: Sync with Gentoo

It's from Gentoo commit d19374ca93509e623f9e663bcfa0086e9e81f710.
This commit is contained in:
Flatcar Buildbot 2024-07-01 07:14:07 +00:00 committed by Mathieu Tortuyaux
parent a90053e503
commit ffdd02c721
No known key found for this signature in database
GPG Key ID: AC5CCFB52545D9B8
3 changed files with 78 additions and 19 deletions

View File

@ -1 +1 @@
DIST jinja-3.1.3.gh.tar.gz 274692 BLAKE2B 0c66600104db89ed17c0a0c58180e8a348f9d505504f4ae1bee01c8c09053994140f87a4d336255e292258f15adc3e535deef494e8fda980ef76547268ddc4fa SHA512 1f4384b3a1cd0f8e128608aa11d00c41f93b6be41459d9e5d8f50e6f879d2427aaea5d04681c85a1577651b9dc434c11c5e7c7caecef6f5fe26518a3d2fdc77e
DIST jinja2-3.1.4.tar.gz 240245 BLAKE2B cb70699cea93ddf53b7c8876b9006cc70599d49f8c64ab615759a53db6829cab7b55ac673777bc4c8dc5dfc68efada29d37f47fe7cf449044721f659fe6a654d SHA512 d07d68a2687af68c705d3b7f5a2c67aca7b9d125316b15085888b9d0d6e769981af76f6f524728b89b5501bd671d518fcb2638f9ae112e57ca2bf2a53482cd89

View File

@ -0,0 +1,67 @@
From 679af7f816ced8941ed5cf9b151a0cac543d0336 Mon Sep 17 00:00:00 2001
From: Thomas Grainger <tagrain@gmail.com>
Date: Mon, 13 May 2024 18:02:35 +0100
Subject: [PATCH] fix test_package_zip_list on 3.13
---
src/jinja2/loaders.py | 32 ++++++++++++++++++++++++++------
tests/test_loader.py | 2 +-
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/src/jinja2/loaders.py b/src/jinja2/loaders.py
index 9eaf647ba..8c2c86cd0 100644
--- a/src/jinja2/loaders.py
+++ b/src/jinja2/loaders.py
@@ -238,6 +238,30 @@ def list_templates(self) -> t.List[str]:
return sorted(found)
+if sys.version_info >= (3, 13):
+
+ def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]:
+ try:
+ get_files = z._get_files
+ except AttributeError as e:
+ raise TypeError(
+ "This zip import does not have the required"
+ " metadata to list templates."
+ ) from e
+ return get_files()
+else:
+
+ def _get_zipimporter_files(z: t.Any) -> t.Dict[str, object]:
+ try:
+ files = z._files
+ except AttributeError as e:
+ raise TypeError(
+ "This zip import does not have the required"
+ " metadata to list templates."
+ ) from e
+ return files # type: ignore[no-any-return]
+
+
class PackageLoader(BaseLoader):
"""Load templates from a directory in a Python package.
@@ -382,11 +406,7 @@ def list_templates(self) -> t.List[str]:
for name in filenames
)
else:
- if not hasattr(self._loader, "_files"):
- raise TypeError(
- "This zip import does not have the required"
- " metadata to list templates."
- )
+ files = _get_zipimporter_files(self._loader)
# Package is a zip file.
prefix = (
@@ -395,7 +415,7 @@ def list_templates(self) -> t.List[str]:
)
offset = len(prefix)
- for name in self._loader._files.keys():
+ for name in files:
# Find names under the templates directory that aren't directories.
if name.startswith(prefix) and name[-1] != os.path.sep:
results.append(name[offset:].replace(os.path.sep, "/"))

View File

@ -3,11 +3,12 @@
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{10..12} pypy3 )
DISTUTILS_USE_PEP517=flit
PYPI_PN=jinja2
PYTHON_COMPAT=( python3_{10..13} pypy3 )
PYTHON_REQ_USE="threads(+)"
inherit distutils-r1
inherit distutils-r1 pypi
DESCRIPTION="A full-featured template engine for Python"
HOMEPAGE="
@ -15,18 +16,13 @@ HOMEPAGE="
https://github.com/pallets/jinja/
https://pypi.org/project/Jinja2/
"
SRC_URI="
https://github.com/pallets/jinja/archive/${PV}.tar.gz
-> ${P}.gh.tar.gz
"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
IUSE="examples"
RDEPEND="
>=dev-python/markupsafe-2.0.0[${PYTHON_USEDEP}]
>=dev-python/markupsafe-2.0[${PYTHON_USEDEP}]
"
distutils_enable_sphinx docs \
@ -37,21 +33,17 @@ distutils_enable_tests pytest
# XXX: handle Babel better?
src_prepare() {
local PATCHES=(
# https://github.com/pallets/jinja/pull/1979
"${FILESDIR}/${P}-py313.patch"
)
# avoid unnecessary dep on extra sphinxcontrib modules
sed -i '/sphinxcontrib.log_cabinet/ d' docs/conf.py || die
distutils-r1_src_prepare
}
python_install_all() {
if use examples ; then
docinto examples
dodoc -r examples/.
fi
distutils-r1_python_install_all
}
pkg_postinst() {
if ! has_version dev-python/Babel; then
elog "For i18n support, please emerge dev-python/Babel."