*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / pylint / pylint-1.8.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 distutils-r1 eutils
10
11 DESCRIPTION="Python code static checker"
12 HOMEPAGE="https://www.logilab.org/project/pylint
13         https://pypi.org/project/pylint/
14         https://github.com/pycqa/pylint"
15 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
16
17 LICENSE="GPL-2"
18 SLOT="0"
19 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~ppc ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
20 IUSE="doc examples test"
21 RESTRICT="!test? ( test )"
22
23 RDEPEND="
24         >=dev-python/astroid-1.6.0[${PYTHON_USEDEP}]
25         dev-python/six[${PYTHON_USEDEP}]
26         >=dev-python/isort-4.2.5[${PYTHON_USEDEP}]
27         dev-python/mccabe[${PYTHON_USEDEP}]
28         virtual/python-singledispatch[${PYTHON_USEDEP}]
29         $(python_gen_cond_dep '
30                 dev-python/backports-functools-lru-cache[${PYTHON_USEDEP}]
31                 dev-python/configparser[${PYTHON_USEDEP}]' -2)"
32 DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]
33         doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
34         test? ( ${RDEPEND}
35                 <dev-python/pytest-4[${PYTHON_USEDEP}] )"
36
37 python_prepare_all() {
38         # remove unused dep
39         sed -i -e '/pytest-runner/d' setup.py || die
40
41         # Disable failing tests
42         # TODO: investigate if it's our fault and how can we fix it
43         sed -i -e 's/io.StringIO()/\0 if sys.version_info.major > 2 else open(os.devnull, "w")/' \
44                 -e 's/test_libmodule/_&/' \
45                 pylint/test/acceptance/test_stdlib.py || die
46         sed -i -e 's/^# pylint:.*/\0, import-error/' \
47                 pylint/test/functional/deprecated_module_py36.py || die
48         sed -i -e 's/^# pylint:.*/\0, wrong-import-order/' \
49                 pylint/test/functional/generated_members.py || die
50         sed -i -e 's/test_good_comprehension_checks/_&/' \
51                 pylint/test/functional/using_constant_test.py || die
52
53         distutils-r1_python_prepare_all
54 }
55
56 python_compile_all() {
57         # selection of straight html triggers a trivial annoying bug, we skirt it
58         use doc && PYTHONPATH="${S}" emake -e -C doc singlehtml
59 }
60
61 python_test() {
62         py.test -v || die "Tests fail with ${EPYTHON}"
63 }
64
65 python_install_all() {
66         doman man/{pylint,pyreverse}.1
67         if use examples ; then
68                 docinto examples
69                 dodoc -r examples/.
70         fi
71         use doc && local HTML_DOCS=( doc/_build/singlehtml/. )
72         distutils-r1_python_install_all
73 }
74
75 pkg_postinst() {
76         # Optional dependency on "tk" USE flag would break support for Jython.
77         optfeature "pylint-gui script requires dev-lang/python with \"tk\" USE flag enabled." 'dev-lang/python[tk]'
78 }