Slight reordering of directories searched for BerkDB libs and include files.
Push /usr/... further down the list - always check /usr/local/... before
/usr/...

Doubt this will help with http://python.org/sf/589427 or not, but these
changes were prompted by my investigation of that bug report.  I wasn't able
to reproduce that problem though
diff --git a/setup.py b/setup.py
index 03a5c20..c78ebc9 100644
--- a/setup.py
+++ b/setup.py
@@ -442,6 +442,7 @@
                                 '/usr/local/BerkeleyDB.4.2/lib',
                                 '/usr/local/BerkeleyDB.4.1/lib',
                                 '/usr/local/BerkeleyDB.4.0/lib',
+                                '/usr/local/lib',
                                 '/usr/lib',
                                 '/opt/sfw',
                                 '/sw/lib',
@@ -451,10 +452,10 @@
                                 '/usr/local/BerkeleyDB.4.2/include',
                                 '/usr/local/BerkeleyDB.4.1/include',
                                 '/usr/local/BerkeleyDB.4.0/include',
-                                '/usr/include/db3',
+                                '/usr/local/include/db3',
                                 '/opt/sfw/include/db3',
                                 '/sw/include/db3',
-                                '/usr/local/include/db3',
+                                '/usr/include/db3',
                                 ),
                     'incs': ('db_185.h',)},
             'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db-3.0'),
@@ -462,34 +463,44 @@
                                 '/usr/local/BerkeleyDB.3.2/lib',
                                 '/usr/local/BerkeleyDB.3.1/lib',
                                 '/usr/local/BerkeleyDB.3.0/lib',
-                                '/usr/lib',
+                                '/usr/local/lib',
                                 '/opt/sfw',
                                 '/sw/lib',
+                                '/usr/lib',
                                 '/lib',
                                 ),
                     'incdirs': ('/usr/local/BerkeleyDB.3.3/include',
                                 '/usr/local/BerkeleyDB.3.2/include',
                                 '/usr/local/BerkeleyDB.3.1/include',
                                 '/usr/local/BerkeleyDB.3.0/include',
-                                '/usr/include/db3',
+                                '/usr/local/include/db3',
                                 '/opt/sfw/include/db3',
                                 '/sw/include/db3',
-                                '/usr/local/include/db3',
+                                '/usr/include/db3',
                                 ),
                     'incs': ('db_185.h',)},
             'db2': {'libs': ('db2',),
-                    'libdirs': ('/usr/lib', '/sw/lib', '/lib'),
-                    'incdirs': ('/usr/include/db2',
-                                '/usr/local/include/db2', '/sw/include/db2'),
+                    'libdirs': ('/usr/local/lib',
+                                '/sw/lib',
+                                '/usr/lib',
+                                '/lib'),
+                    'incdirs': ('/usr/local/include/db2',
+                                '/sw/include/db2',
+                                '/usr/include/db2'),
                     'incs': ('db_185.h',)},
             # if you are willing to risk hash db file corruption you can
             # uncomment the lines below for db1.  Note that this will affect
             # not only the bsddb module, but the dbhash and anydbm modules
-            # as well.  you have been warned!!!
+            # as well.  YOU HAVE BEEN WARNED!!!
             ##'db1': {'libs': ('db1', 'db'),
-            ##        'libdirs': ('/usr/lib', '/sw/lib', '/lib'),
-            ##        'incdirs': ('/usr/include/db1', '/usr/local/include/db1',
-            ##                    '/usr/include', '/usr/local/include'),
+            ##        'libdirs': ('/usr/local/lib',
+            ##                    '/sw/lib',
+            ##                    '/usr/lib',
+            ##                    '/lib'),
+            ##        'incdirs': ('/usr/local/include/db1',
+            ##                    '/usr/local/include',
+            ##                    '/usr/include/db1',
+            ##                    '/usr/include'),
             ##        'incs': ('db.h',)},
             }