summaryrefslogtreecommitdiff
blob: 85b3f6e4b19fbe5bfe497144f7233b7efa35125c (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/pdb2pqr/pdb2pqr-1.7.0-r2.ebuild,v 1.1 2012/05/11 07:42:54 jlec Exp $

EAPI=4

PYTHON_DEPEND="2:2.5"
SUPPORT_PYTHON_ABIS="1"
PYTHON_EXPORT_PHASE_FUNCTIONS="1"
RESTRICT_PYTHON_ABIS="2.4 3.* 2.7-pypy-*"

inherit autotools eutils fortran-2 flag-o-matic python toolchain-funcs versionator

MY_PV=$(get_version_component_range 1-2)
MY_P="${PN}-${MY_PV}"

DESCRIPTION="An automated pipeline for performing Poisson-Boltzmann electrostatics calculations"
LICENSE="BSD"
HOMEPAGE="http://pdb2pqr.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"

SLOT="0"
IUSE="doc examples opal +pdb2pka"
KEYWORDS="~amd64 ~ppc ~x86 ~amd64-linux ~x86-linux"

RDEPEND="
	virtual/fortran
	dev-python/numpy
	sci-chemistry/openbabel
	opal? ( dev-python/zsi )
	pdb2pka? ( sci-chemistry/apbs[python,-mpi] )"
DEPEND="${RDEPEND}"

S="${WORKDIR}/${MY_P}"

pkg_setup() {
	if [[ -z ${MAXATOMS} ]]; then
		einfo "If you like to have support for more then 10000 atoms,"
		einfo "export MAXATOMS=\"your value\""
	else
		einfo "Allow usage of ${MAXATOMS} during calculations"
	fi
	python_pkg_setup
}

src_prepare() {
	epatch \
		"${FILESDIR}"/${PN}-1.4.0-ldflags.patch \
		"${FILESDIR}"/${PN}-1.4.0-automagic.patch \
		"${FILESDIR}"/${PV}-install.patch
	sed \
		-e '50,200s:CWD:DESTDIR:g' \
		-i Makefile.am || die

	python_src_prepare

	preparation() {
		sed \
			-e "s:python\$PY_VERSION:$(PYTHON):g" \
			-i configure.ac || die

		eautoreconf
	}
	python_execute_function -s preparation

	tc-export CC
}

src_configure() {
	# we need to compile the *.so as pic
	append-flags -fPIC
	FFLAGS="${FFLAGS} -fPIC"

	configuration() {
		# Avoid automagic to numeric
		econf \
			--enable-propka \
			--with-max-atoms=${MAXATOMS:-10000} \
			$(use_enable pdb2pka) \
			$(use_with opal) \
			NUMPY="${EPREFIX}/$(python_get_sitedir)" \
			F77="$(tc-getFC)"
	}
	python_execute_function -s configuration
}

src_compile() {
	python_execute_function -d -s
}

src_test() {
	testing() {
		emake -j1 test
	}
	python_execute_function -s testing
}

src_install() {
	installation() {
		dodir $(python_get_sitedir)/${PN}
		emake -j1 DESTDIR="${ED}$(python_get_sitedir)/${PN}" \
			PREFIX="" install

		INPATH="$(python_get_sitedir)/${PN}"

		# generate pdb2pqr wrapper
		cat >> "${T}"/${PN}-$(python_get_version) <<-EOF
			#!/bin/sh
			$(PYTHON) ${EPREFIX}${INPATH}/${PN}.py \$*
		EOF

		cat >> "${T}"/pdb2pka-$(python_get_version) <<-EOF
			#!/bin/sh
			$(PYTHON) ${EPREFIX}${INPATH}/pdb2pka/pka.py \$*
		EOF

		dobin "${T}"/{${PN},pdb2pka}-$(python_get_version)

		insinto "${INPATH}" && doins __init__.py

		exeinto "${INPATH}" && doexe ${PN}.py

		insinto "${INPATH}"/dat && doins dat/*

		exeinto "${INPATH}"/extensions && doexe extensions/*

		insinto "${INPATH}"/src && doins src/*.py

		exeinto "${INPATH}"/propka && doexe propka/_propkalib.so

		insinto "${INPATH}"/propka && doins propka/propkalib.py propka/__init__.py

		insinto "${INPATH}"/pdb2pka && doins pdb2pka/*.{py,so,DAT,h}

		dosym ../../apbs/_apbs.so "${INPATH}"/pdb2pka/_apbslib.so
		dosym ../../apbs/apbslib.py "${INPATH}"/pdb2pka/apbslib.py
		dosym ../../apbs/apbslib.pyc "${INPATH}"/pdb2pka/apbslib.pyc
		dosym ../../apbs/apbslib.pyo "${INPATH}"/pdb2pka/apbslib.pyo
	}
	python_execute_function -s installation

	dosym ${PN}-$(python_get_version -f) /usr/bin/${PN}
	dosym pdb2pka-$(python_get_version -f) /usr/bin/pdb2pka

	if use doc; then
		pushd doc > /dev/null
		sh genpydoc.sh || die "genpydoc failed"
		dohtml -r *.html images pydoc
		popd > /dev/null
	fi

	use examples && \
		insinto /usr/share/${PN}/ && \
		doins -r examples

	dodoc ChangeLog NEWS README AUTHORS
}

pkg_postinst() {
	python_mod_optimize ${PN}
}

pkg_postrm() {
	python_mod_cleanup ${PN}
}