summaryrefslogtreecommitdiff
blob: 8ca1fde92ecb9eefbd60f8853bc7b7c9e9725cbc (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-chemistry/pymol/pymol-1.1-r2.ebuild,v 1.1 2008/12/19 00:32:56 je_fro Exp $

NEED_PYTHON=2.4
PYTHON_MODNAME="chempy pmg_tk pymol"

inherit distutils eutils multilib subversion

ESVN_REPO_URI="https://pymol.svn.sourceforge.net/svnroot/pymol/branches/b11/pymol"
# ESVN_UPDATE_CMD="svn -r 3395 update"

DESCRIPTION="A Python-extensible molecular graphics system."
HOMEPAGE="http://pymol.sourceforge.net/"

LICENSE="PSF-2.2"
IUSE="apbs shaders"
SLOT="0"
KEYWORDS="~amd64 ~x86"

RDEPEND="dev-python/pmw
	dev-python/numeric
	dev-lang/tk
	media-libs/libpng
	sys-libs/zlib
	virtual/glut
	apbs? ( dev-libs/maloc
		sci-chemistry/apbs
		sci-chemistry/pdb2pqr
	)"
DEPEND="${RDEPEND}"

pkg_setup() {
	if ! built_with_use dev-lang/python tk; then
		eerror "Please reemerge dev-lang/python with 'tk' support or pymol will"
		eerror "not work. In order to fix this, execute the following:"
		eerror "echo \"dev-lang/python tk\" >> /etc/portage/package.use"
		eerror "and reemerge dev-lang/python before emerging pymol."
		die "requires dev-lang/python with use-flag 'tk'!!"
	fi
}

src_unpack() {
	subversion_src_unpack

	python_version

	epatch "${FILESDIR}"/${PV}/${PF}-data-path.patch

	# Turn off splash screen.  Please do make a project contribution
	# if you are able though.
	[[ -z "$WANT_SPLASH" ]] && epatch "${FILESDIR}"/${PV}/nosplash-gentoo.patch

	# Respect CFLAGS
	sed -i \
		-e "s:\(ext_comp_args=\).*:\1[]:g" \
		"${S}"/setup.py

	if use shaders; then
		epatch "${FILESDIR}"/${PV}/${PF}-shaders.patch
	fi

	if use apbs; then
		epatch "${FILESDIR}"/${PV}/apbs-070604.patch.bz2
		sed "s:LIBANDPYTHON:$(get_libdir)/python${PYVER}:g" \
			-i modules/pmg_tk/startup/apbs_tools.py || die
	fi
}

src_install() {
	distutils_src_install
	cd "${S}"

	#The following three lines probably do not do their jobs and should be
	#changed
	PYTHONPATH="${D}/usr/$(get_libdir)/python${PYVER}/site-packages" ${python} setup2.py

	# These environment variables should not go in the wrapper script, or else
	# it will be impossible to use the PyMOL libraries from Python.
	cat >> "${T}"/20pymol <<- EOF
	PYMOL_PATH=/usr/$(get_libdir)/python${PYVER}/site-packages/pymol
	PYMOL_DATA="/usr/share/pymol/data"
	PYMOL_SCRIPTS="/usr/share/pymol/scripts"
	EOF

	doenvd "${T}"/20pymol || die "Failed to install env.d file."

	# Make our own wrapper
	cat >> "${T}"/pymol <<- EOF
	#!/bin/sh
	${python} -O \${PYMOL_PATH}/__init__.py \$*
	EOF

	if ! use apbs; then
		rm "${D}"/usr/$(get_libdir)/python${PYVER}/site-packages/pmg_tk/startup/apbs_tools.py
	fi

	exeinto /usr/bin
	doexe "${T}"/pymol || die "Failed to install wrapper."
	dodoc DEVELOPERS || die "Failed to install docs."

	mv examples "${D}"/usr/share/doc/${PF}/ || die "Failed moving docs."

	dodir /usr/share/pymol
	mv test "${D}"/usr/share/pymol/ || die "Failed moving test files."
	mv data "${D}"/usr/share/pymol/ || die "Failed moving data files."
	mv scripts "${D}"/usr/share/pymol/ || die "Failed moving scripts."
}

pkg_postinst() {
	distutils_pkg_postinst

	if use apbs; then
		[[ -e /usr/share/apbs-0.5* ]] && \
		ewarn "You need to reemerge sci-chemistry/apbs!"
	fi
}