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 )
8 inherit check-reqs distutils-r1
10 DESCRIPTION="Python driver for MongoDB"
11 HOMEPAGE="https://github.com/mongodb/mongo-python-driver https://pypi.org/project/pymongo/"
12 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
16 KEYWORDS="amd64 ~hppa x86"
17 IUSE="doc kerberos test"
18 RESTRICT="!test? ( test )"
21 kerberos? ( dev-python/pykerberos[${PYTHON_USEDEP}] )
25 dev-python/setuptools[${PYTHON_USEDEP}]
26 doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
28 dev-python/nose[${PYTHON_USEDEP}]
29 >=dev-db/mongodb-2.6.0
32 DISTUTILS_IN_SOURCE_BUILD=1
36 # During the tests, database size reaches 1.5G.
37 local CHECKREQS_DISK_BUILD=1536M
51 python_compile_all() {
54 sphinx-build doc html || die
59 # Yes, we need TCP/IP for that...
65 local dbpath=${TMPDIR}/mongo.db
66 local logpath=${TMPDIR}/mongod.log
68 # Now, the hard part: we need to find a free port for mongod.
69 # We're just trying to run it random port numbers and check the log
70 # for bind errors. It shall be noted that 'mongod --fork' does not
71 # return failure when it fails to bind.
73 mkdir -p "${dbpath}" || die
75 ebegin "Trying to start mongod on port ${DB_PORT}"
78 mongod --dbpath "${dbpath}" --smallfiles --nojournal \
79 --bind_ip ${DB_IP} --port ${DB_PORT} \
80 --unixSocketPrefix "${TMPDIR}" \
81 --logpath "${logpath}" --fork \
84 # Now we need to check if the server actually started...
85 if [[ ${?} -eq 0 && -S "${TMPDIR}"/mongodb-${DB_PORT}.sock ]]; then
89 elif grep -q 'Address already in use' "${logpath}"; then
90 # ay, someone took our port!
96 eerror "Unable to start mongod for tests. See the server log:"
98 die "Unable to start mongod for tests."
103 #https://jira.mongodb.org/browse/PYTHON-521, py2.[6-7] has intermittent failure with gevent
104 pushd "${BUILD_DIR}"/../ > /dev/null
105 if [[ "${EPYTHON}" == python3* ]]; then
106 2to3 --no-diffs -w test
108 DB_PORT2=$(( DB_PORT + 1 )) DB_PORT3=$(( DB_PORT + 2 )) esetup.py test || failed=1
110 mongod --dbpath "${dbpath}" --shutdown || die
112 [[ ${failed} ]] && die "Tests fail with ${EPYTHON}"
114 rm -rf "${dbpath}" || die
117 python_install_all() {
118 use doc && local HTML_DOCS=( html/. )
120 distutils-r1_python_install_all