From 7227068e7214992dc1f47e5443732d21972672ec Mon Sep 17 00:00:00 2001 From: Hesam Norin Date: Sun, 1 Feb 2026 14:43:10 +0330 Subject: [PATCH] fix: resolve Python 3.12 build failures in docs and lint environments --- MANIFEST.in | 1 + docs/conf.py | 16 ++++++++++++---- tox.ini | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 898a12e..c401e7a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/docs/conf.py b/docs/conf.py index fad7888..92b574b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 = [] diff --git a/tox.ini b/tox.ini index b9ad4be..ecf33e1 100644 --- a/tox.ini +++ b/tox.ini @@ -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