Description
Code of Conduct
- I agree to follow Django's Code of Conduct
Feature Description
Enable lazy loading of the GDAL library in django.contrib.gis.gdal
, mirroring the existing behavior of django.contrib.gis.geos
with the GEOS library.
Problem
Currently, calling django.setup()
on projects that use GeoDjango will fail if GDAL isn't available, even when you're not actually using any GDAL functionality. GEOS doesn't have this problem because it was made lazy 10 years ago (commmit), but no one has bothered to do the same for the GDAL module in the time since then.
This creates an inconsistency in the GeoDjango framework where one geospatial library is lazy and the other isn't.
Request or proposal
proposal
Additional Details
This came about while I've been puttering around on my django-language-server side-project. I have a few applications that use the GeoDjango framework, and to get around the slight inconvenience of installing all the geospatial requirements locally, we moved to using a Docker container with them all pre-installed for development.
This works great for the actual applications, however, I want to be able to run the language server globally on my system without requiring Docker or having to install GDAL just to be able to call django.setup()
— GEOS isn't required because of the laziness of its loading.
I initially tried working on a third-party library to prove this out (django-lazy-gdal), but the headache of trying to both lazily load GDAL and monkeypatch everything that needs patching has proven to be too complex to be worth banging my head against that wall anymore.
Implementation Suggestions
I have a pretty complete branch with a working POC (main branch diff), largely inspired by that original commit that made GEOS lazy. What's there is working just like it should, lazily loading the GDAL library while also mostly maintaining backwards compatibility (plus or minus a few scattered variables), but I'd like some feedback on the approach before moving forward with a formal pull request. Since this is a pretty substantial change, I wanted to gauge interest and gather feedback first.
Metadata
Metadata
Assignees
Type
Projects
Status