]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
add warning and alias for jinja2 1121/head
authorDavid Lord <davidism@gmail.com>
Fri, 10 Jan 2020 22:40:27 +0000 (14:40 -0800)
committerDavid Lord <davidism@gmail.com>
Fri, 10 Jan 2020 23:30:16 +0000 (15:30 -0800)
39 files changed:
MANIFEST.in
jinja2-compat/LICENSE.rst [new file with mode: 0644]
jinja2-compat/MANIFEST.in [new file with mode: 0644]
jinja2-compat/README.rst [new file with mode: 0644]
jinja2-compat/setup.cfg [new file with mode: 0644]
jinja2-compat/setup.py [new file with mode: 0644]
jinja2-compat/src/jinja2/__init__.py [new file with mode: 0644]
jinja2-compat/src/jinja2/_compat.py [new file with mode: 0644]
jinja2-compat/src/jinja2/_identifier.py [new file with mode: 0644]
jinja2-compat/src/jinja2/asyncfilters.py [new file with mode: 0644]
jinja2-compat/src/jinja2/asyncsupport.py [new file with mode: 0644]
jinja2-compat/src/jinja2/bccache.py [new file with mode: 0644]
jinja2-compat/src/jinja2/compiler.py [new file with mode: 0644]
jinja2-compat/src/jinja2/constants.py [new file with mode: 0644]
jinja2-compat/src/jinja2/debug.py [new file with mode: 0644]
jinja2-compat/src/jinja2/defaults.py [new file with mode: 0644]
jinja2-compat/src/jinja2/environment.py [new file with mode: 0644]
jinja2-compat/src/jinja2/exceptions.py [new file with mode: 0644]
jinja2-compat/src/jinja2/ext.py [new file with mode: 0644]
jinja2-compat/src/jinja2/filters.py [new file with mode: 0644]
jinja2-compat/src/jinja2/idtracking.py [new file with mode: 0644]
jinja2-compat/src/jinja2/lexer.py [new file with mode: 0644]
jinja2-compat/src/jinja2/loaders.py [new file with mode: 0644]
jinja2-compat/src/jinja2/meta.py [new file with mode: 0644]
jinja2-compat/src/jinja2/nativetypes.py [new file with mode: 0644]
jinja2-compat/src/jinja2/nodes.py [new file with mode: 0644]
jinja2-compat/src/jinja2/optimizer.py [new file with mode: 0644]
jinja2-compat/src/jinja2/parser.py [new file with mode: 0644]
jinja2-compat/src/jinja2/runtime.py [new file with mode: 0644]
jinja2-compat/src/jinja2/sandbox.py [new file with mode: 0644]
jinja2-compat/src/jinja2/tests.py [new file with mode: 0644]
jinja2-compat/src/jinja2/utils.py [new file with mode: 0644]
jinja2-compat/src/jinja2/visitor.py [new file with mode: 0644]
setup.py
src/jinja/__init__.py
src/jinja/compiler.py
src/jinja/defaults.py
src/jinja/runtime.py
tests/test_bytecode_cache.py

index 8cae0c743c6bb86b21ef4ef0395c9650918b8236..bf02825672beba06116406a0a99df26d9b2b0817 100644 (file)
@@ -5,3 +5,4 @@ prune docs/_build
 graft examples
 graft ext
 graft tests
+global-exclude *.pyc
diff --git a/jinja2-compat/LICENSE.rst b/jinja2-compat/LICENSE.rst
new file mode 100644 (file)
index 0000000..c37cae4
--- /dev/null
@@ -0,0 +1,28 @@
+Copyright 2007 Pallets
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1.  Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+2.  Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+
+3.  Neither the name of the copyright holder nor the names of its
+    contributors may be used to endorse or promote products derived from
+    this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/jinja2-compat/MANIFEST.in b/jinja2-compat/MANIFEST.in
new file mode 100644 (file)
index 0000000..40c6ac8
--- /dev/null
@@ -0,0 +1 @@
+global-exclude *.pyc
diff --git a/jinja2-compat/README.rst b/jinja2-compat/README.rst
new file mode 100644 (file)
index 0000000..b240416
--- /dev/null
@@ -0,0 +1,9 @@
+The Jinja2 package has been renamed to `Jinja`_. This package provides
+compatibility while projects transition to the new name. Imports from
+``jinja2`` will be redirected to ``jinja`` and a deprecation warning
+will be emitted.
+
+Projects are advised to require 'Jinja' instead of 'Jinja2' and replace
+all imports of ``jinja2`` with ``jinja`` to continue receiving updates.
+
+.. _Jinja: https://pypi.org/project/Jinja/
diff --git a/jinja2-compat/setup.cfg b/jinja2-compat/setup.cfg
new file mode 100644 (file)
index 0000000..cf42c63
--- /dev/null
@@ -0,0 +1,5 @@
+[metadata]
+license_file = LICENSE.rst
+
+[bdist_wheel]
+universal = true
diff --git a/jinja2-compat/setup.py b/jinja2-compat/setup.py
new file mode 100644 (file)
index 0000000..9edc0d9
--- /dev/null
@@ -0,0 +1,53 @@
+import io
+
+from setuptools import find_packages
+from setuptools import setup
+
+with io.open("README.rst", "rt", encoding="utf8") as f:
+    readme = f.read()
+
+setup(
+    name="Jinja2",
+    version="2.11.0rc1",
+    url="https://palletsprojects.com/p/jinja/",
+    project_urls={
+        "Documentation": "https://jinja.palletsprojects.com/",
+        "Code": "https://github.com/pallets/jinja",
+        "Issue tracker": "https://github.com/pallets/jinja/issues",
+    },
+    license="BSD-3-Clause",
+    maintainer="Pallets",
+    maintainer_email="contact@palletsprojects.com",
+    description=(
+        "A very fast and expressive template engine. Compatibility"
+        " package for Jinja2 to Jinja rename."
+    ),
+    long_description=readme,
+    classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        "Environment :: Web Environment",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
+        "Programming Language :: Python :: Implementation :: CPython",
+        "Programming Language :: Python :: Implementation :: PyPy",
+        "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        "Topic :: Text Processing :: Markup :: HTML",
+    ],
+    packages=find_packages("src"),
+    package_dir={"": "src"},
+    include_package_data=True,
+    python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
+    install_requires=["Jinja<4.0"],
+    extras_require={"i18n": ["Babel>=0.8"]},
+    entry_points={"babel.extractors": ["jinja2 = jinja2.ext:babel_extract[i18n]"]},
+)
diff --git a/jinja2-compat/src/jinja2/__init__.py b/jinja2-compat/src/jinja2/__init__.py
new file mode 100644 (file)
index 0000000..526ee78
--- /dev/null
@@ -0,0 +1,21 @@
+def _export_jinja(name, ns):
+    import warnings
+    from importlib import import_module
+
+    mod_name = "jinja" if not name else ("jinja." + name)
+    warnings.warn(
+        "'jinja2' has been renamed to 'jinja'. Import from %r instead." % mod_name,
+        DeprecationWarning,
+        stacklevel=3,
+    )
+    mod = import_module(mod_name)
+
+    for key, value in vars(mod).items():
+        if not key.startswith("__") or key == "__version__":
+            ns[key] = value
+
+    if name:
+        ns.pop("_export_jinja")
+
+
+_export_jinja(None, globals())
diff --git a/jinja2-compat/src/jinja2/_compat.py b/jinja2-compat/src/jinja2/_compat.py
new file mode 100644 (file)
index 0000000..d0b2d95
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("_compat", globals())
diff --git a/jinja2-compat/src/jinja2/_identifier.py b/jinja2-compat/src/jinja2/_identifier.py
new file mode 100644 (file)
index 0000000..64dc1dd
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("_identifier", globals())
diff --git a/jinja2-compat/src/jinja2/asyncfilters.py b/jinja2-compat/src/jinja2/asyncfilters.py
new file mode 100644 (file)
index 0000000..e85c81b
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("asyncfilters", globals())
diff --git a/jinja2-compat/src/jinja2/asyncsupport.py b/jinja2-compat/src/jinja2/asyncsupport.py
new file mode 100644 (file)
index 0000000..bbc91ac
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("asyncsupport", globals())
diff --git a/jinja2-compat/src/jinja2/bccache.py b/jinja2-compat/src/jinja2/bccache.py
new file mode 100644 (file)
index 0000000..15164f1
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("bccache", globals())
diff --git a/jinja2-compat/src/jinja2/compiler.py b/jinja2-compat/src/jinja2/compiler.py
new file mode 100644 (file)
index 0000000..d198e0b
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("compiler", globals())
diff --git a/jinja2-compat/src/jinja2/constants.py b/jinja2-compat/src/jinja2/constants.py
new file mode 100644 (file)
index 0000000..0026675
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("constants", globals())
diff --git a/jinja2-compat/src/jinja2/debug.py b/jinja2-compat/src/jinja2/debug.py
new file mode 100644 (file)
index 0000000..6fa47bc
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("debug", globals())
diff --git a/jinja2-compat/src/jinja2/defaults.py b/jinja2-compat/src/jinja2/defaults.py
new file mode 100644 (file)
index 0000000..e3bece6
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("defaults", globals())
diff --git a/jinja2-compat/src/jinja2/environment.py b/jinja2-compat/src/jinja2/environment.py
new file mode 100644 (file)
index 0000000..5062aba
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("environment", globals())
diff --git a/jinja2-compat/src/jinja2/exceptions.py b/jinja2-compat/src/jinja2/exceptions.py
new file mode 100644 (file)
index 0000000..3ad241e
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("exceptions", globals())
diff --git a/jinja2-compat/src/jinja2/ext.py b/jinja2-compat/src/jinja2/ext.py
new file mode 100644 (file)
index 0000000..923754e
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("ext", globals())
diff --git a/jinja2-compat/src/jinja2/filters.py b/jinja2-compat/src/jinja2/filters.py
new file mode 100644 (file)
index 0000000..9517e64
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("filters", globals())
diff --git a/jinja2-compat/src/jinja2/idtracking.py b/jinja2-compat/src/jinja2/idtracking.py
new file mode 100644 (file)
index 0000000..755ef1b
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("idtracking", globals())
diff --git a/jinja2-compat/src/jinja2/lexer.py b/jinja2-compat/src/jinja2/lexer.py
new file mode 100644 (file)
index 0000000..e69c99c
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("lexer", globals())
diff --git a/jinja2-compat/src/jinja2/loaders.py b/jinja2-compat/src/jinja2/loaders.py
new file mode 100644 (file)
index 0000000..3616eee
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("loaders", globals())
diff --git a/jinja2-compat/src/jinja2/meta.py b/jinja2-compat/src/jinja2/meta.py
new file mode 100644 (file)
index 0000000..406d047
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("meta", globals())
diff --git a/jinja2-compat/src/jinja2/nativetypes.py b/jinja2-compat/src/jinja2/nativetypes.py
new file mode 100644 (file)
index 0000000..60e5705
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("nativetypes", globals())
diff --git a/jinja2-compat/src/jinja2/nodes.py b/jinja2-compat/src/jinja2/nodes.py
new file mode 100644 (file)
index 0000000..6bfe778
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("nodes", globals())
diff --git a/jinja2-compat/src/jinja2/optimizer.py b/jinja2-compat/src/jinja2/optimizer.py
new file mode 100644 (file)
index 0000000..7ca0929
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("optimizer", globals())
diff --git a/jinja2-compat/src/jinja2/parser.py b/jinja2-compat/src/jinja2/parser.py
new file mode 100644 (file)
index 0000000..8b4cdfe
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("parser", globals())
diff --git a/jinja2-compat/src/jinja2/runtime.py b/jinja2-compat/src/jinja2/runtime.py
new file mode 100644 (file)
index 0000000..d218cc7
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("runtime", globals())
diff --git a/jinja2-compat/src/jinja2/sandbox.py b/jinja2-compat/src/jinja2/sandbox.py
new file mode 100644 (file)
index 0000000..64d6dd9
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("sandbox", globals())
diff --git a/jinja2-compat/src/jinja2/tests.py b/jinja2-compat/src/jinja2/tests.py
new file mode 100644 (file)
index 0000000..2892b2b
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("tests", globals())
diff --git a/jinja2-compat/src/jinja2/utils.py b/jinja2-compat/src/jinja2/utils.py
new file mode 100644 (file)
index 0000000..b870766
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("utils", globals())
diff --git a/jinja2-compat/src/jinja2/visitor.py b/jinja2-compat/src/jinja2/visitor.py
new file mode 100644 (file)
index 0000000..c236087
--- /dev/null
@@ -0,0 +1,3 @@
+from . import _export_jinja
+
+_export_jinja("visitor", globals())
index 80e99620233175e4f1c774834235e158ad7ccf7f..4befd02354b8d3e52747a5a5cfa11a98d770bfdd 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -20,8 +20,6 @@ setup(
         "Issue tracker": "https://github.com/pallets/jinja/issues",
     },
     license="BSD-3-Clause",
-    author="Armin Ronacher",
-    author_email="armin.ronacher@active-4.com",
     maintainer="Pallets",
     maintainer_email="contact@palletsprojects.com",
     description="A very fast and expressive template engine.",
@@ -39,6 +37,7 @@ setup(
         "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: Implementation :: CPython",
         "Programming Language :: Python :: Implementation :: PyPy",
         "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
index 9c4c9cfc5ecd001478c9895f705a91b7a1d2b0d4..d758a5b0b803486287c9b17b7ea9927579129170 100644 (file)
@@ -40,4 +40,4 @@ from .utils import is_undefined
 from .utils import Markup
 from .utils import select_autoescape
 
-__version__ = "2.11.0.dev0"
+__version__ = "2.11.0rc1"
index 88b4988bc52d3b5714a1fc4fea3966b48f23af54..f52d788fa133f7067d737279f800e140b5a917fe 100644 (file)
@@ -712,7 +712,7 @@ class CodeGenerator(NodeVisitor):
         assert frame is None, "no root frame allowed"
         eval_ctx = EvalContext(self.environment, self.name)
 
-        from .runtime import __all__ as exported
+        from .runtime import exported
 
         self.writeline("from __future__ import %s" % ", ".join(code_features))
         self.writeline("from jinja.runtime import " + ", ".join(exported))
index b5d5f4ef63fc3d83b5ce11840dee2b74343d9ca4..8e0e7d771076a8fe0dc71584018338d2caa35fb5 100644 (file)
@@ -42,6 +42,3 @@ DEFAULT_POLICIES = {
     "json.dumps_kwargs": {"sort_keys": True},
     "ext.i18n.trimmed": False,
 }
-
-# export all constants
-__all__ = tuple(x for x in locals().keys() if x.isupper())
index f6d58a61ab0880a5ec80084e7c3e416b91026070..d178e41e0de7e290fcafdd32b53ed256ad7eca47 100644 (file)
@@ -4,7 +4,7 @@ import sys
 from itertools import chain
 from types import MethodType
 
-from markupsafe import escape
+from markupsafe import escape  # noqa: F401
 from markupsafe import Markup
 from markupsafe import soft_unicode
 
@@ -17,19 +17,19 @@ from ._compat import PY2
 from ._compat import string_types
 from ._compat import text_type
 from ._compat import with_metaclass
-from .exceptions import TemplateNotFound
-from .exceptions import TemplateRuntimeError
+from .exceptions import TemplateNotFound  # noqa: F401
+from .exceptions import TemplateRuntimeError  # noqa: F401
 from .exceptions import UndefinedError
 from .nodes import EvalContext
 from .utils import concat
 from .utils import evalcontextfunction
 from .utils import internalcode
 from .utils import missing
-from .utils import Namespace
+from .utils import Namespace  # noqa: F401
 from .utils import object_type_repr
 
 # these variables are exported to the template runtime
-__all__ = [
+exported = [
     "LoopContext",
     "TemplateReference",
     "Macro",
index 6a6173a0bd7d03890a8154f6933432bd54f4076f..51c2dcb5253b53b93d07402067e16c3f921b857c 100644 (file)
@@ -9,9 +9,9 @@ from jinja.exceptions import TemplateNotFound
 
 
 @pytest.fixture
-def env(package_loader):
-    bytecode_cache = FileSystemBytecodeCache()
-    return Environment(loader=package_loader, bytecode_cache=bytecode_cache,)
+def env(package_loader, tmp_path):
+    bytecode_cache = FileSystemBytecodeCache(str(tmp_path))
+    return Environment(loader=package_loader, bytecode_cache=bytecode_cache)
 
 
 @pytest.mark.byte_code_cache