发现Berkeley DB是单文件的key value 的数据库,目前被Oracle 拥有,使用
AGPL3 commercial license.
ubuntu 下安装libdb5.3-dev;Mac 下安装brew install berkeley-db。python driver 使用 .
由于安装PyBSDDB出现了一些问题,需要设置环境变量(后文详述),于是我决定从源码开始编译。
-
wget
-
tar zxvf db-6.0.30.tar.gz -C /opt
-
cd /opt/db-6.0.30/build_unix
-
../dist/configure --prefix=/usr/local/berkeley-db/ --enable-cxx && make
-
sudo make install
pip install bsddb3 出现错误:
(suggestion: try the --berkeley-db=/path/to/bsddb option)
pip install --berkeley-db=/usr/local/berkeley-db bsddb3 依然出错。
'pip help install'后,使用如下命令,feed it to package's setup.py,可还是这个报错。
pip install --install-option="--berkeley-db=/usr/local/berkeley-db/" bsddb3
这里 详细讲述了这个错误,
指出Mac下可以 brew install berkeley-db --without-java 就不用安装JDK了。
下面是分析:
-
Still nothing. If we look at the output, we can see that the install is failing on running 'python setup.py egg_info'. If we go into the build directory and run that manually, it suggests we add the --berkeley-db option. When we do that, it seems to work, but how do we get pip to call it with that option?
-
It turns out, we can't. At least, not that I can figure out. You can pass parameters to 'setup.py build' through pip by the --install-option flag, but not the 'setup.py egg_info'. It's just not baked in there. Horrible.
-
At this point, our options are, fix pip, or fix the bsddb3 setup.py process. Well, neither are especially appealing options. If I ever need to do this again, or do it on another machine, or whatever, that would be a mess. There's gotta be a better way.
-
Thinking back to the 90s (I know, right?), when you tried to build a library that had a dependency on another library, you could specify the location of that dependency through a similar flag, like --my-library-path=/blah. This was almost always a convenience shortcut for setting an environment variable, MY_LIBRARY_PATH=/blah. Let's see if that's the case here. If we go into the egg and grep around for 'berkeley-db', we find the following segment:
if os.name == 'posix':
# Allow setting the DB dir and additional link flags either in
# the environment or on the command line.
# First check the environment...
BERKELEYDB_INCDIR = os.environ.get('BERKELEYDB_INCDIR', '')
BERKELEYDB_LIBDIR = os.environ.get('BERKELEYDB_LIBDIR', '')
BERKELEYDB_DIR = os.environ.get('BERKELEYDB_DIR', '')
LFLAGS = os.environ.get('LFLAGS', [])
LIBS = os.environ.get('LIBS', [])
# ...then the command line.
# Handle --berkeley-db=[PATH] and --lflags=[FLAGS]
args = sys.argv[:]
for arg in args:
if arg.startswith('--berkeley-db-incdir='):
BERKELEYDB_INCDIR = arg.split('=')[1]
sys.argv.remove(arg)
if arg.startswith('--berkeley-db-libdir='):
BERKELEYDB_LIBDIR = arg.split('=')[1]
sys.argv.remove(arg)
if arg.startswith('--berkeley-db='):
BERKELEYDB_DIR = arg.split('=')[1]
sys.argv.remove(arg)
YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1 BERKELEYDB_DIR=/usr/local/berkeley-db/ pip install bsddb3
问题解决
阅读(4331) | 评论(1) | 转发(0) |