mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Adds basic support for BerkeleyDB 4.2.x. Compiles and passes tests; new
features in BerkeleyDB not exposed. notably: the DB_MPOOLFILE interface has not yet been wrapped in an object. Adds support for building and installing bsddb3 in python2.3 that has an older version of this module installed as bsddb without conflicts. The pybsddb.sf.net build/packaged version of the module uses a dynamicly loadable module called _pybsddb rather than _bsddb.
This commit is contained in:
parent
cec1b3f6a7
commit
41631e8f66
21 changed files with 114 additions and 71 deletions
|
@ -33,11 +33,18 @@
|
|||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
"""Support for BerkeleyDB 3.1 through 4.1.
|
||||
"""Support for BerkeleyDB 3.2 through 4.2.
|
||||
"""
|
||||
|
||||
try:
|
||||
import _bsddb
|
||||
if __name__ == 'bsddb3':
|
||||
# import _pybsddb binary as it should be the more recent version from
|
||||
# a standalone pybsddb addon package than the version included with
|
||||
# python as bsddb._bsddb.
|
||||
import _pybsddb
|
||||
_bsddb = _pybsddb
|
||||
else:
|
||||
import _bsddb
|
||||
except ImportError:
|
||||
# Remove ourselves from sys.modules
|
||||
import sys
|
||||
|
|
|
@ -37,8 +37,15 @@
|
|||
# case we ever want to augment the stuff in _db in any way. For now
|
||||
# it just simply imports everything from _db.
|
||||
|
||||
from _bsddb import *
|
||||
from _bsddb import __version__
|
||||
if __name__[:len('bsddb3.')] == 'bsddb3.':
|
||||
# import _pybsddb binary as it should be the more recent version from
|
||||
# a standalone pybsddb addon package than the version included with
|
||||
# python as bsddb._bsddb.
|
||||
from _pybsddb import *
|
||||
from _pybsddb import __version__
|
||||
else:
|
||||
from _bsddb import *
|
||||
from _bsddb import __version__
|
||||
|
||||
if version() < (3, 1, 0):
|
||||
raise ImportError, "BerkeleyDB 3.x symbols not found. Perhaps python was statically linked with an older version?"
|
||||
if version() < (3, 2, 0):
|
||||
raise ImportError, "correct BerkeleyDB symbols not found. Perhaps python was statically linked with an older version?"
|
||||
|
|
|
@ -35,12 +35,7 @@ try:
|
|||
except ImportError:
|
||||
# DictMixin is new in Python 2.3
|
||||
class DictMixin: pass
|
||||
try:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
import db
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ from types import ListType, StringType
|
|||
import cPickle as pickle
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3.db import *
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb.db import *
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3.db import *
|
||||
|
||||
|
||||
class TableDBError(StandardError):
|
||||
|
|
|
@ -26,12 +26,7 @@
|
|||
#
|
||||
from time import sleep as _sleep
|
||||
|
||||
try:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
import db
|
||||
|
||||
# always sleep at least N seconds between retrys
|
||||
_deadlock_MinSleepTime = 1.0/64
|
||||
|
|
|
@ -17,11 +17,11 @@ if 'silent' in sys.argv: # take care of old flag, just in case
|
|||
|
||||
def print_versions():
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
print
|
||||
print '-=' * 38
|
||||
print db.DB_VERSION_STRING
|
||||
|
|
|
@ -17,11 +17,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbshelve
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
@ -13,11 +13,11 @@ from pprint import pprint
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
from test_all import verbose
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ import tempfile
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, hashopen, btopen, rnopen
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, hashopen, btopen, rnopen
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, hashopen, btopen, rnopen
|
||||
|
||||
|
||||
class CompatibilityTestCase(unittest.TestCase):
|
||||
|
|
|
@ -4,11 +4,11 @@ import unittest
|
|||
import glob
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbobj
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbobj
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbobj
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
@ -9,11 +9,11 @@ from types import *
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbshelve
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
|
||||
from test_all import verbose
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbtables
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbtables
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbtables
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ import glob
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
from test_all import verbose
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ from pprint import pprint
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
from test_all import verbose
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbshelve
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
@ -19,11 +19,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
|
@ -6,11 +6,11 @@ import sys
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbshelve
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbshelve
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ from pprint import pprint
|
|||
import unittest
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
from test_all import verbose
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db
|
||||
|
||||
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ import unittest
|
|||
from test_all import verbose
|
||||
|
||||
try:
|
||||
# For Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbutils
|
||||
except ImportError:
|
||||
# For Python 2.3
|
||||
from bsddb import db, dbutils
|
||||
except ImportError:
|
||||
# For earlier Pythons w/distutils pybsddb
|
||||
from bsddb3 import db, dbutils
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue