PK/YvW##+_ sphinx_jinja2_compat/__init__.py#!/usr/bin/env python3 # # __init__.py """ Patches Jinja2 v3 to restore compatibility with earlier Sphinx versions. """ # # Copyright © 2022 Dominic Davis-Foster # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. # # stdlib import os import sys from typing import List # this package from sphinx_jinja2_compat._installers import install_jinja2, install_markupsafe __all__: List[str] = [] __author__: str = "Dominic Davis-Foster" __copyright__: str = "2022 Dominic Davis-Foster" __license__: str = "MIT License" __version__: str = "0.2.0.post1" __email__: str = "dominic@davis-foster.co.uk" if "NO_SPHINX_JINJA2_COMPAT" not in os.environ: if sys.version_info >= (3, 10): # stdlib import types types.Union = types.UnionType try: # 3rd party import markupsafe install_markupsafe(markupsafe) # 3rd party import jinja2 import jinja2.filters import jinja2.utils install_jinja2(jinja2, jinja2.filters, jinja2.utils) except ImportError: # Unable to import one module # Perhaps they are in global site-packages and we're not, # so they aren't available yet? # this package from sphinx_jinja2_compat._meta_path import _Finder sys.meta_path.insert(0, _Finder()) PK/YvWF #sphinx_jinja2_compat/_installers.py#!/usr/bin/env python3 # # _installers.py """ Functions to install the various patches. """ # # Copyright © 2022 Dominic Davis-Foster # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. # # stdlib from types import ModuleType from typing import Any, Callable, TypeVar __all__ = ["install_jinja2", "install_markupsafe"] F = TypeVar('F', bound=Callable[..., Any]) def install_markupsafe(markupsafe: ModuleType) -> None: """ Install the markupsafe patch. :param markupsafe: The ``markupsafe`` module. """ if not hasattr(markupsafe, "soft_unicode"): def soft_unicode(s: Any) -> str: return markupsafe.soft_str(s) markupsafe.soft_unicode = soft_unicode # type: ignore[attr-defined] def install_jinja2(jinja2: ModuleType, filters: ModuleType, utils: ModuleType) -> None: """ Install the jinja2 patch. :param jinja2: The ``jinja2`` module. :param filters: The ``jinja2.filters`` module. :param utils: The ``jinja2.utils`` module. """ if not hasattr(filters, "environmentfilter"): def environmentfilter(f: F) -> F: return utils.pass_environment(f) filters.environmentfilter = environmentfilter # type: ignore[attr-defined] jinja2.environmentfilter = environmentfilter # type: ignore[attr-defined] if not hasattr(utils, "contextfunction"): def contextfunction(f: F) -> F: return utils.pass_context(f) utils.contextfunction = contextfunction # type: ignore[attr-defined] jinja2.contextfunction = contextfunction # type: ignore[attr-defined] PK/YvWif f "sphinx_jinja2_compat/_meta_path.py#!/usr/bin/env python3 # # _meta_path.py """ Meta path finder and loader to install patched at import time. """ # # Copyright © 2022 Dominic Davis-Foster # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE # OR OTHER DEALINGS IN THE SOFTWARE. # # stdlib import importlib.abc import importlib.util import sys # this package from sphinx_jinja2_compat._installers import install_jinja2, install_markupsafe class _Finder(importlib.abc.MetaPathFinder): def __init__(self): # Stack stops us going round in circles self._stack = [] def find_spec(self, fullname, path, target=None): if fullname in self._stack: return None if fullname == "markupsafe": if self in sys.meta_path: self._stack.append("markupsafe") markupsafe = importlib.import_module("markupsafe") self._stack.pop() # This is necessary to ensure the patched version gets loaded del sys.modules["markupsafe"] class _MarkupsafeLoader(importlib.abc.Loader): def create_module(self, spec): install_markupsafe(markupsafe) return markupsafe def exec_module(self, module): pass return importlib.util.spec_from_loader( "markupsafe", _MarkupsafeLoader(), origin=markupsafe.__file__, ) elif fullname == "jinja2": if self in sys.meta_path: self._stack.append("jinja2") jinja2 = importlib.import_module("jinja2") filters = importlib.import_module("jinja2.filters") utils = importlib.import_module("jinja2.utils") self._stack.pop() # This is necessary to ensure the patched version gets loaded del sys.modules["jinja2"] class _Jinja2Loader(importlib.abc.Loader): def create_module(self, spec): install_jinja2(jinja2, filters, utils) return jinja2 def exec_module(self, module): pass return importlib.util.spec_from_loader("jinja2", _Jinja2Loader(), origin=jinja2.__file__) PK=YvWF[((2sphinx_jinja2_compat-0.2.0.post1.dist-info/LICENSECopyright (c) 2022 Dominic Davis-Foster Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK=YvWz0dcc3sphinx_jinja2_compat-0.2.0.post1.dist-info/METADATAMetadata-Version: 2.1 Name: sphinx-jinja2-compat Version: 0.2.0.post1 Summary: Patches Jinja2 v3 to restore compatibility with earlier Sphinx versions. Author-email: Dominic Davis-Foster License: MIT Keywords: documentation,jinja2,sphinx Home-page: https://github.com/sphinx-toolbox/sphinx-jinja2-compat Project-URL: Issue Tracker, https://github.com/sphinx-toolbox/sphinx-jinja2-compat/issues Project-URL: Source Code, https://github.com/sphinx-toolbox/sphinx-jinja2-compat Platform: Windows Platform: macOS Platform: Linux Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Documentation Classifier: Topic :: Documentation :: Sphinx Classifier: Topic :: Software Development :: Documentation Requires-Python: >=3.6 Requires-Dist: jinja2>=2.10 Requires-Dist: markupsafe>=1 Description-Content-Type: text/x-rst ===================== sphinx-jinja2-compat ===================== .. start short_desc **Patches Jinja2 v3 to restore compatibility with earlier Sphinx versions.** .. end short_desc Also makes some Sphinx versions work correctly on Python 3.10. The patches can be disabled by setting the environment variable ``NO_SPHINX_JINJA2_COMPAT`` to ``1``. (v0.2.0 and newer only) .. start shields .. list-table:: :stub-columns: 1 :widths: 10 90 * - Tests - |actions_linux| |actions_windows| |actions_macos| * - PyPI - |pypi-version| |supported-versions| |supported-implementations| |wheel| * - Anaconda - |conda-version| |conda-platform| * - Activity - |commits-latest| |commits-since| |maintained| |pypi-downloads| * - QA - |codefactor| |actions_flake8| |actions_mypy| * - Other - |license| |language| |requires| .. |actions_linux| image:: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/workflows/Linux/badge.svg :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/actions?query=workflow%3A%22Linux%22 :alt: Linux Test Status .. |actions_windows| image:: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/workflows/Windows/badge.svg :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/actions?query=workflow%3A%22Windows%22 :alt: Windows Test Status .. |actions_macos| image:: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/workflows/macOS/badge.svg :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/actions?query=workflow%3A%22macOS%22 :alt: macOS Test Status .. |actions_flake8| image:: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/workflows/Flake8/badge.svg :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/actions?query=workflow%3A%22Flake8%22 :alt: Flake8 Status .. |actions_mypy| image:: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/workflows/mypy/badge.svg :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/actions?query=workflow%3A%22mypy%22 :alt: mypy status .. |requires| image:: https://dependency-dash.repo-helper.uk/github/sphinx-toolbox/sphinx-jinja2-compat/badge.svg :target: https://dependency-dash.repo-helper.uk/github/sphinx-toolbox/sphinx-jinja2-compat/ :alt: Requirements Status .. |codefactor| image:: https://img.shields.io/codefactor/grade/github/sphinx-toolbox/sphinx-jinja2-compat?logo=codefactor :target: https://www.codefactor.io/repository/github/sphinx-toolbox/sphinx-jinja2-compat :alt: CodeFactor Grade .. |pypi-version| image:: https://img.shields.io/pypi/v/sphinx-jinja2-compat :target: https://pypi.org/project/sphinx-jinja2-compat/ :alt: PyPI - Package Version .. |supported-versions| image:: https://img.shields.io/pypi/pyversions/sphinx-jinja2-compat?logo=python&logoColor=white :target: https://pypi.org/project/sphinx-jinja2-compat/ :alt: PyPI - Supported Python Versions .. |supported-implementations| image:: https://img.shields.io/pypi/implementation/sphinx-jinja2-compat :target: https://pypi.org/project/sphinx-jinja2-compat/ :alt: PyPI - Supported Implementations .. |wheel| image:: https://img.shields.io/pypi/wheel/sphinx-jinja2-compat :target: https://pypi.org/project/sphinx-jinja2-compat/ :alt: PyPI - Wheel .. |conda-version| image:: https://img.shields.io/conda/v/domdfcoding/sphinx-jinja2-compat?logo=anaconda :target: https://anaconda.org/domdfcoding/sphinx-jinja2-compat :alt: Conda - Package Version .. |conda-platform| image:: https://img.shields.io/conda/pn/domdfcoding/sphinx-jinja2-compat?label=conda%7Cplatform :target: https://anaconda.org/domdfcoding/sphinx-jinja2-compat :alt: Conda - Platform .. |license| image:: https://img.shields.io/github/license/sphinx-toolbox/sphinx-jinja2-compat :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/blob/master/LICENSE :alt: License .. |language| image:: https://img.shields.io/github/languages/top/sphinx-toolbox/sphinx-jinja2-compat :alt: GitHub top language .. |commits-since| image:: https://img.shields.io/github/commits-since/sphinx-toolbox/sphinx-jinja2-compat/v0.2.0.post1 :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/pulse :alt: GitHub commits since tagged version .. |commits-latest| image:: https://img.shields.io/github/last-commit/sphinx-toolbox/sphinx-jinja2-compat :target: https://github.com/sphinx-toolbox/sphinx-jinja2-compat/commit/master :alt: GitHub last commit .. |maintained| image:: https://img.shields.io/maintenance/yes/2023 :alt: Maintenance .. |pypi-downloads| image:: https://img.shields.io/pypi/dm/sphinx-jinja2-compat :target: https://pypi.org/project/sphinx-jinja2-compat/ :alt: PyPI - Downloads .. end shields Installation -------------- .. start installation ``sphinx-jinja2-compat`` can be installed from PyPI or Anaconda. To install with ``pip``: .. code-block:: bash $ python -m pip install sphinx-jinja2-compat To install with ``conda``: * First add the required channels .. code-block:: bash $ conda config --add channels https://conda.anaconda.org/conda-forge $ conda config --add channels https://conda.anaconda.org/domdfcoding * Then install .. code-block:: bash $ conda install sphinx-jinja2-compat .. end installation PK=YvW7qTT0sphinx_jinja2_compat-0.2.0.post1.dist-info/WHEELWheel-Version: 1.0 Generator: whey (0.0.24) Root-Is-Purelib: true Tag: py3-none-any PK=YvW;sphinx_jinja2_compat-0.2.0.post1.dist-info/entry_points.txtPK=YvW2_sphinx_jinja2_compat.pthimport sphinx_jinja2_compat PK=YvW CC1sphinx_jinja2_compat-0.2.0.post1.dist-info/RECORDsphinx_jinja2_compat/__init__.py,sha256=y8PLeJl-A9pW7kDGawpQf5G4oMuYE2XgOGW4t4zm1Iw,2254 sphinx_jinja2_compat/_installers.py,sha256=6PtWdYxE2lVUfHvOfXCBrvxTvHSiPJnezKx6zqDXLlw,2544 sphinx_jinja2_compat/_meta_path.py,sha256=IRBb12JN8qPvEw8oFbEyVX9iIyKYxnRk271TtOK9NEE,2918 sphinx_jinja2_compat-0.2.0.post1.dist-info/LICENSE,sha256=vcYl7QVHqsKsQ0daepvB-wZkus6akEGBbqUynXKQ9r8,1064 sphinx_jinja2_compat-0.2.0.post1.dist-info/METADATA,sha256=3FJqAsnkgQTnKcin3WEgHDBbZMOrCdybNNyroTBpNPU,6755 sphinx_jinja2_compat-0.2.0.post1.dist-info/WHEEL,sha256=3vSnEhs48RUlSXcCXKCl4DOHs_qqaP2dU3IGkMqN2oI,84 sphinx_jinja2_compat-0.2.0.post1.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 _sphinx_jinja2_compat.pth,sha256=m-JFoQVBTohfRiVZY6q7o5D3mL4OpFktyhPJ-Z-G7G8,28 sphinx_jinja2_compat-0.2.0.post1.dist-info/RECORD,, PK/YvW##+_ sphinx_jinja2_compat/__init__.pyPK/YvWF # sphinx_jinja2_compat/_installers.pyPK/YvWif f "=sphinx_jinja2_compat/_meta_path.pyPK=YvWF[((2sphinx_jinja2_compat-0.2.0.post1.dist-info/LICENSEPK=YvWz0dcc3[#sphinx_jinja2_compat-0.2.0.post1.dist-info/METADATAPK=YvW7qTT0>sphinx_jinja2_compat-0.2.0.post1.dist-info/WHEELPK=YvW;>sphinx_jinja2_compat-0.2.0.post1.dist-info/entry_points.txtPK=YvW2 ?_sphinx_jinja2_compat.pthPK=YvW CC1]?sphinx_jinja2_compat-0.2.0.post1.dist-info/RECORDPK B