From: Michael Fladischer <fladi@debian.org>
Date: Thu, 8 Oct 2015 08:49:54 -0700
Subject: use local objects.inv where possible

 Upstream uses intersphinx mappings that fetch the objects.inv for python and
 python-django by HTTP from a remote host. Using the local objects.inv from
 python and kombu enables the package to build without network connection.
Last-Update: 2013-11-26
Forwarded: not-needed

Patch-Name: docs-use_local_intersphinx_mapping.patch
---
 docs/conf.py | 49 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 598ef40..af1ce1e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -13,6 +13,8 @@
 import contextlib
 import os
 import sys
+import django
+import tox
 
 from pkg_resources import DistributionNotFound, get_distribution
 
@@ -61,6 +63,7 @@ version = ".".join(release.split(".")[:2])
 # ones.
 extensions = ["sphinx.ext.intersphinx", "daldocs"]
 
+
 # Add any paths that contain templates here, relative to this directory.
 # templates_path = ['_templates']
 
@@ -189,12 +192,40 @@ texinfo_documents = [
 
 # -- Options for intersphinx extension ---------------------------------------
 
-intersphinx_mapping = {
-    "python": ("https://docs.python.org/3/", None),
-    "django": (
-        "https://docs.djangoproject.com/en/stable/",
-        "https://docs.djangoproject.com/en/stable/_objects/",
-    ),
-    "pythonldap": ("https://www.python-ldap.org/en/latest/", None),
-    "tox": ("https://tox.wiki/en/latest/", None),
-}
+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',
+        'http://docs.python.org/',
+        '/usr/share/doc/python{v}/html/objects.inv'.format(v=map(str, sys.version_info[: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'
+    )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        'pythonldap',
+        'http://python-ldap.org/doc/html/',
+        ''
+    )
+)
+intersphinx_mapping.update(
+    check_object_path(
+        'tox',
+        'https://tox.wiki/en/{v}/'.format(v=tox.__version__),
+        '/usr/share/doc/tox/html/objects.inv'
+    )
+)
+
+
