[pybsddb] How to install bsdbb?

Jesus Cea jcea at jcea.es
Thu Oct 28 03:36:39 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 27/10/10 20:31, alanpae at ilkda.com wrote:
>>>> The right approach would be to install bsddb3 (pybsddb 5.0.0 can be
>>>> compiled against 5.1.19 library with a cpmmand line argument, like you
>>>> do) and then write the three lines import trick already described in a
>>>> previous message.
> 
> Ok, my mistake.  I installed bsddb3 with the stock version of Python
> that comes with OpenSolaris and forgot to add it to the one that I
> compiled myself.
> 
> So, I added it to both of them and the three line fix works but it's
> dynamic.  Is there a way to make it a static fix?  

bsddb and bsddb3 are different namespaces because one is the library in
python standard lib, and the other is an standalone project (more
modern). You could install "bsddb3" over "bsddb", but you could broke
when upgrading python again.

I think the three line dynamic patch is the most easy and foolproof
approach. More, it is explicit, so you, as the programmer, know exactly
what is going on. Remember the Zen of python: "explicit is better than
implicit".

Another approach would be to customize "site.py". That would be fully
transparent, but two years in the future you could wonder what is going
on when somethings doesn't work. And you have to remember to repeat the
trick when you upgrade Python. Magic usually backfires.

I would do the 3 lines myself.

In fact I actually do this in my projects:

"""
# Try to use the newest
# BerkeleyDB bindings available
try :
    import bsddb
except :
    bsddb=None
try :
    import bsddb3
except :
    if not bsddb :
        raise RuntimeError("You need a BerkeleyDB instalation, \
                            and the corresponding python bindings")
    bsddb3=bsddb
if not bsddb :
    bsddb=bsddb3
if bsddb3.__version__.split(".") >= bsddb.__version__.split(".") :
    bsddb=bsddb3

"""

Here I import both libraries, then check which one is the most modern
and use it. In your case you would have to add the three line patch too,
since you are using an external module.

If the library you are using is actively maintained, I would suggest you
to write the author requesting to test bsddb3 presence and, if the
version is more modern, use it instead of stock bsddb.

>> "My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
> 
> Cute.

This is a remaining from 1990 or so :-).

- -- 
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
.                              _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQCVAwUBTMjTp5lgi5GaxT1NAQIZOwP/UfAJUrbufOynvMezTwe1AEXDBxFoEEUq
JL0HD7Poo2WMJkAU+jj1mKtSspSrBjLGFQU7QWCHi7YQnlEKeYMJAH3xSF/UI5sb
deds2KmU8IM4Y1+mBHUeBoONRVchfJ8jvhwHQKZprZnBsszVpvsPQw7mvKYGHM9O
NLC7BiJh/Y4=
=IzWD
-----END PGP SIGNATURE-----


More information about the pybsddb mailing list