From dff6bccd9a14d190ea65d14d43d1f6daeffd569a Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Tue, 28 Feb 2017 11:10:51 +0100 Subject: [PATCH] workaround for RTD apidoc build --- doc/source/conf.py | 32 ++++++++++++++++++++++++++++++++ doc/source/requirements.txt | 1 + setup.py | 4 +++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 44a9a5f5..cc75a025 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -20,6 +20,8 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) +import sys +from mock import Mock as MagicMock # -- General configuration ------------------------------------------------ @@ -154,3 +156,33 @@ # numpydoc fix numpydoc_show_class_members = False + +# Mocking + +class Mock(MagicMock): + @classmethod + def __getattr__(cls, name): + return MagicMock() + + +MOCK_MODULES = [ + 'tilematrix', + 'fiona', + 'pyyaml', + 'flask', + 'Pillow', + 'scipy', + 'rasterio', + 'rasterio.features', + 'rasterio.warp', + 'rasterio.warp.Resampling', + 'rasterio.windows', + 'rasterio.crs', + 'matplotlib', + 'matplotlib.pyplot', + 'gdal', + 'cached_property', + 'pyproj', + 'cachetools' +] +sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) diff --git a/doc/source/requirements.txt b/doc/source/requirements.txt index 72128684..a16ccaad 100644 --- a/doc/source/requirements.txt +++ b/doc/source/requirements.txt @@ -1,2 +1,3 @@ numpydoc>=0.6.0 sphinxcontrib-autodoc-doxygen>=0.3.2 +mock diff --git a/setup.py b/setup.py index 290ecfe1..de8cf0fe 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,8 @@ from setuptools import setup +on_rtd = os.environ.get('READTHEDOCS') == 'True' + setup( name='mapchete', version='0.4', @@ -50,7 +52,7 @@ 'cached_property', 'pyproj', 'cachetools' - ], + ] if on_rtd else [], classifiers=[ 'Development Status :: 3 - Alpha', 'Intended Audience :: Developers',