summaryrefslogtreecommitdiff
path: root/sci-physics/espresso/espresso-9999.ebuild
blob: 45a4a3ec7583c5522ced2afa86f6ab1d74c07de2 (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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )

inherit cmake cuda python-single-r1 savedconfig

DESCRIPTION="Extensible Simulation Package for Research on Soft matter"
HOMEPAGE="https://espressomd.org"

if [[ ${PV} = 9999 ]]; then
	EGIT_REPO_URI="https://github.com/${PN}md/${PN}.git"
	EGIT_BRANCH="python"
	inherit git-r3
else
	SRC_URI="https://github.com/${PN}md/${PN}/releases/download/${PV}/${P}.tar.gz"
	KEYWORDS="~amd64 ~x86"
	S="${WORKDIR}/${PN}"
fi

LICENSE="GPL-3"
SLOT="0"
IUSE="cuda doc examples +fftw +hdf5 test"
RESTRICT="!test? ( test )"

REQUIRED_USE="
	${PYTHON_REQUIRED_USE}"

# cmake built hdf5 fails to detect, -r1 switched to cmake
RDEPEND="
	${PYTHON_DEPS}
	$(python_gen_cond_dep '
		>=dev-python/cython-0.26.1[${PYTHON_USEDEP}]
		dev-python/numpy[${PYTHON_USEDEP}]
	')
	cuda? ( >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 )
	fftw? ( sci-libs/fftw:3.0 )
	dev-libs/boost:=[mpi]
	hdf5? ( <sci-libs/hdf5-1.14.6-r1:=[mpi] )
"

DEPEND="${RDEPEND}
	doc? (
		app-text/doxygen[dot]
		dev-texlive/texlive-latexextra
		virtual/latex-base
	)
	test? (
		$(python_gen_cond_dep '
			dev-python/scipy[${PYTHON_USEDEP}]
		')
	)
"

DOCS=( AUTHORS NEWS Readme.md ChangeLog )

PATCHES=(
	"${FILESDIR}"/${P}-test-deps-only.patch
)

src_prepare() {
	use cuda && cuda_src_prepare
	cmake_src_prepare
	# allow cython 3.1
	sed -i '/Cython/{s/3\.1\.0/4.0/}' CMakeLists.txt || die

	# These produce tests that aren't run by "make check", but ctest picks
	# them up by default, against upstream's intention.
	cd testsuite || die
	cmake_comment_add_subdirectory cmake scripts tutorials samples benchmarks
}

src_configure() {
	local mycmakeargs=(
		-DESPRESSO_BUILD_WITH_CUDA=$(usex cuda)
		-DPython_EXECUTABLE="${PYTHON}"
		# ignores site-packages dir and replaces with CMAKE_INSTALL_LIBDIR
		-DESPRESSO_INSTALL_PYTHON="$(python_get_sitedir)"
		-DESPRESSO_BUILD_TESTS=$(usex test)
		-DINSTALL_PYPRESSO=OFF
		-DESPRESSO_BUILD_WITH_FFTW=$(usex fftw)
		-DESPRESSO_BUILD_WITH_HDF5=$(usex hdf5)
	)
	cmake_src_configure
}

src_compile() {
	cmake_src_compile
	use doc && cmake_build doxygen
	[[ ${PV} = 9999 ]] && use doc && cmake_build ug dg tutorials
}

src_test() {
	# testsuite uses exclude_from_all, and lists all targets as deps for their custom rule
	cmake_build check
	cmake_src_test
}

src_install() {
	local i docdir="${S}"

	cmake_src_install

	python_optimize

	insinto /usr/share/${PN}/
	doins "${BUILD_DIR}/myconfig-sample.hpp"

	save_config "${BUILD_DIR}/src/config/include/config/myconfig-final.hpp"

	if use doc; then
		dodoc -r "${BUILD_DIR}/doc/doxygen/html"
	fi

	if use examples; then
		insinto "/usr/share/${PN}/examples/python"
		doins -r samples/${i}/.
	fi
}

pkg_postinst() {
	echo
	elog "Please read and cite:"
	elog "ESPResSo, Comput. Phys. Commun. 174(9) ,704, 2006."
	elog "https://dx.doi.org/10.1016/j.cpc.2005.10.005"
	echo
	elog "If you need more features, change"
	elog "/etc/portage/savedconfig/${CATEGORY}/${PF}"
	elog "and reemerge with USE=savedconfig"
	echo
	elog "For a full feature list see:"
	elog "/usr/share/${PN}/myconfig-sample.hpp"
	echo
}