dev-python/routes: keyworded 2.4.1-r1 for ia64, bug #717946
[gentoo.git] / sci-chemistry / pymol / pymol-2.3.0-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 )
7
8 inherit distutils-r1 desktop eutils flag-o-matic xdg-utils
9
10 DESCRIPTION="A Python-extensible molecular graphics system"
11 HOMEPAGE="https://www.pymol.org/"
12 SRC_URI="
13         https://dev.gentoo.org/~jlec/distfiles/${PN}-1.8.4.0.png.xz
14         https://github.com/schrodinger/pymol-open-source/archive/v${PV}.tar.gz -> ${P}.tar.gz
15         "
16 RESTRICT="mirror"
17 LICENSE="PSF-2.2"
18 SLOT="0"
19 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos"
20 IUSE="web"
21
22 DEPEND="
23         dev-libs/msgpack[cxx]
24         dev-libs/mmtf-cpp
25         || (
26                 dev-python/numpy-python2[${PYTHON_USEDEP}]
27                 dev-python/numpy[${PYTHON_USEDEP}]
28         )
29         dev-python/pmw:py2[${PYTHON_USEDEP}]
30         dev-python/pyopengl[${PYTHON_USEDEP}]
31         dev-python/PyQt5[opengl,${PYTHON_USEDEP}]
32         media-libs/freetype:2
33         media-libs/glew:0=
34         media-libs/glm
35         media-libs/libpng:0=
36         media-video/mpeg-tools
37         sys-libs/zlib
38         !sci-chemistry/pymol-apbs-plugin[${PYTHON_USEDEP}]
39         web? ( !dev-python/webpy[${PYTHON_USEDEP}] )"
40 RDEPEND="${DEPEND}
41         sci-chemistry/chemical-mime-data
42 "
43
44 S="${WORKDIR}"/${PN}-open-source-${PV}
45
46 python_prepare_all() {
47         sed \
48                 -e "s:\"/usr:\"${EPREFIX}/usr:g" \
49                 -e "/ext_comp_args.*+=/s:\[.*\]$:\[\]:g" \
50                 -e "/import/s:argparse:argparseX:g" \
51                 -i setup.py || die
52
53         sed \
54                 -e "s:/opt/local:${EPREFIX}/usr:g" \
55                 -e '/ext_comp_args/s:\[.*\]:[]:g' \
56                 -i setup.py || die
57         sed \
58                 -e "s:\['msgpackc'\]:\['msgpack'\]:g" \
59                 -i setup.py || die
60
61         append-cxxflags -std=c++0x
62
63         distutils-r1_python_prepare_all
64 }
65
66 python_install() {
67         distutils-r1_python_install \
68                 --pymol-path="${EPREFIX}/usr/share/pymol"
69
70         sed \
71                 -e '1d' \
72                 -e "/APBS_BINARY_LOCATION/s:None:\"${EPREFIX}/usr/bin/apbs\":g" \
73                 -e "/APBS_PSIZE_LOCATION/s:None:\"$(python_get_sitedir)/pdb2pqr/src/\":g" \
74                 -e "/APBS_PDB2PQR_LOCATION/s:None:\"$(python_get_sitedir)/pdb2pqr/\":g" \
75                 -i "${D}/$(python_get_sitedir)"/pmg_tk/startup/apbs_tools.py || die
76 }
77
78 python_install_all() {
79         distutils-r1_python_install_all
80
81         sed \
82                 -e '1i#!/usr/bin/env python' \
83                 "${D}/$(python_get_sitedir)"/pymol/__init__.py > "${T}"/${PN} || die
84
85         python_foreach_impl python_doscript "${T}"/${PN}
86
87         # These environment variables should not go in the wrapper script, or else
88         # it will be impossible to use the PyMOL libraries from Python.
89         cat >> "${T}"/20pymol <<- EOF
90                 PYMOL_PATH="${EPREFIX}/usr/share/pymol"
91                 PYMOL_DATA="${EPREFIX}/usr/share/pymol/data"
92                 PYMOL_SCRIPTS="${EPREFIX}/usr/share/pymol/scripts"
93         EOF
94
95         doenvd "${T}"/20pymol
96
97         newicon "${WORKDIR}"/${PN}-1.8.4.0.png ${PN}.png
98         make_desktop_entry ${PN} PyMol ${PN} \
99                 "Graphics;Education;Science;Chemistry;" \
100                 "MimeType=chemical/x-pdb;chemical/x-mdl-molfile;chemical/x-mol2;chemical/seq-aa-fasta;chemical/seq-na-fasta;chemical/x-xyz;chemical/x-mdl-sdf;"
101
102         if ! use web; then
103                 rm -rf "${D}/$(python_get_sitedir)/web" || die
104         fi
105
106         rm -f "${ED}"/usr/share/${PN}/LICENSE || die
107 }
108
109 pkg_postinst() {
110         xdg_desktop_database_update
111         xdg_mimeinfo_database_update
112         optfeature "Electrostatic calculations" sci-chemistry/apbs sci-chemistry/pdb2pqr
113 }
114
115 pkg_postrm() {
116         xdg_desktop_database_update
117         xdg_mimeinfo_database_update
118 }