Merge remote-tracking branch 'github/pr/108'
[gentoo.git] / dev-python / bsddb3 / bsddb3-6.1.0.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
7
8 inherit db-use distutils-r1 multilib
9
10 DESCRIPTION="Python bindings for Berkeley DB"
11 HOMEPAGE="http://www.jcea.es/programacion/pybsddb.htm https://pypi.python.org/pypi/bsddb3"
12 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
13
14 LICENSE="BSD"
15 SLOT="0"
16 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux"
17 IUSE="doc"
18
19 RDEPEND="
20         >=sys-libs/db-4.7
21         <sys-libs/db-6.2:=
22 "
23 DEPEND="${RDEPEND}
24         dev-python/setuptools[${PYTHON_USEDEP}]"
25
26 DISTUTILS_IN_SOURCE_BUILD=1
27
28 src_prepare() {
29         # This list should be kept in sync with setup.py.
30         if [[ -z ${DB_VER} ]]; then
31                 for DB_VER in 6.1 6.0 5.3 5.2 5.1 5.0 4.8 4.7; do
32                         has_version "sys-libs/db:${DB_VER}" && break
33                 done
34         fi
35
36         # Force version.
37         sed -e "s/db_ver = None/db_ver = (${DB_VER%.*}, ${DB_VER#*.})/" \
38                 -e "s/dblib = 'db'/dblib = '$(db_libname ${DB_VER})'/" \
39                 -i setup2.py setup3.py || die
40
41         # Adjust test.py to look in build/lib.
42         sed -e "s/'lib.%s' % PLAT_SPEC/'lib'/" \
43                 -i test2.py test3.py || die
44
45         distutils-r1_src_prepare
46 }
47
48 src_configure() {
49         # These are needed for both build and install.
50         export BERKELEYDB_DIR="${EPREFIX}/usr"
51         export BERKELEYDB_INCDIR="$(db_includedir ${DB_VER})"
52         export BERKELEYDB_LIBDIR="${EPREFIX}/usr/$(get_libdir)"
53         export YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1
54 }
55
56 python_compile() {
57         if ! python_is_python3; then
58                 local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
59         fi
60         distutils-r1_python_compile
61 }
62
63 python_test() {
64         if python_is_python3; then
65                 PYTHONPATH=Lib3 "${PYTHON}" test3.py -v || die "Testing failed with ${EPYTHON}"
66         else
67                 PYTHONPATH=Lib "${PYTHON}" test.py -v || die "Testing failed with ${EPYTHON}"
68         fi
69 }
70
71 python_install_all() {
72         use doc && local HTML_DOCS=( docs/html/. )
73         distutils-r1_python_install_all
74 }