Skip to content

Fix sqlite3 import by matching upstream build option for load_extension #223

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

Merged
merged 1 commit into from
May 16, 2018

Conversation

ihnorton
Copy link
Contributor

@ihnorton ihnorton commented May 15, 2018

Per upstream documentation:

The sqlite3 module is not built with loadable extension support by
default, because some platforms (notably Mac OS X) have SQLite
libraries which are compiled without this feature. To get loadable
extension support, you must modify setup.py and remove the line that
sets SQLITE_OMIT_LOAD_EXTENSION.

which means that SQLITE_OMIT_LOAD_EXTENSION is added as a compile
definition by default in the upstream build system. We match that
here to fix import sqlite3.

Per upstream documentation:

> The sqlite3 module is not built with loadable extension support by
> default, because some platforms (notably Mac OS X) have SQLite
> libraries which are compiled without this feature. To get loadable
> extension support, you must modify setup.py and remove the line that
> sets SQLITE_OMIT_LOAD_EXTENSION.

which means that SQLITE_OMIT_LOAD_EXTENSION is added as a compile
definition by default in the upstream build system. We match that
here to fix `import sqlite3`.
@ihnorton
Copy link
Contributor Author

Slicer issue: https://issues.slicer.org/view.php?id=4555

>>> import sqlite3
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/opt/worksw/Slicer-4.9.0-20180425.app/Contents/lib/Python/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/opt/worksw/Slicer-4.9.0-20180425.app/Contents/lib/Python/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: dlopen(/opt/worksw/Slicer-4.9.0-20180425.app/Contents/lib/Python/lib/python2.7/lib-dynload/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
  Referenced from: /opt/worksw/Slicer-4.9.0-20180425.app/Contents/lib/Python/lib/python2.7/lib-dynload/_sqlite3.so
  Expected in: flat namespace
 in /opt/worksw/Slicer-4.9.0-20180425.app/Contents/lib/Python/lib/python2.7/lib-dynload/_sqlite3.so
>>> 

@jcfr jcfr merged commit c3b8d53 into python-cmake-buildsystem:master May 16, 2018
@jcfr
Copy link
Contributor

jcfr commented May 16, 2018

Thanks @ihnorton 👍

@ihnorton ihnorton deleted the fix_sqlite3 branch May 16, 2018 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants