You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it's hard to build autodoc files for projects that use GDAL. This affects all GeoDjango projects / django.contrib.gis imports.
The proposed solution to use autodoc_mock_imports doesn't work here. Before it's applied, the django setup already imports the real module. I've failed to move django.setup() after de autodoc initialization, even when using Sphinx events. Plus, the mock breaks other imports in a different way.
My current workaround is adding this to docs/source/conf.py:
import os
import sys
import django
from sphinx.ext.autodoc.mock import _MockModule
sys.path.insert(0, os.path.abspath("../../src"))
os.environ["DJANGO_SETTINGS_MODULE"] = "myproject.settings"
# GDAL is not part of the build container
# The workaround to use 'autodoc_mock_imports' doesn't work either, and is applied too late.
# Instead, the internal machinery of 'autodoc_mock_imports' is reused here to avoid GDAL imports.
class GDALMockModule(_MockModule):
GDAL_VERSION = (0, 0)
sys.modules["django.contrib.gis.geos.libgeos"] = _MockModule("django.contrib.gis.geos.libgeos")
sys.modules["django.contrib.gis.gdal.libgdal"] = GDALMockModule("django.contrib.gis.gdal.libgdal")
django.setup()
Since GDAL is a common dependency for any GIS-related project, could you consider adding it by default in the project?
The text was updated successfully, but these errors were encountered:
vdboor
changed the title
Feature request: provide libgdal inside the build container
Feature request: provide libgdal/libgeos inside the build container
May 6, 2021
Currently it's hard to build autodoc files for projects that use GDAL. This affects all GeoDjango projects /
django.contrib.gis
imports.The proposed solution to use
autodoc_mock_imports
doesn't work here. Before it's applied, the django setup already imports the real module. I've failed to movedjango.setup()
after de autodoc initialization, even when using Sphinx events. Plus, the mock breaks other imports in a different way.My current workaround is adding this to
docs/source/conf.py
:Since GDAL is a common dependency for any GIS-related project, could you consider adding it by default in the project?
The text was updated successfully, but these errors were encountered: