Skip to content

Commit

Permalink
Rework CI/RTD dependencies.
Browse files Browse the repository at this point in the history
As noted in comments, doing these as etxras or as PDM dev dependencies
doens't really work because they're not used like extras, and PDM
would constrain them to Python-3.9-compatible versions, which creates
differences with RTD (which runs a much newer Python and will pick up,
for example, Sphinx 8.x instead of 7.x as a result).
  • Loading branch information
ubernostrum committed Nov 6, 2024
1 parent dc00718 commit ae9b366
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 1,076 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
- run: tar xf dist/*.tar.gz --strip-components=1
- uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version: "3.12"
- name: Set up test runner
run: |
python -VV
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -16,10 +16,10 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.8
language_version: python3.13
name: black (Python formatter)
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
Expand Down
5 changes: 3 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .[docs]
path: .
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"sphinx_inline_tabs",
]
templates_path = ["_templates"]
source_suffix = ".rst"
source_suffix = {".rst": "restructuredtext"}
master_doc = "index"
project = "django-registration"
copyright = "James Bennett and contributors"
Expand Down
13 changes: 13 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These dependencies are not "extras" defined in the pyproject.toml,
# because they're not something you actually want to install alongside
# the main package. They're also not "dev dependencies" in the PDM
# sense of the term, because PDM would constrain them to the oldest
# Python version the main package supports (3.9), while all our
# documentation jobs, whether run via nox or via readthedocs, run on
# Python 3.12.
furo
sphinx
sphinx-copybutton
sphinx-inline-tabs
sphinx-notfound-page
sphinxext-opengraph
21 changes: 15 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ def tests_with_coverage(session: nox.Session, django: str) -> None:
Run the package's unit tests, with coverage report.
"""
session.install(f"Django~={django}.0", ".[tests]")
session.install(
f"Django~={django}.0",
".[tests]",
"coverage",
'tomli; python_full_version < "3.11.0a7"',
)
python_version = session.run(
f"{session.bin}/python{session.python}", "--version", silent=True
).strip()
Expand Down Expand Up @@ -127,13 +132,17 @@ def coverage_report(session: nox.Session) -> None:
# -----------------------------------------------------------------------------------


@nox.session(python=["3.13"], tags=["docs"])
# The documentation jobs ordinarily would want to use the latest Python version, but
# currently that's 3.13 and Read The Docs doesn't yet support it. So to ensure the
# documentation jobs are as closely matched to what would happen on RTD, these jobs stay
# on 3.12 for now.
@nox.session(python=["3.12"], tags=["docs"])
def docs_build(session: nox.Session) -> None:
"""
Build the package's documentation as HTML.
"""
session.install(".[docs]")
session.install(".", "-r", "docs/requirements.txt")
build_dir = session.create_tmp()
session.run(
f"{session.bin}/python{session.python}",
Expand All @@ -152,7 +161,7 @@ def docs_build(session: nox.Session) -> None:
clean()


@nox.session(python=["3.13"], tags=["docs"])
@nox.session(python=["3.12"], tags=["docs"])
def docs_docstrings(session: nox.Session) -> None:
"""
Enforce the presence of docstrings on all modules, classes, functions, and
Expand All @@ -175,13 +184,13 @@ def docs_docstrings(session: nox.Session) -> None:
clean()


@nox.session(python=["3.13"], tags=["docs"])
@nox.session(python=["3.12"], tags=["docs"])
def docs_spellcheck(session: nox.Session) -> None:
"""
Spell-check the package's documentation.
"""
session.install(".[docs]")
session.install(".", "-r", "docs/requirements.txt")
session.install("pyenchant", "sphinxcontrib-spelling")
build_dir = session.create_tmp()
session.run(
Expand Down
1,050 changes: 11 additions & 1,039 deletions pdm.lock

Large diffs are not rendered by default.

27 changes: 3 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ dependencies = [
"Documentation" = "https://django-registration.readthedocs.io/"
"Source Code" = "https://github.com/ubernostrum/django-registration"


[project.optional-dependencies]
docs = [
"furo",
"sphinx",
"sphinx-copybutton",
"sphinx-inline-tabs",
"sphinx-notfound-page",
"sphinxext-opengraph",
]
linters = [
"bandit[toml]",
"flake8",
"flake8-bugbear",
"pylint",
"pylint-django",
"interrogate",
]
tests = [
"coverage",
"nox",
"tomli; python_full_version < \"3.11.0a7\"",
]

[tool.bandit]
exclude_dirs = ["src/django_registration/_backports.py"]
skips = ["B101"]
Expand Down Expand Up @@ -137,3 +113,6 @@ disable = [
"missing-module-docstring",
"too-many-ancestors",
]

[dependency-groups]
tests = ["nox"]

0 comments on commit ae9b366

Please sign in to comment.