ports/156076: [patch] databases/py-sqlite3: Undefined symbol "sqlite3_load_extension"

Pan Tsu inyaoo at gmail.com
Thu Mar 31 03:20:10 UTC 2011


>Number:         156076
>Category:       ports
>Synopsis:       [patch] databases/py-sqlite3: Undefined symbol "sqlite3_load_extension"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-python
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 31 03:20:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Anonymous
>Release:        FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
Move py-sqlite3 fix to its own PR after silence on python@ for ~2 days, cf.
  http://docs.freebsd.org/cgi/mid.cgi?86tyem8iz9.fsf

tested on www/firefox (PGO build, r64446), www/py-flexget (via sqlalchemy)
tested on lang/python27, lang/python32

  $ ./sqlite3_compileoption_get
  ENABLE_COLUMN_METADATA
  ENABLE_FTS3
  ENABLE_FTS3_PARENTHESIS
  ENABLE_UNLOCK_NOTIFY
  OMIT_LOAD_EXTENSION
  SECURE_DELETE
  TEMP_STORE=1
  THREADSAFE=1

>Description:
Don't define HAVE_LOAD_EXTENSION when sqlite3 is compiled with EXTENSION
option turned off.

see also ports/149842, ports/155971, neither cites exact error message
>How-To-Repeat:
1. install databases/sqlite3 without EXTENSION support
2. install databases/py-sqlite3
3. try to import py-sqlite3

  $ python -c 'import sqlite3'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
      from dbapi2 import *
    File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
      from _sqlite3 import *
  ImportError: /usr/local/lib/python2.7/site-packages/_sqlite3.so: Undefined symbol "sqlite3_load_extension"

>Fix:
No need to go overkill and iterate sqlite3_compileoption_get() to
populate macros, testing existence of the symbol is enough.

  $ grep -r '#if.*[[:blank:]]SQLITE_' $(make -V WRKSRC) | fgrep -iv version
  WRKSRC/_sqlite/connection.c:#ifndef SQLITE_OMIT_LOAD_EXTENSION

--- a.diff begins here ---
Index: databases/py-sqlite3/Makefile
===================================================================
RCS file: /a/.cvsup/ports/databases/py-sqlite3/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- databases/py-sqlite3/Makefile	28 Oct 2010 21:00:08 -0000	1.8
+++ databases/py-sqlite3/Makefile	29 Mar 2011 07:40:40 -0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	sqlite3
 PORTVERSION=	${PYTHON_PORTVERSION}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	databases python
 MASTER_SITES=	${PYTHON_MASTER_SITES}
 MASTER_SITE_SUBDIR=	${PYTHON_MASTER_SITE_SUBDIR}
Index: databases/py-sqlite3/files/setup.py
===================================================================
RCS file: /a/.cvsup/ports/databases/py-sqlite3/files/setup.py,v
retrieving revision 1.2
diff -u -p -r1.2 setup.py
--- databases/py-sqlite3/files/setup.py	7 Aug 2006 02:23:05 -0000	1.2
+++ databases/py-sqlite3/files/setup.py	29 Mar 2011 07:38:29 -0000
@@ -32,6 +32,12 @@ sqlite_srcs = [
 '_sqlite/statement.c',
 '_sqlite/util.c']
 
+try:
+    import ctypes
+    ctypes.CDLL('libsqlite3.so').sqlite3_load_extension
+except AttributeError:
+    macros.append(('SQLITE_OMIT_LOAD_EXTENSION', '1'))
+
 setup(name = "_sqlite3",
       description = "SQLite 3 extension to Python",
       
Index: databases/py-sqlite3/files/setup3.py
===================================================================
RCS file: /a/.cvsup/ports/databases/py-sqlite3/files/setup3.py,v
retrieving revision 1.1
diff -u -p -r1.1 setup3.py
--- databases/py-sqlite3/files/setup3.py	30 Jun 2009 21:51:53 -0000	1.1
+++ databases/py-sqlite3/files/setup3.py	29 Mar 2011 07:40:50 -0000
@@ -31,6 +31,12 @@ sqlite_srcs = [
 '_sqlite/statement.c',
 '_sqlite/util.c']
 
+try:
+    import ctypes
+    ctypes.CDLL('libsqlite3.so').sqlite3_load_extension
+except AttributeError:
+    macros.append(('SQLITE_OMIT_LOAD_EXTENSION', '1'))
+
 setup(name = "_sqlite3",
       description = "SQLite 3 extension to Python",
       
--- a.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-python mailing list