Skip to content

Instantly share code, notes, and snippets.

@ryanolf
Created May 6, 2013 23:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ryanolf/5529070 to your computer and use it in GitHub Desktop.
Save ryanolf/5529070 to your computer and use it in GitHub Desktop.
Installing pyBSDDB (bsddb3) 5.3.0 on Windows
@echo off
setlocal
rem Update the local copy of the DB libs and stuff.
rem This copies the necessary libs and headers and exe
rem files into the python module tree.
rem Set DBDIR to the base directory of the DB source.
rem e.g. it should have the folder "build_windows" in it.
set DBDIR=c:\Users\yourname\Downloads\db-5.3.21\db-5.3.21
rem set DBDIR=f:\db-4.0.14
mkdir db
mkdir db\include
mkdir db\lib
mkdir db\bin
copy /v %DBDIR%\build_windows\db.h db\include
copy /v %DBDIR%\build_windows\Win32\Debug\*.lib db\lib
copy /v "%DBDIR%\build_windows\Win32\Static Debug\*.lib" db\lib
copy /v %DBDIR%\build_windows\Win32\Release\*.lib db\lib
copy /v "%DBDIR%\build_windows\Win32\Static Release\*.lib" db\lib
copy /v %DBDIR%\build_windows\Win32\Release\*.dll db\bin
copy /v %DBDIR%\build_windows\Win32\Release\*.exe db\bin
endlocal
1. Download Oracle Berkeley DB source: http://download.oracle.com/otn/berkeley-db/db-5.3.21.zip
2. Follow directions for building for Windows with Visual Studio (e.g. 2012), with a few modifications.
a. You can use VS 2012, just update the solution when prompted. The solution to use is Berkeley_DB_vs2010.sln in the 'build_windows' directory.
b. Select "Release" from the pull-down menu, and then Build Solution. Let it build.
c. Select "Release Static" from the pull-down menu.
i. You need to change the runtime library configuration to use /MD (Multi-Threaded DLL) instead of /MT. Right click on the "db" project, open Properties Dialog. Under C/C++ -> Code Generation change Runtime Library to /MD.
ii. You can repeat this on db_small, db_sql, db_stl... but I haven't tested if this is necessary. I did it just to be safe.
d. Build the solution with the modified "Release Static" configuration.
3. Modify the attached updatedb.bat file to point to the location of your Berkeley DB files. Run this batch file in the pybsddb source directory (which has the setup.py file). This will copy the necessary Berkeley DB files into the pyBSDDB tree.
4. Patch the setup2.py file with the attached file setup2.py.diff. "patch < setup2.py.diff"
5. If you are using Visual Studio 2012, you need to tell python to use its compiler. Run the attached file useVS2012.bat to do this.
6. Now you should be all set to build and install bsddb3. Run "python setup.py install" and let the magic happen.
--- setup2.py Mon May 6 13:54:00 2013
+++ ../../bsddb3-5.3.0-orig/bsddb3-5.3.0/setup2.py Mon May 6 15:06:19 2013
@@ -314,8 +314,6 @@
# uses "Multithreaded DLL" and "Debug Multithreaded DLL" (/MD and /MDd)
# settings as appropriate to build .lib file (the db_static project).
- db_ver_list = ((5, 3), (5, 2), (5, 1), (5, 0),
- (4, 8), (4, 7), (4, 6), (4, 5), (4, 4), (4, 3))
incdir = 'db/include'
libdir = 'db/lib'
@@ -330,15 +328,14 @@
continue
fullverstr = match.group(1)
ver = fullverstr[0] + fullverstr[2] # 31 == 3.1, 32 == 3.2, etc.
- assert (int(fullverstr[0]), int(fullverstr[2])) in db_ver_list, (
+ assert (fullverstr[0], fullverstr[2]) in db_ver_list, (
"pybsddb untested with this Berkeley DB version", ver)
print 'Detected Berkeley DB version', ver, 'from db.h'
- dep_libs = ['ws2_32', 'Advapi32'] # WIN32 dependencies
if debug:
- libname = ['libdb%ssd' % ver] + dep_libs # Debug, static
+ libname = ['libdb%ssd' % ver] # Debug, static
else:
- libname = ['libdb%ss' % ver] + dep_libs # Release, static
+ libname = ['libdb%ss' % ver] # Release, static
utils = [("bsddb3/utils",
["db/bin/db_archive.exe",
"db/bin/db_checkpoint.exe",
@@ -398,7 +395,7 @@
include_dirs = [ incdir ],
define_macros = [('PYBSDDB_STANDALONE', 1)],
library_dirs = [ libdir ],
- # runtime_library_dirs = [ libdir ],
+ runtime_library_dirs = [ libdir ],
libraries = libname,
extra_link_args = lflags_arg,
)],
SET VS90COMNTOOLS=%VS110COMNTOOLS%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment