diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7b95937 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=64", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/sphinx_tabs/tabs.py b/sphinx_tabs/tabs.py index bad665e..5df962f 100644 --- a/sphinx_tabs/tabs.py +++ b/sphinx_tabs/tabs.py @@ -27,6 +27,11 @@ LEXER_MAP[short_name] = lexer[0] +def _get_env_app(env): + """Return Sphinx app without triggering deprecated BuildEnvironment.app.""" + return getattr(env, "_app", None) or env.app + + def get_compatible_builders(app): builders = [ "html", @@ -103,7 +108,8 @@ def run(self): self.state.nested_parse(self.content, self.content_offset, node) - if self.env.app.builder.name in get_compatible_builders(self.env.app): + app = _get_env_app(self.env) + if app.builder.name in get_compatible_builders(app): tablist = SphinxTabsTablist() tablist["role"] = "tablist" tablist["aria-label"] = "Tabbed content" @@ -187,7 +193,8 @@ def run(self): self.state.nested_parse(self.content[1:], self.content_offset, panel) - if self.env.app.builder.name not in get_compatible_builders(self.env.app): + app = _get_env_app(self.env) + if app.builder.name not in get_compatible_builders(app): # Use base docutils classes outer_node = nodes.container() tab = nodes.container() diff --git a/tests/test_build.py b/tests/test_build.py index 4a21690..94be76a 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -2,6 +2,7 @@ import pytest import sphinx from sphinx.application import Sphinx +from rinoh.resource import ResourceNotFound @pytest.mark.sphinx(testroot="basic") @@ -74,7 +75,12 @@ def test_custom_lexer(app, check_asset_links): def test_rinohtype_pdf( app, status, warning, check_build_success, get_sphinx_app_doctree ): - app.build() + try: + app.build() + except ResourceNotFound as err: + if "Tex Gyre Heros" in str(err): + pytest.skip("Tex Gyre Heros typeface is not available in this environment") + raise check_build_success(status, warning) get_sphinx_app_doctree(app, regress=True) # Doesn't currently regression test pdf output