92e458928e6adce8cd9096ae9a8e9461bbb46e82
[gentoo.git] / dev-python / pylibmc / pylibmc-1.6.1-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python3_{6,7,8} )
6
7 inherit distutils-r1
8
9 DESCRIPTION="Libmemcached wrapper written as a Python extension"
10 HOMEPAGE="http://sendapatch.se/projects/pylibmc/ https://pypi.org/project/pylibmc/"
11 # One image is missing from the doc at PyPI
12 # https://github.com/lericson/pylibmc/pull/221
13 SRC_URI="https://github.com/lericson/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz"
14
15 LICENSE="BSD"
16 SLOT="0"
17 KEYWORDS="~alpha amd64 ~arm64 ~ppc ~ppc64 x86"
18 IUSE="doc test"
19
20 # implementations to use for building docs, separate from PYTHON_COMPAT since
21 # dev-python/sphinx might not be available everywhere
22 DOCS_PYTHON_COMPAT=( python{2_7,3_{6,7}} )
23
24 RDEPEND=">=dev-libs/libmemcached-0.32"
25 # Older sphinx versions fail to compile the doc
26 # https://github.com/sphinx-doc/sphinx/issues/3266
27 BDEPEND="${RDEPEND}
28         doc? ( $(python_gen_cond_dep '
29                 >=dev-python/sphinx-1.5.1-r1[${PYTHON_USEDEP}]' "${DOCS_PYTHON_COMPAT[@]}")
30         )
31         test? (
32                 net-misc/memcached
33                 dev-python/nose[${PYTHON_USEDEP}]
34         )"
35
36 RESTRICT="!test? ( test )"
37
38 REQUIRED_USE="doc? ( || ( $(python_gen_useflags "${DOCS_PYTHON_COMPAT[@]}") ) )"
39
40 PATCHES=(
41         "${FILESDIR}/pylibmc-1.6.1-fix-test-failures-r1.patch"
42 )
43
44 pkg_setup() {
45         use doc && DISTUTILS_ALL_SUBPHASE_IMPLS=( "${DOCS_PYTHON_COMPAT[@]}" )
46 }
47
48 python_prepare_all() {
49         sed -e "/with-info=1/d" -i setup.cfg || die
50
51         # some amazon thing, expects to be in AWS
52         rm tests/test_autoconf.py || die
53         distutils-r1_python_prepare_all
54 }
55
56 python_compile_all() {
57         if use doc; then
58                 # This variable is added to sys.path
59                 # but it does not seem to be useful
60                 PYLIBMC_DIR="." emake -C docs
61                 HTML_DOCS=( docs/_build/html/. )
62         fi
63 }
64
65 python_test() {
66         distutils_install_for_testing
67         memcached -d -p 11219 -u nobody -l localhost -P "${T}/m.pid" || die
68         MEMCACHED_PORT=11219 nosetests -v
69         local ret=${?}
70         kill "$(<"${T}/m.pid")" || die
71         [[ ${ret} == 0 ]] || die "Tests fail with ${EPYTHON}!"
72 }