Browse Source

Workaround for LMDB import.

Stefano Cossu 6 years ago
parent
commit
c41fa19123
3 changed files with 15 additions and 13 deletions
  1. 3 2
      docs/Makefile
  2. 12 11
      docs/conf.py
  3. 0 0
      lsup-admin

+ 3 - 2
docs/Makefile

@@ -4,8 +4,9 @@
 # You can set these variables from the command line.
 SPHINXOPTS    =
 # Workaround to prevent lmdb from throwing an exception when loaded from Sphinx
-SPHINXBUILD   = python -m sphinx
-#SPHINXBUILD   = sphinx-build
+# Does not work with readthedocs unfortunately.
+#SPHINXBUILD   = python -m sphinx
+SPHINXBUILD   = sphinx-build
 SPHINXPROJ    = lakesuperior
 SOURCEDIR     = .
 BUILDDIR      = _build

+ 12 - 11
docs/conf.py

@@ -24,8 +24,20 @@ from unittest.mock import MagicMock
 
 #sys.path.insert(0, os.path.abspath('../'))
 sys.path.append(os.path.abspath('../'))
+
+class MockModule(MagicMock):
+    @classmethod
+    def __getattr__(cls, name):
+        return MagicMock()
+
+# LMDB raises an issue if imported by Sphinx. This bypasses the issue.
+# https://github.com/dw/py-lmdb/issues/172
+MOCK_MODULES = ['lmdb']
+sys.modules.update((mod_name, MockModule()) for mod_name in MOCK_MODULES)
+
 import lakesuperior.env_setup
 
+
 # -- General configuration ------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -174,17 +186,6 @@ texinfo_documents = [
      'Miscellaneous'),
 ]
 
-
-
-
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {'https://docs.python.org/': None}
 
-class Mock(MagicMock):
-    @classmethod
-    def __getattr__(cls, name):
-        return MagicMock()
-
-MOCK_MODULES = ['lmdb']
-sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
-

+ 0 - 0
lsup-admin