File: 0001-Use-local-objects.inv-where-possible.patch

package info (click to toggle)
python-testfixtures 4.14.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 860 kB
  • sloc: python: 6,084; makefile: 73
file content (57 lines) | stat: -rw-r--r-- 1,736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From d51fe5544dab8a41907e32f3f73a4a0dc3951c04 Mon Sep 17 00:00:00 2001
From: Michael Fladischer <FladischerMichael@fladi.at>
Date: Fri, 27 Jan 2017 09:50:38 +0100
Subject: Use local objects.inv where possible

Upstream uses intersphinx mappings that fetch the objects.inv for python by
HTTP from a remote host. Using the local objects.inv from python enables the
package to build without network connection.
---
 docs/conf.py | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/docs/conf.py b/docs/conf.py
index 7a3cef7..7b44b46 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -4,6 +4,7 @@ import os
 import pkginfo
 import sys
 import time
+import django
 
 on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
 pkg_info = pkginfo.Develop(os.path.join(os.path.dirname(__file__), '..'))
@@ -14,10 +15,28 @@ extensions = [
     'sphinx.ext.intersphinx'
     ]
 
-intersphinx_mapping = {
-    'http://docs.python.org': None,
-    'http://django.readthedocs.org/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',
+    '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'
+))
 
 # General
 source_suffix = '.txt'