|
Line 0
Link Here
|
| 0 |
- |
1 |
# Copyright 1999-2018 Gentoo Foundation |
|
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
|
| 4 |
EAPI=7 |
| 5 |
|
| 6 |
PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy ) |
| 7 |
ES_VERSION="6.4.0" |
| 8 |
|
| 9 |
inherit distutils-r1 |
| 10 |
|
| 11 |
MY_PN=${PN/-py/} |
| 12 |
DESCRIPTION="official Python low-level client for Elasticsearch" |
| 13 |
HOMEPAGE="https://github.com/elastic/elasticsearch-py" |
| 14 |
SRC_URI="https://github.com/elasticsearch/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz |
| 15 |
test? ( https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-${ES_VERSION}.tar.gz )" |
| 16 |
|
| 17 |
LICENSE="Apache-2.0" |
| 18 |
SLOT="0" |
| 19 |
KEYWORDS="~amd64 ~x86" |
| 20 |
IUSE="examples doc test" |
| 21 |
|
| 22 |
# tests fail in chroot |
| 23 |
# https://github.com/elastic/elasticsearch/issues/12018 |
| 24 |
RESTRICT="test" |
| 25 |
|
| 26 |
RDEPEND=">=dev-python/urllib3-1.21.1[${PYTHON_USEDEP}]" |
| 27 |
|
| 28 |
DEPEND="dev-python/setuptools[${PYTHON_USEDEP}] |
| 29 |
>=dev-python/sphinx-1.3.1-r1[${PYTHON_USEDEP}] |
| 30 |
test? ( ${RDEPEND} |
| 31 |
>=dev-python/requests-2.4.0[${PYTHON_USEDEP}] |
| 32 |
<dev-python/requests-3.0.0[${PYTHON_USEDEP}] |
| 33 |
dev-python/nose[${PYTHON_USEDEP}] |
| 34 |
dev-python/coverage[${PYTHON_USEDEP}] |
| 35 |
dev-python/mock[${PYTHON_USEDEP}] |
| 36 |
dev-python/pretty-yaml[${PYTHON_USEDEP}] |
| 37 |
dev-python/nosexcover[${PYTHON_USEDEP}] |
| 38 |
virtual/jre:1.8 )" |
| 39 |
|
| 40 |
python_prepare_all() { |
| 41 |
# 643684 |
| 42 |
sed -i -e /urllib3/d setup.py || die |
| 43 |
|
| 44 |
distutils-r1_python_prepare_all |
| 45 |
} |
| 46 |
|
| 47 |
python_compile_all() { |
| 48 |
emake -C docs -j1 man $(usex doc html "") |
| 49 |
} |
| 50 |
|
| 51 |
# FEATURES="test -usersandbox" emerge dev-python/elasticsearch-py |
| 52 |
python_test() { |
| 53 |
ES="${WORKDIR}/elasticsearch-${ES_VERSION}" |
| 54 |
ES_PORT="25124" |
| 55 |
ES_INSTANCE="gentoo-es-py-test" |
| 56 |
ES_LOG="${ES}/logs/${ES_INSTANCE}.log" |
| 57 |
PID="${ES}/elasticsearch.pid" |
| 58 |
|
| 59 |
# run Elasticsearch instance on custom port |
| 60 |
sed -i "s/#http.port: 9200/http.port: ${ES_PORT}/g; \ |
| 61 |
s/#cluster.name: my-application/cluster.name: ${ES_INSTANCE}/g" \ |
| 62 |
"${ES}/config/elasticsearch.yml" || die |
| 63 |
|
| 64 |
# start local instance of elasticsearch |
| 65 |
"${ES}"/bin/elasticsearch -d -p "${PID}" -Epath.repo=/ || die |
| 66 |
|
| 67 |
local i |
| 68 |
local es_started=0 |
| 69 |
for i in {1..20}; do |
| 70 |
grep -q "started" ${ES_LOG} 2> /dev/null |
| 71 |
if [[ $? -eq 0 ]]; then |
| 72 |
einfo "Elasticsearch started" |
| 73 |
es_started=1 |
| 74 |
eend 0 |
| 75 |
break |
| 76 |
elif grep -q 'BindException\[Address already in use\]' "${ES_LOG}" 2>/dev/null; then |
| 77 |
eend 1 |
| 78 |
eerror "Elasticsearch already running" |
| 79 |
die "Cannot start Elasticsearch for tests" |
| 80 |
else |
| 81 |
einfo "Waiting for Elasticsearch" |
| 82 |
eend 1 |
| 83 |
sleep 2 |
| 84 |
continue |
| 85 |
fi |
| 86 |
done |
| 87 |
|
| 88 |
[[ $es_started -eq 0 ]] && die "Elasticsearch failed to start" |
| 89 |
|
| 90 |
export TEST_ES_SERVER="localhost:${ES_PORT}" |
| 91 |
esetup.py test || die |
| 92 |
|
| 93 |
pkill -F ${PID} |
| 94 |
} |
| 95 |
|
| 96 |
python_install_all() { |
| 97 |
use doc && HTML_DOCS=( docs/_build/html/. ) |
| 98 |
use examples && dodoc -r example |
| 99 |
doman docs/_build/man/* |
| 100 |
distutils-r1_python_install_all |
| 101 |
} |