Skip to content

Commit a3ca1d4

Browse files
fix(runtime): use bundled PROJ data in managed sidecars (#1491)
1 parent 6ab4888 commit a3ca1d4

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

backend/geolibre_server/geolibre_server/app/runtime.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def _clean_env() -> dict[str, str]:
6060
"""Return a Python subprocess environment suitable for extension imports."""
6161
env = dict(os.environ)
6262
env.pop("PYTHONHOME", None)
63+
# PyPI geospatial wheels bundle a matching PROJ database. Inherited search
64+
# paths can redirect them to an absent or incompatible system installation.
65+
env.pop("PROJ_DATA", None)
66+
env.pop("PROJ_LIB", None)
6367
env["PYTHONIOENCODING"] = "utf-8"
6468
env["PYTHONUTF8"] = "1"
6569
return env
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Tests for shared managed-runtime environment handling."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
7+
from geolibre_server.app.runtime import _clean_env
8+
9+
10+
def test_clean_env_drops_inherited_proj_search_paths(
11+
monkeypatch: pytest.MonkeyPatch,
12+
) -> None:
13+
"""Managed geospatial wheels must discover their own bundled PROJ data."""
14+
monkeypatch.setenv("PROJ_DATA", "/system/share/proj")
15+
monkeypatch.setenv("PROJ_LIB", "/legacy/system/share/proj")
16+
monkeypatch.setenv("GEOLIBRE_RUNTIME_DIR", "/managed/geolibre")
17+
18+
env = _clean_env()
19+
20+
assert "PROJ_DATA" not in env
21+
assert "PROJ_LIB" not in env
22+
assert env["GEOLIBRE_RUNTIME_DIR"] == "/managed/geolibre"

0 commit comments

Comments
 (0)