Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: register drivers on import #145

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## O.4.2

### Bug fixes

- register GDAL drivers during initial import of pyogrio (#145)

## 0.4.1

### Bug fixes
Expand Down
3 changes: 0 additions & 3 deletions pyogrio/_io.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ cdef void* ogr_open(const char* path_c, int mode, options) except NULL:
cdef void* ogr_driver = NULL
cdef char **open_opts = NULL

# Register all drivers
GDALAllRegister()

# Force linear approximations in all cases
OGRSetNonLinearGeometriesEnabledFlag(0)

Expand Down
8 changes: 5 additions & 3 deletions pyogrio/_ogr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ def ogr_list_drivers():
cdef int i
cdef char *name_c

# Register all drivers
GDALAllRegister()

drivers = dict()
for i in range(OGRGetDriverCount()):
driver = OGRGetDriver(i)
Expand Down Expand Up @@ -272,3 +269,8 @@ def init_proj_data():
return

warnings.warn("Could not detect PROJ data files. Set PROJ_LIB environment variable to the correct path.", RuntimeWarning)


def _register_drivers():
# Register all drivers
GDALAllRegister()
2 changes: 2 additions & 0 deletions pyogrio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
init_gdal_data as _init_gdal_data,
init_proj_data as _init_proj_data,
remove_virtual_file,
_register_drivers,
)
from pyogrio._io import ogr_list_layers, ogr_read_bounds, ogr_read_info

_init_gdal_data()
_init_proj_data()
_register_drivers()

__gdal_version__ = get_gdal_version()
__gdal_version_string__ = get_gdal_version_string()
Expand Down