[pypy-issue] [issue1440] "import sqlite3" fails on win32

mattip tracker at bugs.pypy.org
Mon Apr 8 17:48:46 CEST 2013


mattip <matti.picus at gmail.com> added the comment:

rather than modifying cffi, how about this fix which first looks for the 
sqlite3.dll next to the executable

diff -r 0126d6664978 lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py      Sun Apr 07 15:58:46 2013 +0200
+++ b/lib_pypy/_sqlite3.py      Mon Apr 08 18:46:35 2013 +0300
@@ -256,7 +256,12 @@
     typedef ... sqlite3;
     int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
     """)
-    unverified_lib = unverified_ffi.dlopen('sqlite3')
+    libname = 'sqlite3'
+    if sys.platform == 'win32':
+        _libname = os.path.join(os.path.dirname(sys.executable), libname)
+        if os.path.exists(_libname + '.dll'):
+            libname = _libname
+    unverified_lib = unverified_ffi.dlopen(libname)
     return hasattr(unverified_lib, 'sqlite3_enable_load_extension')

 if _has_load_extension():

----------
status: unread -> chatting

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1440>
________________________________________


More information about the pypy-issue mailing list