From 0a198a0f691c8e606342126d564ca00436e7f851 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Thu, 18 Jul 2024 09:21:46 +0200 Subject: [PATCH 01/12] MAINT: change dependency to libgdal-core --- ci/envs/latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/latest.yml b/ci/envs/latest.yml index 0643a67f..39b7e0aa 100644 --- a/ci/envs/latest.yml +++ b/ci/envs/latest.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - numpy - - libgdal + - libgdal-core - pytest - shapely>=2 - geopandas-base From 51f03ecb9f460afd5e32d5bfe877ba9fd22eb595 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Thu, 18 Jul 2024 09:30:33 +0200 Subject: [PATCH 02/12] Add pyproj as dependency as well... --- ci/envs/latest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/latest.yml b/ci/envs/latest.yml index 39b7e0aa..bded966a 100644 --- a/ci/envs/latest.yml +++ b/ci/envs/latest.yml @@ -8,4 +8,4 @@ dependencies: - shapely>=2 - geopandas-base - pyarrow - + - pyproj From e66e93a56f53a935cf9d6922ff636f26da8501d3 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Thu, 18 Jul 2024 09:34:52 +0200 Subject: [PATCH 03/12] Also depend on libgdal-core for minimal --- ci/envs/minimal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/minimal.yml b/ci/envs/minimal.yml index 8cd6e83d..a20d2e39 100644 --- a/ci/envs/minimal.yml +++ b/ci/envs/minimal.yml @@ -3,5 +3,5 @@ channels: - conda-forge dependencies: - numpy - - libgdal + - libgdal-core - pytest From 9abb1f459c3e8af74b5fa8e920a4049c48cb1e8a Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 01:45:59 +0200 Subject: [PATCH 04/12] Try just removing the dependency on pyproj --- pyogrio/geopandas.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyogrio/geopandas.py b/pyogrio/geopandas.py index b700d99c..cc50189a 100644 --- a/pyogrio/geopandas.py +++ b/pyogrio/geopandas.py @@ -447,7 +447,6 @@ def write_dataframe( from geopandas.array import to_wkb import pandas as pd - from pyproj.enums import WktVersion # if geopandas is available so is pyproj if not isinstance(df, pd.DataFrame): raise ValueError("'df' must be a DataFrame or GeoDataFrame") @@ -579,7 +578,7 @@ def write_dataframe( if epsg: crs = f"EPSG:{epsg}" # noqa: E231 else: - crs = geometry.crs.to_wkt(WktVersion.WKT1_GDAL) + crs = geometry.crs.to_wkt("WKT1_GDAL") if use_arrow: import pyarrow as pa From 2cb815cfe56bca2bfb8388f5f6f6f1b681144567 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 11:25:36 +0200 Subject: [PATCH 05/12] Update CHANGES.md --- CHANGES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 99c837ae..3a0104d6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,14 @@ ## 0.9.1 (yyyy-mm-dd) +### Packaging + +- For the conda-forge package, change the dependency from `libgdal` to + `libgdal-core`. This package is significantly smaller as it doesn't contain + some large GDAL plugins. Extra plugins can be installed as seperate conda + packages if needed: more info [here](https://gdal.org/download.html#conda) + (#452). + ### Bug fixes - Silence warning from `write_dataframe` with `GeoSeries.notna()` (#435). From 3325138bdb743b7404d86a7f6ff6bdf7b4c2900d Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 11:28:38 +0200 Subject: [PATCH 06/12] Update nightly-deps.yml --- ci/envs/nightly-deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/nightly-deps.yml b/ci/envs/nightly-deps.yml index d6df4e94..2bca259d 100644 --- a/ci/envs/nightly-deps.yml +++ b/ci/envs/nightly-deps.yml @@ -2,7 +2,7 @@ name: test channels: - conda-forge dependencies: - - libgdal + - libgdal-core - pytest - geopandas-base - pip From e7abe19dc5d2bc0314f375989b851d93c8d87bfa Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 11:33:10 +0200 Subject: [PATCH 07/12] Try removing pyproj dependency again --- ci/envs/latest.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/envs/latest.yml b/ci/envs/latest.yml index bded966a..c75ab4b7 100644 --- a/ci/envs/latest.yml +++ b/ci/envs/latest.yml @@ -8,4 +8,3 @@ dependencies: - shapely>=2 - geopandas-base - pyarrow - - pyproj From eb4b6d200ec07820c38cfffa6e4a0a5f2a84f9c3 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 21:31:34 +0200 Subject: [PATCH 08/12] Fix some tests when pyproj not available --- pyogrio/_compat.py | 6 ++++++ pyogrio/tests/conftest.py | 3 +++ pyogrio/tests/test_geopandas_io.py | 9 +++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pyogrio/_compat.py b/pyogrio/_compat.py index cd67247e..fc3df94d 100644 --- a/pyogrio/_compat.py +++ b/pyogrio/_compat.py @@ -8,6 +8,11 @@ except ImportError: pyarrow = None +try: + import pyproj +except ImportError: + pyproj = None + try: import shapely except ImportError: @@ -27,6 +32,7 @@ HAS_ARROW_API = __gdal_version__ >= (3, 6, 0) HAS_ARROW_WRITE_API = __gdal_version__ >= (3, 8, 0) HAS_PYARROW = pyarrow is not None +HAS_PYPROJ = pyproj is not None HAS_GEOPANDAS = geopandas is not None diff --git a/pyogrio/tests/conftest.py b/pyogrio/tests/conftest.py index d562a4d1..85508464 100644 --- a/pyogrio/tests/conftest.py +++ b/pyogrio/tests/conftest.py @@ -14,6 +14,7 @@ HAS_ARROW_WRITE_API, HAS_GDAL_GEOS, HAS_PYARROW, + HAS_PYPROJ, HAS_SHAPELY, ) from pyogrio.raw import read, write @@ -54,6 +55,8 @@ def pytest_report_header(config): not HAS_ARROW_API or not HAS_PYARROW, reason="GDAL>=3.6 and pyarrow required" ) +requires_pyproj = pytest.mark.skipif(not HAS_PYPROJ, reason="pyproj required") + requires_arrow_write_api = pytest.mark.skipif( not HAS_ARROW_WRITE_API or not HAS_PYARROW, reason="GDAL>=3.8 required for Arrow write API", diff --git a/pyogrio/tests/test_geopandas_io.py b/pyogrio/tests/test_geopandas_io.py index 12146c3d..7786afb1 100644 --- a/pyogrio/tests/test_geopandas_io.py +++ b/pyogrio/tests/test_geopandas_io.py @@ -20,9 +20,10 @@ DRIVERS, requires_pyarrow_api, requires_arrow_write_api, + requires_pyproj, requires_gdal_geos, ) -from pyogrio._compat import PANDAS_GE_15, HAS_ARROW_WRITE_API +from pyogrio._compat import HAS_PYPROJ, PANDAS_GE_15, HAS_ARROW_WRITE_API try: import pandas as pd @@ -126,7 +127,8 @@ def test_read_csv_platform_encoding(tmp_path): def test_read_dataframe(naturalearth_lowres_all_ext): df = read_dataframe(naturalearth_lowres_all_ext) - assert df.crs == "EPSG:4326" + if HAS_PYPROJ: + assert df.crs == "EPSG:4326" assert len(df) == 177 assert df.columns.tolist() == [ "pop_est", @@ -1071,6 +1073,8 @@ def test_write_empty_geometry(tmp_path): # Check that no warning is raised with GeoSeries.notna() with warnings.catch_warnings(): warnings.simplefilter("error", UserWarning) + if not HAS_PYPROJ: + warnings.filterwarnings("ignore", message="'crs' was not provided.") write_dataframe(expected, filename) assert filename.exists() @@ -1460,6 +1464,7 @@ def test_write_dataframe_infer_geometry_with_nulls(tmp_path, geoms, ext, use_arr "ignore: You will likely lose important projection information" ) @pytest.mark.requires_arrow_write_api +@requires_pyproj def test_custom_crs_io(tmp_path, naturalearth_lowres_all_ext, use_arrow): df = read_dataframe(naturalearth_lowres_all_ext) # project Belgium to a custom Albers Equal Area projection From 67e8a00e7302e735f2ff6df1012fbb1270fd7d5a Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 21:34:26 +0200 Subject: [PATCH 09/12] Update environment-dev.yml --- environment-dev.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index e9992f65..1deb497c 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -2,14 +2,17 @@ name: pyogrio-dev channels: - conda-forge dependencies: + # Required - numpy + - libgdal-core + - shapely>=2 + # Optional - geopandas-base - - libgdal==3.8.3 + - pyproj - pyarrow - - shapely>=2 # Specific for dev - cython - pre-commit - pytest - - versioneer - ruff + - versioneer \ No newline at end of file From a52a56d18c1e61843d5a5375826d42b7d8dc8c53 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 21:40:42 +0200 Subject: [PATCH 10/12] Fix another test --- pyogrio/tests/test_path.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyogrio/tests/test_path.py b/pyogrio/tests/test_path.py index 3dde5363..5c61f05e 100644 --- a/pyogrio/tests/test_path.py +++ b/pyogrio/tests/test_path.py @@ -6,6 +6,7 @@ import pytest import pyogrio +from pyogrio._compat import HAS_PYPROJ import pyogrio.raw from pyogrio.util import vsi_path, get_vsi_path_or_buffer @@ -238,6 +239,9 @@ def test_detect_zip_path(tmp_path, naturalearth_lowres): path = tmp_path / "test.zip" with ZipFile(path, mode="w", compression=ZIP_DEFLATED, compresslevel=5) as out: for ext in ["dbf", "prj", "shp", "shx"]: + if not HAS_PYPROJ and ext == "prj": + continue + filename = f"test1.{ext}" out.write(tmp_path / filename, filename) From 8611fe7ffe42f2bf23305215f9ea21a790d27df9 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Sat, 27 Jul 2024 22:01:11 +0200 Subject: [PATCH 11/12] Update CHANGES.md --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3a0104d6..7c876215 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,8 +7,8 @@ - For the conda-forge package, change the dependency from `libgdal` to `libgdal-core`. This package is significantly smaller as it doesn't contain some large GDAL plugins. Extra plugins can be installed as seperate conda - packages if needed: more info [here](https://gdal.org/download.html#conda) - (#452). + packages if needed: more info [here](https://gdal.org/download.html#conda). + This also leads to `pyproj` becoming an optional dependency (#452). ### Bug fixes From 71850a55d582d8b3ccbbc158e5f597d7a3f24d13 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Tue, 20 Aug 2024 20:55:38 +0200 Subject: [PATCH 12/12] Improve changelog as suggested --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7c876215..626f3eb2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,8 @@ `libgdal-core`. This package is significantly smaller as it doesn't contain some large GDAL plugins. Extra plugins can be installed as seperate conda packages if needed: more info [here](https://gdal.org/download.html#conda). - This also leads to `pyproj` becoming an optional dependency (#452). + This also leads to `pyproj` becoming an optional dependency; you will need + to install `pyproj` in order to support spatial reference systems (#452). ### Bug fixes