This commit is contained in:
Francesco Bartoli
2020-01-29 00:16:09 +01:00
committed by GitHub
parent d0d7ed48da
commit fda0df9cb4
3 changed files with 51 additions and 1 deletions
+44
View File
@@ -0,0 +1,44 @@
.. _devel:
OSX Developers
==============
Using pyenv
-----------
It is common among OSX developers to use the package manager homebrew for the installation of pyenv to being able to manage multiple versions of Python.
They can encounter errors about the load of some SQLite extensions that pygeoapi uses for handling spatial data formats. In order to run properly the server
you are required to follow these steps below carefully.
Make Homebrew and pyenv play nicely together::
.. code-block:: console
# see https://github.com/pyenv/pyenv/issues/106
alias brew='env PATH=${PATH//$(pyenv root)\/shims:/} brew'
Install python with the option to enable SQLite extensions::
.. code-block:: console
LDFLAGS="-L/usr/local/opt/sqlite/lib -L/usr/local/opt/zlib/lib" CPPFLAGS="-I/usr/local/opt/sqlite/include -I/usr/local/opt/zlib/include" PYTHON_CONFIGURE_OPTS="--enable-loadable-sqlite-extensions" pyenv install 3.7.6
Configure SQLite from Homebrew over that one shipped with the OS::
.. code-block:: console
export PATH="/usr/local/opt/sqlite/bin:$PATH"
Install Spatialite from Homebrew::
.. code-block:: console
brew update
brew install spatialite-tools
brew libspatialite
Set the variable for the Spatialite library under OSX::
.. code-block:: console
SPATIALITE_LIBRARY_PATH=/usr/local/lib/mod_spatialite.dylib
+1
View File
@@ -16,6 +16,7 @@ Welcome to pygeoapi's documentation!
install
openapi
docker
devel
wsgi
asgi
configuration
+6 -1
View File
@@ -2,9 +2,11 @@
#
# Authors: Jorge Samuel Mendes de Jesus <jorge.dejesus@protonmail.net>
# Tom Kralidis <tomkralidis@gmail.com>
# Francesco Bartoli <xbartolone@gmail.com>
#
# Copyright (c) 2018 Jorge Samuel Mendes de Jesus
# Copyright (c) 2019 Tom Kralidis
# Copyright (c) 2020 Francesco Bartoli
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
@@ -39,6 +41,9 @@ from pygeoapi.provider.base import BaseProvider, ProviderConnectionError
LOGGER = logging.getLogger(__name__)
SPATIALITE_EXTENSION = os.getenv('SPATIALITE_LIBRARY_PATH', 'mod_spatialite.so')
class SQLiteGPKGProvider(BaseProvider):
"""Generic provider for SQLITE and GPKG using sqlite3 module.
This module requires install of libsqlite3-mod-spatialite
@@ -147,7 +152,7 @@ class SQLiteGPKGProvider(BaseProvider):
# conn.set_trace_callback(LOGGER.debug)
cursor = conn.cursor()
try:
cursor.execute("SELECT load_extension('mod_spatialite.so')")
cursor.execute(f"SELECT load_extension('{SPATIALITE_EXTENSION}')")
except sqlite3.OperationalError as err:
LOGGER.error('Extension loading error: {}'.format(err))
raise ProviderConnectionError()