From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Sun, 26 Feb 2017 17:19:06 +0100
Subject: Use local objects.inv file for intersphinx.

This makes sure that no online resources are used during package build.
---
 docs/source/conf.py | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 1010622..955c6ef 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -62,11 +62,28 @@ django.conf.settings.configure(
 )
 django.setup()
 
-intersphinx_mapping = {
-    'python': ('https://docs.python.org/3/', None),
-    'django': ('https://docs.djangoproject.com/en/4.2/',
-               'https://docs.djangoproject.com/en/4.2/_objects/'),
-}
+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://docs.djangoproject.com/en/{v}/'.format(
+        v='.'.join(map(str, django.VERSION[:2]))
+    ),
+    '/usr/share/doc/python-django-doc/html/objects.inv'
+))
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
