Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: provide libgdal/libgeos inside the build container #8160

Closed
vdboor opened this issue May 6, 2021 · 3 comments
Closed

Feature request: provide libgdal/libgeos inside the build container #8160

vdboor opened this issue May 6, 2021 · 3 comments
Labels
Support Support question

Comments

@vdboor
Copy link

vdboor commented 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 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?

@vdboor vdboor changed the title Feature request: provide libgdal inside the build container Feature request: provide libgdal/libgeos inside the build container May 6, 2021
@stsewd
Copy link
Member

stsewd commented May 6, 2021

Hi @vdboor is this the package https://packages.ubuntu.com/hirsute/gdal-bin? Soon you'll be able to install this from a config file #8065. Also, looks like you can use conda https://gdal.org/download.html#conda

@stsewd stsewd added Needed: more information A reply from issue author is required Support Support question labels May 6, 2021
@vdboor
Copy link
Author

vdboor commented May 12, 2021

@stsewd This concerns libgdal20 and libproj12. Both are libraries who are directly used via ctypes (in Django at least)

Behind able to install apt-packages would definitely fix the build issue! Both are part of the standard Ubuntu/Debian package repo's

@no-response no-response bot removed the Needed: more information A reply from issue author is required label May 12, 2021
@stsewd
Copy link
Member

stsewd commented May 12, 2021

#8065 should be live by next tuesday. You would need to use a config file like

version: 2

build:
   apt_packages:
      - libgdal20
      - libproj12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support Support question
Projects
None yet
Development

No branches or pull requests

2 participants