Skip to content

Commit fcb455c

Browse files
bsipoczdprada
andauthored
MAINT: dropping sphinx<7 and python<3.10 versions (#218)
* MAINT: dropping sphinx<7 and python<3.10 versions * Updating tox file * Modernize packaging and improve Sphinx 9 compatibility * Update deprecated BS4 usage * MAINT: remove more old version workarounds * MAINT: ensure we fail on warnings, adding exceptions for 3rd party * Adding pending deprecation to ignore list * Fix linter --------- Co-authored-by: Diego Prada <prada.gracia@gmail.com>
1 parent bb0be82 commit fcb455c

7 files changed

Lines changed: 44 additions & 28 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
strategy:
2222
matrix:
23-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
23+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2424

2525
steps:
2626
- uses: actions/checkout@v6

setup.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tool:pytest]
2+
xfail_strict = true
3+
addopts = --color=yes --doctest-continue-on-failure
4+
filterwarnings =
5+
error
6+
# Deprecation triggered in rinoh
7+
ignore:nodes.Node.traverse:DeprecationWarning
8+
# Same as above, but for python3.10 it is a pending deprecation
9+
ignore:nodes.Node.traverse:PendingDeprecationWarning
10+
# More rinoh warning
11+
ignore:TeX Gyre Pagella does not include:rinoh.warnings.RinohWarning

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def get_version():
2424
include_package_data=True,
2525
url="https://github.com/executablebooks/sphinx-tabs",
2626
license="MIT",
27-
python_requires=">=3.7",
28-
install_requires=["sphinx>=1.8", "pygments", "docutils"],
27+
python_requires=">=3.10",
28+
install_requires=["sphinx>=7", "pygments", "docutils"],
2929
extras_require={
3030
"testing": [
3131
"coverage",
32-
"pytest>=7.1,<8",
32+
"pytest>=7.1",
3333
"pytest-cov",
3434
"pytest-regressions",
3535
"pygments",
@@ -47,10 +47,11 @@ def get_version():
4747
"License :: OSI Approved :: MIT License",
4848
"Natural Language :: English",
4949
"Operating System :: OS Independent",
50-
"Programming Language :: Python :: 3.7",
51-
"Programming Language :: Python :: 3.8",
52-
"Programming Language :: Python :: 3.9",
5350
"Programming Language :: Python :: 3.10",
51+
"Programming Language :: Python :: 3.11",
52+
"Programming Language :: Python :: 3.12",
53+
"Programming Language :: Python :: 3.13",
54+
"Programming Language :: Python :: 3.14",
5455
"Programming Language :: Python",
5556
"Topic :: Documentation :: Sphinx",
5657
"Topic :: Documentation",

sphinx_tabs/tabs.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import base64
44
from pathlib import Path
55
from functools import partial
6-
import sphinx
7-
86

97
from docutils import nodes
108
from docutils.parsers.rst import directives
@@ -27,6 +25,11 @@
2725
LEXER_MAP[short_name] = lexer[0]
2826

2927

28+
def _get_env_app(env):
29+
"""Return Sphinx app without triggering deprecated BuildEnvironment.app."""
30+
return getattr(env, "_app", None) or env.app
31+
32+
3033
def get_compatible_builders(app):
3134
builders = [
3235
"html",
@@ -103,7 +106,8 @@ def run(self):
103106

104107
self.state.nested_parse(self.content, self.content_offset, node)
105108

106-
if self.env.app.builder.name in get_compatible_builders(self.env.app):
109+
app = _get_env_app(self.env)
110+
if app.builder.name in get_compatible_builders(app):
107111
tablist = SphinxTabsTablist()
108112
tablist["role"] = "tablist"
109113
tablist["aria-label"] = "Tabbed content"
@@ -187,7 +191,8 @@ def run(self):
187191

188192
self.state.nested_parse(self.content[1:], self.content_offset, panel)
189193

190-
if self.env.app.builder.name not in get_compatible_builders(self.env.app):
194+
app = _get_env_app(self.env)
195+
if app.builder.name not in get_compatible_builders(app):
191196
# Use base docutils classes
192197
outer_node = nodes.container()
193198
tab = nodes.container()
@@ -304,9 +309,7 @@ def update_context(app, pagename, templatename, context, doctree):
304309
visitor = _FindTabsDirectiveVisitor(doctree)
305310
doctree.walk(visitor)
306311

307-
include_assets_in_all_pages = False
308-
if sphinx.version_info >= (4, 1, 0):
309-
include_assets_in_all_pages = app.registry.html_assets_policy == "always"
312+
include_assets_in_all_pages = app.registry.html_assets_policy == "always"
310313

311314
if visitor.found_tabs_directive or include_assets_in_all_pages:
312315
if not app.config.sphinx_tabs_disable_css_loading:

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import pytest
32
from pathlib import Path
43
from bs4 import BeautifulSoup
@@ -96,7 +95,7 @@ def read(app, buildername="html", filename="index.html", encoding="utf-8"):
9695
body = soup.select("div.body")[0]
9796
body.append(soup.new_tag("div", **{"class": "clearer"}))
9897

99-
doc_div = soup.findAll("div", {"class": "documentwrapper"})[0]
98+
doc_div = soup.find_all("div", {"class": "documentwrapper"})[0]
10099
doc = doc_div.prettify()
101100

102101
else:
@@ -190,7 +189,7 @@ def get_sphinx_app_output():
190189
def get(app, buildername="html", filename="index.html", encoding="utf-8"):
191190
outpath = Path(app.srcdir) / "_build" / buildername / filename
192191
if not outpath.exists():
193-
raise IOError("No output file exists: {}".format(outpath.as_posix()))
192+
raise OSError(f"No output file exists: {outpath.as_posix()}")
194193

195194
return outpath.read_text(encoding=encoding)
196195

tests/test_build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import sys
21
import pytest
3-
import sphinx
4-
from sphinx.application import Sphinx
2+
from rinoh.resource import ResourceNotFound
53

64

75
@pytest.mark.sphinx(testroot="basic")
@@ -68,13 +66,15 @@ def test_custom_lexer(app, check_asset_links):
6866

6967
@pytest.mark.noautobuild
7068
@pytest.mark.sphinx("rinoh", testroot="rinohtype-pdf")
71-
@pytest.mark.skipif(
72-
sys.version_info < (3, 8), reason="Unknown dependency conflict in lower versions"
73-
)
7469
def test_rinohtype_pdf(
7570
app, status, warning, check_build_success, get_sphinx_app_doctree
7671
):
77-
app.build()
72+
try:
73+
app.build()
74+
except ResourceNotFound as err:
75+
if "Tex Gyre Heros" in str(err):
76+
pytest.skip("Tex Gyre Heros typeface is not available in this environment")
77+
raise
7878
check_build_success(status, warning)
7979
get_sphinx_app_doctree(app, regress=True)
8080
# Doesn't currently regression test pdf output

tox.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
# then run `tox` or `tox -- {pytest args}`
55
# run in parallel using `tox -p`
66
[tox]
7-
envlist = py{311,312,313,314}-sphinx{7,8,9},docs
7+
envlist = py{310,311,312,313,314}-sphinx{7,8,9},docs
88

9-
[testenv:py{311,312,313,314}-sphinx{7,8,9}]
9+
[testenv:py{310,311,312,313,314}-sphinx{7,8,9}]
1010
extras = testing
1111
deps =
1212
sphinx7: sphinx>=7,<8
1313
sphinx8: sphinx>=8,<9
1414
sphinx9: sphinx>=9,<10
1515
recreate = false
16-
commands = pytest {posargs}
16+
commands =
17+
pip freeze
18+
pytest {posargs}
1719

1820
[testenv:docs]
19-
whitelist_externals = rm
21+
allowlist_externals = rm
2022
recreate = false
2123
commands =
2224
rm -rf docs/_build

0 commit comments

Comments
 (0)