Skip to content

Commit

Permalink
Run Sphinx tests with current Python version if possible
Browse files Browse the repository at this point in the history
Only use Python 3.9 if the Sphinx version requires it.

This requires setting the Python version requirement for Sphinx in
our pyproject.toml (see #359).
  • Loading branch information
brechtm committed Aug 25, 2023
1 parent 3c96a61 commit 4079766
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
32 changes: 24 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ def parametrize_dist():
return nox.parametrize('dist', ['sdist', 'wheel'], ids=['sdist', 'wheel'])


def parametrize(dependency, granularity='minor'):
return nox.parametrize(dependency, get_versions(dependency, granularity))
def parametrize(dependency, granularity='minor', python=CURRENT_PYTHON):
versions = get_versions(dependency, granularity, python)
if python != CURRENT_PYTHON:
for version in get_versions(dependency, granularity, CURRENT_PYTHON):
versions.remove(version)
return nox.parametrize(dependency, versions)


# sessions

@nox_poetry.session()
@nox_poetry.session
def check(session):
session.run('poetry', 'check', external=True)


@nox_poetry.session()
@nox_poetry.session
def check_docs(session):
_install(session, dependencies=['doc8', 'sphinx-immaterial',
'sphinxcontrib-autoprogram'])
Expand All @@ -50,7 +54,7 @@ def check_docs(session):
session.run('python', 'doc/build.py', 'doctest')


@nox_poetry.session()
@nox_poetry.session
def build_docs(session):
_install(session, dependencies=['Sphinx', 'sphinx-immaterial',
'sphinxcontrib-autoprogram'])
Expand All @@ -70,30 +74,42 @@ def unit(session, dist):
_unit(session, dist=dist)


@nox_poetry.session(python='3.9') # Sphinx >3.5 fail on 3.10
@nox_poetry.session
@parametrize('sphinx')
def unit_sphinx(session, sphinx):
_unit(session, sphinx=sphinx, ignore_deprecation_warnings=True)


@nox_poetry.session(python='3.9')
@parametrize('sphinx', python='3.9')
def unit_sphinx_py39(session, sphinx):
_unit(session, sphinx=sphinx, ignore_deprecation_warnings=True)


@nox_poetry.session(python=PYTHONS)
@parametrize_dist()
def regression(session, dist):
_regression(session, dist=dist)


@nox_poetry.session()
@nox_poetry.session
@parametrize('docutils')
def regression_docutils(session, docutils):
_regression(session, docutils=docutils, ignore_deprecation_warnings=True)


@nox_poetry.session(python='3.9') # Sphinx >3.5 fail on 3.10
@nox_poetry.session
@parametrize('sphinx')
def regression_sphinx(session, sphinx):
_regression(session, sphinx=sphinx, ignore_deprecation_warnings=True)


@nox_poetry.session(python='3.9')
@parametrize('sphinx', python='3.9')
def regression_sphinx_py39(session, sphinx):
_regression(session, sphinx=sphinx, ignore_deprecation_warnings=True)


# utility functions

def _install(session, docutils=None, sphinx=None, dist='wheel',
Expand Down
5 changes: 2 additions & 3 deletions noxutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ def allowed(version):
python_version = parse_single_constraint(python)
for requirement in requirements:
python_versions = parse_single_constraint(requirement.python_versions)
if python_versions.allows(python_version) and requirement.constraint.allows(
version
):
if (python_versions.allows(python_version)
and requirement.constraint.allows(version)):
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ rinoh-typeface-dejavuserif = "^0.1.3"
rinoh-typeface-texgyrecursor = "^0.1.1"
rinoh-typeface-texgyreheros = "^0.1.1"
rinoh-typeface-texgyrepagella = "^0.1.1"
Sphinx = { version = ">=2.2.1", optional = true }
Sphinx = [
{version = ">=2.2.1", python = "<3.10", optional = true},
{version = ">=2.2.1,!=3.5.*,!=4.0.*,!=4.1.*", python = ">=3.10", optional = true}
]

[tool.poetry.group.dev.dependencies]
doc8 = "^1.0.0"
Expand Down

0 comments on commit 4079766

Please sign in to comment.