From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Sun, 12 Sep 2021 21:07:44 +0200
Subject: Use local inventory for intersphinx

The upstream way is to fetch the interspinx inventary by https from
docs.djangoproject.com.
Using instead the packages stuff from python3-django-doc.

This patch is basicaly completely taken from python-testfixtures and was
written by Michael Fladischer <FladischerMichael@fladi.at>.

Forwarded: not-needed
---
 docs/conf.py | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 3f2fafe..8625c90 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -348,22 +348,29 @@ texinfo_documents = [
 # texinfo_no_detailmenu = False
 
 # Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {
-    "python": ('https://docs.python.org/', None),
-    "django": ('https://docs.djangoproject.com/en/3.2/', 'django.inv'),
-}
+
+def check_object_path(key, url, path):
+    if os.path.isfile(path):
+        return {key: (url, path)}
+    return {}
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(check_object_path(
+    'python',
+    'https://docs.python.org/{v}/'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
+    ),
+    '/usr/share/doc/python{v}/html/objects.inv'.format(
+        v='.'.join(map(str, sys.version_info[0:2]))
+    )
+))
+
+intersphinx_mapping.update(check_object_path(
+    'django',
+    'https://django.readthedocs.org/en/latest/',
+    '/usr/share/doc/python-django-doc/html/objects.inv'
+))
 
 autodoc_member_order = 'bysource'
 
 locale_dirs = ['../test_venv/lib/python2.7/site-packages/django/conf/locale/']
-
-
-def _download_django_inv():
-    import requests
-    with open(_download_django_inv.path, 'wb') as f:
-        r = requests.get("https://docs.djangoproject.com/en/3.2/_objects")
-        f.write(r.content)
-_download_django_inv.path = os.path.abspath(os.path.join(os.path.dirname(__file__), "django.inv"))
-
-if not os.path.isfile(_download_django_inv.path):
-    _download_django_inv()
