Skip to content

Commit f0f4e04

Browse files
authored
MAINT: change conda dependency to libgdal-core + remove dependency on pyproj (#452)
1 parent 1ad69fb commit f0f4e04

File tree

10 files changed

+39
-11
lines changed

10 files changed

+39
-11
lines changed

CHANGES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## 0.9.1 (yyyy-mm-dd)
44

5+
### Packaging
6+
7+
- For the conda-forge package, change the dependency from `libgdal` to
8+
`libgdal-core`. This package is significantly smaller as it doesn't contain
9+
some large GDAL plugins. Extra plugins can be installed as seperate conda
10+
packages if needed: more info [here](https://gdal.org/download.html#conda).
11+
This also leads to `pyproj` becoming an optional dependency; you will need
12+
to install `pyproj` in order to support spatial reference systems (#452).
13+
514
### Bug fixes
615

716
- Silence warning from `write_dataframe` with `GeoSeries.notna()` (#435).

ci/envs/latest.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ channels:
33
- conda-forge
44
dependencies:
55
- numpy
6-
- libgdal
6+
- libgdal-core
77
- pytest
88
- shapely>=2
99
- geopandas-base
1010
- pyarrow
11-

ci/envs/minimal.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ channels:
33
- conda-forge
44
dependencies:
55
- numpy
6-
- libgdal
6+
- libgdal-core
77
- pytest

ci/envs/nightly-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test
22
channels:
33
- conda-forge
44
dependencies:
5-
- libgdal
5+
- libgdal-core
66
- pytest
77
- geopandas-base
88
- pip

environment-dev.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ name: pyogrio-dev
22
channels:
33
- conda-forge
44
dependencies:
5+
# Required
56
- numpy
7+
- libgdal-core
8+
- shapely>=2
9+
# Optional
610
- geopandas-base
7-
- libgdal==3.8.3
11+
- pyproj
812
- pyarrow
9-
- shapely>=2
1013
# Specific for dev
1114
- cython
1215
- pre-commit
1316
- pytest
14-
- versioneer
1517
- ruff
18+
- versioneer

pyogrio/_compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
except ImportError:
99
pyarrow = None
1010

11+
try:
12+
import pyproj
13+
except ImportError:
14+
pyproj = None
15+
1116
try:
1217
import shapely
1318
except ImportError:
@@ -27,6 +32,7 @@
2732
HAS_ARROW_API = __gdal_version__ >= (3, 6, 0)
2833
HAS_ARROW_WRITE_API = __gdal_version__ >= (3, 8, 0)
2934
HAS_PYARROW = pyarrow is not None
35+
HAS_PYPROJ = pyproj is not None
3036

3137
HAS_GEOPANDAS = geopandas is not None
3238

pyogrio/geopandas.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ def write_dataframe(
447447

448448
from geopandas.array import to_wkb
449449
import pandas as pd
450-
from pyproj.enums import WktVersion # if geopandas is available so is pyproj
451450

452451
if not isinstance(df, pd.DataFrame):
453452
raise ValueError("'df' must be a DataFrame or GeoDataFrame")
@@ -579,7 +578,7 @@ def write_dataframe(
579578
if epsg:
580579
crs = f"EPSG:{epsg}" # noqa: E231
581580
else:
582-
crs = geometry.crs.to_wkt(WktVersion.WKT1_GDAL)
581+
crs = geometry.crs.to_wkt("WKT1_GDAL")
583582

584583
if use_arrow:
585584
import pyarrow as pa

pyogrio/tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
HAS_ARROW_WRITE_API,
1515
HAS_GDAL_GEOS,
1616
HAS_PYARROW,
17+
HAS_PYPROJ,
1718
HAS_SHAPELY,
1819
)
1920
from pyogrio.raw import read, write
@@ -54,6 +55,8 @@ def pytest_report_header(config):
5455
not HAS_ARROW_API or not HAS_PYARROW, reason="GDAL>=3.6 and pyarrow required"
5556
)
5657

58+
requires_pyproj = pytest.mark.skipif(not HAS_PYPROJ, reason="pyproj required")
59+
5760
requires_arrow_write_api = pytest.mark.skipif(
5861
not HAS_ARROW_WRITE_API or not HAS_PYARROW,
5962
reason="GDAL>=3.8 required for Arrow write API",

pyogrio/tests/test_geopandas_io.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
DRIVERS,
2121
requires_pyarrow_api,
2222
requires_arrow_write_api,
23+
requires_pyproj,
2324
requires_gdal_geos,
2425
)
25-
from pyogrio._compat import PANDAS_GE_15, HAS_ARROW_WRITE_API
26+
from pyogrio._compat import HAS_PYPROJ, PANDAS_GE_15, HAS_ARROW_WRITE_API
2627

2728
try:
2829
import pandas as pd
@@ -126,7 +127,8 @@ def test_read_csv_platform_encoding(tmp_path):
126127
def test_read_dataframe(naturalearth_lowres_all_ext):
127128
df = read_dataframe(naturalearth_lowres_all_ext)
128129

129-
assert df.crs == "EPSG:4326"
130+
if HAS_PYPROJ:
131+
assert df.crs == "EPSG:4326"
130132
assert len(df) == 177
131133
assert df.columns.tolist() == [
132134
"pop_est",
@@ -1071,6 +1073,8 @@ def test_write_empty_geometry(tmp_path):
10711073
# Check that no warning is raised with GeoSeries.notna()
10721074
with warnings.catch_warnings():
10731075
warnings.simplefilter("error", UserWarning)
1076+
if not HAS_PYPROJ:
1077+
warnings.filterwarnings("ignore", message="'crs' was not provided.")
10741078
write_dataframe(expected, filename)
10751079
assert filename.exists()
10761080

@@ -1460,6 +1464,7 @@ def test_write_dataframe_infer_geometry_with_nulls(tmp_path, geoms, ext, use_arr
14601464
"ignore: You will likely lose important projection information"
14611465
)
14621466
@pytest.mark.requires_arrow_write_api
1467+
@requires_pyproj
14631468
def test_custom_crs_io(tmp_path, naturalearth_lowres_all_ext, use_arrow):
14641469
df = read_dataframe(naturalearth_lowres_all_ext)
14651470
# project Belgium to a custom Albers Equal Area projection

pyogrio/tests/test_path.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
import pyogrio
9+
from pyogrio._compat import HAS_PYPROJ
910
import pyogrio.raw
1011
from pyogrio.util import vsi_path, get_vsi_path_or_buffer
1112

@@ -238,6 +239,9 @@ def test_detect_zip_path(tmp_path, naturalearth_lowres):
238239
path = tmp_path / "test.zip"
239240
with ZipFile(path, mode="w", compression=ZIP_DEFLATED, compresslevel=5) as out:
240241
for ext in ["dbf", "prj", "shp", "shx"]:
242+
if not HAS_PYPROJ and ext == "prj":
243+
continue
244+
241245
filename = f"test1.{ext}"
242246
out.write(tmp_path / filename, filename)
243247

0 commit comments

Comments
 (0)