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 python3 pyspatialite import #3534

Merged
merged 1 commit into from Sep 28, 2016
Merged

Fix python3 pyspatialite import #3534

merged 1 commit into from Sep 28, 2016

Conversation

dmarteau
Copy link
Contributor

@dmarteau dmarteau commented Sep 27, 2016

pyspatialite is broken under python 3.5+:

ImportError: dynamic module does not define module export function (PyInit__spatialite)
  • buffer() is removed in python3 in favor of memoryview - see https://docs.python.org/2/c-api/buffer.html. memoryview works in 2.7 and support the object implementing buffer protocol. I did not see any explicit reference to buffer() in the qgis ( buffer is aliased as Binary in dbapi2.py) but I cannot speak for plugins.

@mhugo
Copy link

mhugo commented Sep 28, 2016

Hi @dmarteau
Just to let you know pyspatialite is now replaced by sqlite + load_extension. See https://github.com/qgis/QGIS/blob/master/python/utils.py#L587
If your patch helps to simplify utils.spatialite_connect it's fine :)

@dmarteau
Copy link
Contributor Author

dmarteau commented Sep 28, 2016

Hi @mhugo,

Actually, this is going to be a problem on OSX: the default implementation for python module sqlite does not enable load_extension: mac users will have to use a patched versions of python sqlite which is a core module:

I don't know about homebrew but Macport currently adopt the OSX way - and I hope that is going to be fixed soon: https://trac.macports.org/ticket/49317.

David

@mhugo
Copy link

mhugo commented Sep 28, 2016

Ok, so on OSX with your patch and the compilation flag WITH_PYSPATIALITE, pyspatialite should now be usable in Python 3 ? Cool.
Does anyone know why we don't compile our own version of pyspatialite whatever the platform ?

@dmarteau
Copy link
Contributor Author

dmarteau commented Sep 28, 2016

Actually, this is really a pain to install pyspatialite on OSX because the official pyspatialite module is totally deprecated and the right way is to use load_extension from python (which is deactivated on OSX - it does not even compile). The actual QGIS implementation is 'de facto' the only way to use pyspatialite on OSX without patching python.

@rldhont rldhont added this to the QGIS 3 milestone Sep 28, 2016
@@ -329,7 +329,11 @@ static struct PyModuleDef _sqlite3module = {
};
#endif

#if PY_MAJOR_VERSION < 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to check that, we no longer need to support python 2 on master

@nyalldawson nyalldawson assigned mhugo and unassigned nyalldawson Sep 28, 2016
@jef-n jef-n merged commit 07b7b7d into qgis:master Sep 28, 2016
@jef-n
Copy link
Member

jef-n commented Sep 28, 2016

This was a missing bit of 6e4e845.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants