Skip to content

Commit abc180a

Browse files
committed
Add pyogrio
1 parent e73a4d1 commit abc180a

4 files changed

Lines changed: 150 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
export GDAL_DATA=${PREFIX}/share/gdal
3+
${PYTHON} -m pip install .
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
From 8e7ad6c60a5052f29a95def2709ad4075f0d1aa1 Mon Sep 17 00:00:00 2001
2+
From: Julien Jerphanion <git@jjerphan.xyz>
3+
Date: Fri, 19 Dec 2025 16:19:35 +0100
4+
Subject: [PATCH] Set GDAL_DATA environment variable and remove ValueError
5+
checks
6+
7+
Set GDAL_DATA to ${PREFIX}/share/gdal before importing pyogrio.core
8+
to ensure GDAL data files are found correctly. Also remove ValueError
9+
checks in init_gdal_data to allow graceful handling when data files
10+
are not present. Patch get_gdal_data_path to return GDAL_DATA env var.
11+
12+
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
13+
---
14+
pyogrio/__init__.py | 7 +++++++
15+
pyogrio/_ogr.pyx | 16 +++-------------
16+
2 files changed, 10 insertions(+), 13 deletions(-)
17+
18+
diff --git a/pyogrio/__init__.py b/pyogrio/__init__.py
19+
index 17db833..9bc18b1 100644
20+
--- a/pyogrio/__init__.py
21+
+++ b/pyogrio/__init__.py
22+
@@ -1,5 +1,12 @@
23+
"""Vectorized vector I/O using OGR."""
24+
25+
+import os
26+
+
27+
+# Set GDAL_DATA environment variable before importing GDAL-dependent modules
28+
+if 'GDAL_DATA' not in os.environ:
29+
+ __prefix = os.environ.get('PREFIX', "/")
30+
+ os.environ['GDAL_DATA'] = os.path.join(__prefix, 'share', 'gdal')
31+
+
32+
try:
33+
# we try importing shapely, to ensure it is imported (and it can load its
34+
# own GEOS copy) before we load GDAL and its linked GEOS
35+
diff --git a/pyogrio/_ogr.pyx b/pyogrio/_ogr.pyx
36+
index 2109125..e58ee53 100644
37+
--- a/pyogrio/_ogr.pyx
38+
+++ b/pyogrio/_ogr.pyx
39+
@@ -159,10 +159,9 @@ def get_gdal_data_path():
40+
"""
41+
Get the path to the directory GDAL uses to read data files.
42+
"""
43+
- cdef const char *path_c = CPLFindFile("gdal", "header.dxf")
44+
- if path_c != NULL:
45+
- return get_string(path_c).replace("header.dxf", "")
46+
- return None
47+
+ __prefix = os.environ.get('PREFIX', "/")
48+
+ __fallback = os.path.join(__prefix, 'share', 'gdal')
49+
+ return os.environ.get('GDAL_DATA', __fallback)
50+
51+
52+
def has_proj_data():
53+
@@ -204,10 +203,6 @@ def init_gdal_data():
54+
wheel_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "gdal_data"))
55+
if os.path.exists(wheel_path):
56+
set_gdal_config_options({"GDAL_DATA": wheel_path})
57+
- if not has_gdal_data():
58+
- raise ValueError(
59+
- "Could not correctly detect GDAL data files installed by pyogrio wheel"
60+
- )
61+
return
62+
63+
# GDAL correctly found data files from GDAL_DATA or compiled-in paths
64+
@@ -217,11 +212,6 @@ def init_gdal_data():
65+
wk_path = os.path.join(sys.prefix, "share", "gdal")
66+
if os.path.exists(wk_path):
67+
set_gdal_config_options({"GDAL_DATA": wk_path})
68+
- if not has_gdal_data():
69+
- raise ValueError(
70+
- f"Found GDAL data directory at {wk_path} but it does not appear to "
71+
- "correctly contain GDAL data files"
72+
- )
73+
return
74+
75+
warnings.warn(
76+
--
77+
2.52.0
78+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
context:
2+
name: pyogrio
3+
version: 0.12.1
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
source:
10+
url: https://github.com/geopandas/pyogrio/releases/download/v${{ version }}/pyogrio-${{ version }}.tar.gz
11+
sha256: e548ab705bb3e5383693717de1e6c76da97f3762ab92522cb310f93128a75ff1
12+
patches:
13+
- patches/0001-Set-GDAL_DATA-environment-variable-and-remove-ValueE.patch
14+
15+
build:
16+
number: 0
17+
18+
requirements:
19+
build:
20+
- python
21+
- cross-python_${{ target_platform }}
22+
- cython
23+
- ${{ compiler('c') }}
24+
- ${{ compiler('cxx') }}
25+
- pip
26+
- setuptools
27+
- numpy
28+
host:
29+
- python
30+
- pip
31+
- setuptools
32+
- cython
33+
- libgdal-core
34+
- versioneer
35+
- tomli
36+
- numpy
37+
run:
38+
- python
39+
- libgdal-core
40+
- packaging
41+
- numpy
42+
43+
tests:
44+
- script: pytester
45+
requirements:
46+
build:
47+
- pytester
48+
run:
49+
- pytester-run
50+
files:
51+
recipe:
52+
- test_pyogrio.py
53+
54+
about:
55+
homepage: https://github.com/geopandas/pyogrio/
56+
license: MIT
57+
license_file: LICENSE
58+
summary: Vectorized vector I/O using GDAL
59+
description: |
60+
Provide faster I/O using GDAL OGR to read / write vector geospatial files.
61+
Intended for use with libraries that consume WKB for their internal constructs, such as pygeos.
62+
documentation: https://pyogrio.readthedocs.io/
63+
repository: https://github.com/geopandas/pyogrio
64+
65+
extra:
66+
recipe-maintainers:
67+
- jjerphan
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_pyogrio():
2+
import pyogrio

0 commit comments

Comments
 (0)