*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / bsddb3 / bsddb3-6.2.4.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{6,7} )
7 PYTHON_REQ_USE="threads(+)"
8
9 inherit db-use distutils-r1
10
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"
14
15 LICENSE="BSD"
16 SLOT="0"
17 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-linux ~x86-linux"
18
19 RDEPEND="
20         <sys-libs/db-6.3:=
21         || (
22                 sys-libs/db:6.2
23                 sys-libs/db:6.1
24                 sys-libs/db:5.3
25                 sys-libs/db:5.1
26                 sys-libs/db:4.8
27                 sys-libs/db:4.7
28         )"
29 DEPEND="${RDEPEND}
30         dev-python/setuptools[${PYTHON_USEDEP}]"
31
32 DISTUTILS_IN_SOURCE_BUILD=1
33
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
39                 done
40         fi
41
42         # Force version.
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
46
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
50
51         distutils-r1_python_prepare_all
52 }
53
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
60 }
61
62 python_compile() {
63         if ! python_is_python3; then
64                 local -x CFLAGS="${CFLAGS} -fno-strict-aliasing"
65         fi
66         distutils-r1_python_compile
67 }
68
69 python_test() {
70         if python_is_python3; then
71                 PYTHONPATH=Lib3 "${EPYTHON}" test3.py -v || die "Testing failed with ${EPYTHON}"
72         else
73                 PYTHONPATH=Lib "${EPYTHON}" test.py -v || die "Testing failed with ${EPYTHON}"
74         fi
75 }