fix: resolve Python 3.12 build failures in docs and lint environments

This commit is contained in:
Hesam Norin 2026-02-01 14:43:10 +03:30
parent 967c08f348
commit 7227068e72
3 changed files with 16 additions and 4 deletions

View file

@ -7,6 +7,7 @@ include CODE_OF_CONDUCT.md
include requirements.txt
include tox.ini
include .pre-commit-config.yaml
include .readthedocs.yaml
recursive-include docs *
recursive-include exampleapp *
recursive-include defender/templates *.html

View file

@ -13,7 +13,11 @@
# import os
# import sys
# sys.path.insert(0, os.path.abspath("."))
from pkg_resources import get_distribution
try:
from importlib import metadata
except ImportError:
# Running on pre-3.8 Python; use importlib-metadata package
import importlib_metadata as metadata
# -- Project information -----------------------------------------------------
@ -22,7 +26,11 @@ copyright = "2024, Ken Cochrane"
author = "Ken Cochrane"
# The full version, including alpha/beta/rc tags.
release = get_distribution("django-defender").version
try:
release = metadata.version("django-defender")
except metadata.PackageNotFoundError:
# package is not installed
release = "0.0.0"
# The short X.Y version.
version = ".".join(release.split(".")[:2])
@ -38,7 +46,7 @@ master_doc = "index"
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
templates_path = []
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@ -56,4 +64,4 @@ html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = []

View file

@ -41,6 +41,7 @@ deps =
-rrequirements.txt
Sphinx
sphinx_rtd_theme
setuptools
commands = sphinx-build -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html
[testenv:py312-lint]
@ -48,6 +49,8 @@ basepython = python3.12
deps =
twine
check-manifest
setuptools
setuptools_scm
commands =
check-manifest -v
python setup.py sdist