geopython / geopython/pygeoapi

Make rasterio (and GDAL) an optional dependency (move it to extras_require)

Open
#2,392 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
624
Forks
326
Avg merge
8h 25m
Merged PRs (30d)
2

Description

Looking at `requirements.txt`

https://github.com/geopython/pygeoapi/blob/b96765c9d49945bf3c265fe37dcae5dd343e2be7/requirements.txt#L14

We have rasterio as dependency on every `pip install pygeoapi` pulls in rasterio (that is a big GDAL binary wheel)

But rasterio is used by only three providers:

- [pygeoapi/provider/rasterio_.py](https://github.com/geopython/pygeoapi/blob/b96765c9d49945bf3c265fe37dcae5dd343e2be7/pygeoapi/provider/rasterio_.py#L34)
- [pygeoapi/provider/filesystem.py](https://github.com/geopython/pygeoapi/blob/b96765c9d49945bf3c265fe37dcae5dd343e2be7/pygeoapi/provider/filesystem.py#L262)
- [pygeoapi/provider/azure_.py](https://github.com/geopython/pygeoapi/blob/b96765c9d49945bf3c265fe37dcae5dd343e2be7/pygeoapi/provider/azure_.py#L258)

So this bloats the base install and minimal container images.

The proposed slim/distroless Docker vaiants in #1753 only avoid it via a `pip install --no-deps` workaround and explicit dependency list
```python
#Add it as an extra in setup.py:
extras_require={
'rasterio': ['rasterio'],
},
```
And remove it from requirements.txt

- Keep rasterio available to CI/tests by listing it in requirements-dev.txt (or requirements-provider.txt) so the Rasterio provider is still exercised.
- Ensure rasterio_.py degrades gracefully when rasterio is absent (the plugin loader should already surface a clear "provider unavailable" error; the two lazy importers already do the right thing).

So:
- pip install pygeoapi -> GDAL-free
- pip install pygeoapi[rasterio] - >raster/coverage support

Contributor guide

Open the contributing guide

Research direction

Start with requirements.txt and setup.py to trace how rasterio enters the base install, then review requirements-dev.txt or requirements-provider.txt for CI coverage. Read pygeoapi/provider/rasterio_.py, filesystem.py, and azure_.py, including their documented lazy-import behavior. Done means the base install is GDAL-free, the rasterio extra restores raster support, and CI still exercises the provider with rasterio installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, build-system
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.