summaryrefslogtreecommitdiff
blob: b87cc76195365b2383aefb9475ee88505911d0f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-python/pylint/pylint-0.18.1-r1.ebuild,v 1.7 2010/02/07 20:51:49 pva Exp $

EAPI="2"
SUPPORT_PYTHON_ABIS="1"

inherit eutils distutils

DESCRIPTION="a tool to check if a Python module satisfies a coding standard"
HOMEPAGE="http://www.logilab.org/projects/pylint/"
SRC_URI="ftp://ftp.logilab.org/pub/${PN}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ~ia64 ppc ~sparc x86 ~amd64-linux ~x86-linux ~x86-macos"
IUSE="doc examples test tk"

DEPEND=">=dev-python/logilab-common-0.44.0
	>=dev-python/astng-0.19.0"
RDEPEND="${DEPEND}
	dev-lang/python[tk?]"
RESTRICT_PYTHON_ABIS="3.*"

src_prepare() {
	distutils_src_prepare
	epatch "${FILESDIR}/${P}-utils.py.patch"
}

src_test() {
	testing() {
		local lpath="${T}/test/lib/python"
		local tpath=""

		rm -fr "${lpath}"

		# Create testdir and copy pylint into it for testing purpose.
		mkdir -p "${lpath}/logilab" || die
		PYTHONPATH="${lpath}" "$(PYTHON)" setup.py build -b "build-${PYTHON_ABI}" install --home="${T}/test" || die "test copy failed"

		# To support test w/o setuptools.
		if [[ -d "${lpath}/${PN}" ]]; then
			tpath="${lpath}/${PN}"
		else
			tpath="${lpath}/${P}-py${PYTHON_ABI}.egg/${PN}"
		fi

		# Copy pylint unittest and logilab-{common,astng} into our temporary test
		# dir.
		cp -r test/ ${tpath} || die "copy tests failed"
		cp -r "$(python_get_sitedir)/logilab/"{common,astng} "${lpath}/logilab" || die "copying logilab-{common,astng} failed!"

		pushd "${tpath}" >/dev/null || die
		PYTHONPATH="${lpath}" pytest -v || die "tests failed"
		popd >/dev/null || die
	}
	python_execute_function testing
}

src_install() {
	distutils_src_install

	doman man/{pylint,pyreverse}.1 || die "doman failed"
	dodoc doc/FAQ.txt || die "dodoc failed"

	if use doc; then
		dodoc doc/*.txt || die "dodoc failed"
	fi

	if use examples; then
		docinto examples
		dodoc examples/* || die "dodoc failed"
	fi
}

pkg_postinst() {
	distutils_pkg_postinst

	if ! has_version dev-lang/python[tk]; then
		ewarn "dev-lang/python has been built without tk support,"
		ewarn "${PN}-gui doesn't work without Tkinter so if you really need it"
		ewarn "re-install dev-lang/python with tk useflag enabled."
	fi
}