]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
deprecate `__version__` 2098/head
authorDavid Lord <davidism@gmail.com>
Wed, 28 May 2025 18:39:42 +0000 (11:39 -0700)
committerDavid Lord <davidism@gmail.com>
Wed, 28 May 2025 18:39:42 +0000 (11:39 -0700)
CHANGES.rst
pyproject.toml
src/jinja2/__init__.py
uv.lock

index 2b3841030209f1645e5e48c0121fe884ed506724..338dc99662c959d1dea04fa0deee944c85b2c632 100644 (file)
@@ -8,6 +8,8 @@ Unreleased
 -   Drop support for Python 3.7, 3.8, and 3.9.
 -   Update minimum MarkupSafe version to >= 3.0.
 -   Update minimum Babel version to >= 2.17.
+-   Deprecate the ``__version__`` attribute. Use feature detection or
+    ``importlib.metadata.version("jinja2")`` instead.
 -   Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.
     :pr:`1793`
 -   Use ``flit_core`` instead of ``setuptools`` as build backend.
index 04cf89aa428728c4a38a26b7637d80da90ff38ac..efc5d2beec34a7a8beb884be2d2b17076f16d025 100644 (file)
@@ -1,5 +1,6 @@
 [project]
 name = "Jinja2"
+version = "3.2.0.dev"
 description = "A very fast and expressive template engine."
 readme = "README.md"
 license = "BSD-3-Clause"
@@ -17,7 +18,6 @@ classifiers = [
 ]
 requires-python = ">=3.10"
 dependencies = ["MarkupSafe>=3.0"]
-dynamic = ["version"]
 
 [project.urls]
 Donate = "https://palletsprojects.com/donate"
index 2ac03b96e1f3adb5b0497572dd181ceaa02ee9ab..93bc023379db5a27dc33570bee0df0d6001c5753 100644 (file)
@@ -3,6 +3,10 @@ non-XML syntax that supports inline expressions and an optional
 sandboxed environment.
 """
 
+from __future__ import annotations
+
+import typing as t
+
 from .bccache import BytecodeCache as BytecodeCache
 from .bccache import FileSystemBytecodeCache as FileSystemBytecodeCache
 from .bccache import MemcachedBytecodeCache as MemcachedBytecodeCache
@@ -35,4 +39,19 @@ from .utils import pass_environment as pass_environment
 from .utils import pass_eval_context as pass_eval_context
 from .utils import select_autoescape as select_autoescape
 
-__version__ = "3.2.0.dev0"
+
+def __getattr__(name: str) -> t.Any:
+    if name == "__version__":
+        import importlib.metadata
+        import warnings
+
+        warnings.warn(
+            "The `__version__` attribute is deprecated and will be removed in"
+            " Werkzeug 3.3. Use feature detection or"
+            ' `importlib.metadata.version("werkzeug")` instead.',
+            DeprecationWarning,
+            stacklevel=2,
+        )
+        return importlib.metadata.version("werkzeug")
+
+    raise AttributeError(name)
diff --git a/uv.lock b/uv.lock
index 49096020d3aaf8556de29df3e77a764c2aca20a7..df2fe0ac67cee7a7ec3d8e0130cd49902034824d 100644 (file)
--- a/uv.lock
+++ b/uv.lock
@@ -313,6 +313,7 @@ wheels = [
 
 [[package]]
 name = "jinja2"
+version = "3.2.0.dev0"
 source = { editable = "." }
 dependencies = [
     { name = "markupsafe" },