1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6,7} )
7 PYTHON_REQ_USE="threads(+)"
9 inherit db-use distutils-r1
11 DESCRIPTION="Python bindings for Berkeley DB"
12 HOMEPAGE="https://www.jcea.es/programacion/pybsddb.htm https://pypi.org/project/bsddb3/"
13 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
17 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-linux ~x86-linux"
30 dev-python/setuptools[${PYTHON_USEDEP}]"
32 DISTUTILS_IN_SOURCE_BUILD=1
34 python_prepare_all() {
35 # This list should be kept in sync with setup.py.
36 if [[ -z ${DB_VER} ]]; then
37 for DB_VER in 6.2 6.1 5.3 5.1 4.8 4.7; do
38 has_version "sys-libs/db:${DB_VER}" && break
43 sed -e "s/db_ver = None/db_ver = (${DB_VER%.*}, ${DB_VER#*.})/" \
44 -e "s/dblib = 'db'/dblib = '$(db_libname ${DB_VER})'/" \
45 -i setup2.py setup3.py || die
47 # Adjust test.py to look in build/lib.
48 sed -e "s/'lib.%s' % PLAT_SPEC/'lib'/" \
49 -i test2.py test3.py || die
51 distutils-r1_python_prepare_all
54 python_configure_all() {
55 # These are needed for both build and install.
56 export BERKELEYDB_DIR="${EPREFIX}/usr"
57 export BERKELEYDB_INCDIR="$(db_includedir ${DB_VER})"
58 export BERKELEYDB_LIBDIR="${EPREFIX}/usr/$(get_libdir)"
59 export YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1
63 if ! python_is_python3; then
64 local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
66 distutils-r1_python_compile
70 if python_is_python3; then
71 PYTHONPATH=Lib3 "${EPYTHON}" test3.py -v || die "Testing failed with ${EPYTHON}"
73 PYTHONPATH=Lib "${EPYTHON}" test.py -v || die "Testing failed with ${EPYTHON}"