[Python-checkins] r43514 - in python/trunk: Lib/sqlite3 Lib/sqlite3/test Lib/test/regrtest.py Lib/test/test_sqlite.py Misc/NEWS Modules/_sqlite setup.py

anthony.baxter python-checkins at python.org
Sat Apr 1 02:57:33 CEST 2006


Author: anthony.baxter
Date: Sat Apr  1 02:57:31 2006
New Revision: 43514

Added:
   python/trunk/Lib/sqlite3/   (props changed)
      - copied from r43513, python/branches/sqlite-integration/Lib/sqlite3/
   python/trunk/Lib/test/test_sqlite.py
      - copied unchanged from r43513, python/branches/sqlite-integration/Lib/test/test_sqlite.py
   python/trunk/Modules/_sqlite/
      - copied from r43513, python/branches/sqlite-integration/Modules/_sqlite/
Modified:
   python/trunk/Lib/sqlite3/test/   (props changed)
   python/trunk/Lib/test/regrtest.py
   python/trunk/Misc/NEWS
   python/trunk/setup.py
Log:
merged the sqlite-integration branch. 
This is based on pysqlite2.1.3, and provides a DB-API interface in 
the standard library. You'll need sqlite 3.2.2 or later to build 
this - if you have an earlier version, the C extension module will 
not be built.


Modified: python/trunk/Lib/test/regrtest.py
==============================================================================
--- python/trunk/Lib/test/regrtest.py	(original)
+++ python/trunk/Lib/test/regrtest.py	Sat Apr  1 02:57:31 2006
@@ -741,6 +741,7 @@
         test_pwd
         test_resource
         test_signal
+        test_sqlite
         test_sunaudiodev
         test_threadsignals
         test_timing
@@ -763,6 +764,7 @@
         test_nis
         test_ntpath
         test_ossaudiodev
+        test_sqlite
         test_sunaudiodev
         """,
    'mac':
@@ -802,6 +804,7 @@
         test_pwd
         test_resource
         test_signal
+        test_sqlite
         test_sunaudiodev
         test_sundry
         test_tarfile
@@ -826,6 +829,7 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_sqlite
         test_sunaudiodev
         test_sundry
         """,
@@ -848,6 +852,7 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_sqlite
         test_sunaudiodev
         test_sundry
         """,
@@ -875,6 +880,7 @@
         test_pyexpat
         test_queue
         test_sax
+        test_sqlite
         test_sunaudiodev
         test_sundry
         test_thread
@@ -915,6 +921,7 @@
         test_pty
         test_pwd
         test_strop
+        test_sqlite
         test_sunaudiodev
         test_sundry
         test_thread
@@ -944,6 +951,7 @@
         test_ntpath
         test_ossaudiodev
         test_poll
+        test_sqlite
         test_sunaudiodev
         """,
     'sunos5':
@@ -962,6 +970,7 @@
         test_imgfile
         test_linuxaudiodev
         test_openpty
+        test_sqlite
         test_zipfile
         test_zlib
         """,
@@ -988,6 +997,7 @@
         test_openpty
         test_pyexpat
         test_sax
+        test_sqlite
         test_sunaudiodev
         test_zipfile
         test_zlib
@@ -1013,6 +1023,7 @@
         test_poll
         test_popen2
         test_resource
+        test_sqlite
         test_sunaudiodev
         """,
     'cygwin':
@@ -1034,6 +1045,7 @@
         test_nis
         test_ossaudiodev
         test_socketserver
+        test_sqlite
         test_sunaudiodev
         """,
     'os2emx':
@@ -1060,6 +1072,7 @@
         test_pty
         test_resource
         test_signal
+        test_sqlite
         test_sunaudiodev
         """,
     'freebsd4':
@@ -1086,6 +1099,7 @@
         test_scriptpackages
         test_socket_ssl
         test_socketserver
+        test_sqlite
         test_sunaudiodev
         test_tcl
         test_timeout
@@ -1115,6 +1129,7 @@
         test_macostools
         test_nis
         test_ossaudiodev
+        test_sqlite
         test_sunaudiodev
         test_tcl
         test_winreg
@@ -1147,6 +1162,7 @@
         test_plistlib
         test_scriptpackages
         test_tcl
+        test_sqlite
         test_sunaudiodev
         test_unicode_file
         test_winreg

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Apr  1 02:57:31 2006
@@ -489,6 +489,11 @@
 Library
 -------
 
+- Added the sqlite3 package. This is based on pysqlite2.1.3, and provides
+  a DB-API interface in the standard library. You'll need sqlite 3.2.2 or
+  later to build this - if you have an earlier version, the C extension 
+  module will not be built.
+
 - Bug #1460340: ``random.sample(dict)`` failed in various ways.  Dicts
   aren't officially supported here, and trying to use them will probably
   raise an exception some day.  But dicts have been allowed, and "mostly

Modified: python/trunk/setup.py
==============================================================================
--- python/trunk/setup.py	(original)
+++ python/trunk/setup.py	Sat Apr  1 02:57:31 2006
@@ -689,6 +689,81 @@
             dblibs = []
             dblib_dir = None
 
+        # The sqlite interface
+
+        # We hunt for "#define SQLITE_VERSION_NUMBER nnnnn"
+        # We need to find a version >= 3002002 (> sqlite version 3.2.2)
+        sqlite_incdir = sqlite_libdir = None
+        sqlite_inc_paths = [ '/usr/include', 
+                             '/usr/include/sqlite',
+                             '/usr/include/sqlite3',
+                             '/usr/local/include',
+                             '/usr/local/include/sqlite',
+                             '/usr/local/include/sqlite3',
+                           ]
+        MIN_SQLITE_VERSION = 3002002
+        for d in sqlite_inc_paths + inc_dirs:
+            f = os.path.join(d, "sqlite3.h")
+            if os.path.exists(f):
+                if db_setup_debug: print "found %s"%f
+                f = open(f).read()
+                m = re.search(r"#define\WSQLITE_VERSION_NUMBER\W(\d+)", f)
+                if m:
+                    sqlite_version = int(m.group(1))
+                    if sqlite_version >= MIN_SQLITE_VERSION:
+                        # we win!
+                        print "%s/sqlite3.h: version %s"%(d, sqlite_version)
+                        sqlite_incdir = d
+                        break
+                    else:
+                        if db_setup_debug: 
+                            print "%s: version %d is too old, need >= %s"%(d,
+                                        sqlite_version, MIN_SQLITE_VERSION)
+        
+        if sqlite_incdir:
+            sqlite_dirs_to_check = [
+                os.path.join(sqlite_incdir, '..', 'lib64'),
+                os.path.join(sqlite_incdir, '..', 'lib'),
+                os.path.join(sqlite_incdir, '..', '..', 'lib64'),
+                os.path.join(sqlite_incdir, '..', '..', 'lib'),
+            ]
+            sqlite_libfile = self.compiler.find_library_file(
+                                sqlite_dirs_to_check + lib_dirs, 'sqlite3')
+            sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))]
+
+        if sqlite_incdir and sqlite_libdir:
+            sqlite_srcs = ['_sqlite/adapters.c',
+                '_sqlite/cache.c',
+                '_sqlite/connection.c',
+                '_sqlite/converters.c',
+                '_sqlite/cursor.c',
+                '_sqlite/microprotocols.c',
+                '_sqlite/module.c',
+                '_sqlite/prepare_protocol.c',
+                '_sqlite/row.c',
+                '_sqlite/statement.c',
+                '_sqlite/util.c', ]
+
+            PYSQLITE_VERSION = "2.1.3"
+            sqlite_defines = []
+            if sys.platform != "win32":
+                sqlite_defines.append(('PYSQLITE_VERSION', 
+                                        '"%s"' % PYSQLITE_VERSION))
+            else:
+                sqlite_defines.append(('PYSQLITE_VERSION', 
+                                        '\\"'+PYSQLITE_VERSION+'\\"'))
+            sqlite_defines.append(('PY_MAJOR_VERSION', 
+                                        str(sys.version_info[0])))
+            sqlite_defines.append(('PY_MINOR_VERSION', 
+                                        str(sys.version_info[1])))
+
+            exts.append(Extension('_sqlite3', sqlite_srcs,
+                                  define_macros=sqlite_defines,
+                                  include_dirs=["Modules/_sqlite", 
+                                                sqlite_incdir],
+                                  library_dirs=sqlite_libdir,
+                                  runtime_library_dirs=sqlite_libdir,
+                                  libraries=["sqlite3",]))
 
         # Look for Berkeley db 1.85.   Note that it is built as a different
         # module name so it can be included even when later versions are


More information about the Python-checkins mailing list