summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Levine <plevine457@gmail.com>2021-03-21 03:54:12 -0400
committerAndrew Ammerlaan <andrewammerlaan@gentoo.org>2021-12-15 11:09:01 +0100
commite4d21e84be5fb16ae0d7f9bee7f7ab33fcb93eee (patch)
tree622e7e91ac4061b4aa3dece388ca7d908317dc9e /sci-chemistry/openbabel
parentsci-physics/geant: pass python args to CMake only with USE=python (diff)
downloadgentoo-e4d21e84be5fb16ae0d7f9bee7f7ab33fcb93eee.tar.gz
gentoo-e4d21e84be5fb16ae0d7f9bee7f7ab33fcb93eee.tar.bz2
gentoo-e4d21e84be5fb16ae0d7f9bee7f7ab33fcb93eee.zip
sci-chemistry/openbabel: Add openbabel-9999
Add an up-to-date live ebuild with a templated versioning scheme, and match the bindings to USE flags. Package-Manager: Portage-3.0.17, Repoman-3.0.2 Signed-off-by: Peter Levine <plevine457@gmail.com> Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Diffstat (limited to 'sci-chemistry/openbabel')
-rw-r--r--sci-chemistry/openbabel/Manifest1
-rw-r--r--sci-chemistry/openbabel/files/openbabel-python.cmake104
-rw-r--r--sci-chemistry/openbabel/metadata.xml4
-rw-r--r--sci-chemistry/openbabel/openbabel-9999.ebuild272
4 files changed, 381 insertions, 0 deletions
diff --git a/sci-chemistry/openbabel/Manifest b/sci-chemistry/openbabel/Manifest
index b22751d4a860..ac334bea30ea 100644
--- a/sci-chemistry/openbabel/Manifest
+++ b/sci-chemistry/openbabel/Manifest
@@ -1,2 +1,3 @@
DIST openbabel-2.4.1.tar.gz 11618304 BLAKE2B 8fc051e83add9be6456e281a109bd6bbec282a64ffc83309819f0decbf167b4914fbb7f1966e95e103f268754045b804317f51c79a952ace707c6af2bd320125 SHA512 427e678f0a911bd27b9a8a05e60b6e09f113be4e5dd180daaf80c28d06368e52b57501261755ab3817a8d31f2754db24471fd0ceee706d029386d6f70800e9c6
+DIST openbabel.jpg 12159 BLAKE2B b701df2b8c29df607dc2bd3997a282aa9a726d56c789ff2db900d33234dc691f76b6af12a4c9ccda4f09984504b863c40c39e8bf91058939996714ede2dd37c7 SHA512 998ea526c8c92f87dd203527fdd9f4e001357e951409209f41ab68e0b730fe12d97f9079c12ca289be413854ea2abcf8bb691ae5af823a6f29d6a590e1a3e2b0
DIST openbabel.png 29060 BLAKE2B 8d217d92125cc73462437411dd4e0cc05179cb0934f5ed15a307acc6b549b8ebab250a48a05ef7657f48c6df394f37da9b659de61efb1477b79b573a5b393ad3 SHA512 bbcaaa37663b526c9038ccb9edaf05ccc3ad1a861739a737f05f363098d8402a10b36e341fcc0aca636e809c6c32db99bf987b41719a0c756bf5e31444d3eb70
diff --git a/sci-chemistry/openbabel/files/openbabel-python.cmake b/sci-chemistry/openbabel/files/openbabel-python.cmake
new file mode 100644
index 000000000000..425b4656a9d2
--- /dev/null
+++ b/sci-chemistry/openbabel/files/openbabel-python.cmake
@@ -0,0 +1,104 @@
+# The following is a cmake fragment taken from scripts/CMakeLists.txt and
+# edited for Gentoo python multibuild compatibility.
+
+if (PYTHON_BINDINGS)
+ # Tags should be edited to reflect the active python implementation
+ set(EPYTHON @@EPYTHON@@)
+ set(PYTHON_INCUDE_DIR @@PYTHON_INCUDE_DIR@@)
+ set(PYTHON_LIBS @@PYTHON_LIBS@@)
+ set(PYTHON_SITEDIR @@PYTHON_SITEDIR@@)
+
+ include_directories(${PYTHON_INCUDE_DIR})
+
+ add_custom_command(
+ OUTPUT ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel-python.cpp ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel.py
+ COMMAND ${SWIG_EXECUTABLE} -python -c++ -small -O -templatereduce -naturalvar -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_BINARY_DIR}/include -o ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel-python.cpp ${eigen_define} -outdir ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON} ${CMAKE_SOURCE_DIR}/scripts/openbabel-python.i
+ MAIN_DEPENDENCY openbabel-python.i
+ VERBATIM
+ )
+
+ configure_file(${CMAKE_SOURCE_DIR}/scripts/python/openbabel/__init__.py.in
+ ${CMAKE_BINARY_DIR}/scripts/${EPYTHON}/openbabel/__init__.py)
+
+ add_library(bindings_python_${EPYTHON} MODULE ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel-python.cpp)
+ target_link_libraries(bindings_python_${EPYTHON} ${PYTHON_LIBS} ${BABEL_LIBRARY})
+
+ set_target_properties(bindings_python_${EPYTHON}
+ PROPERTIES
+ OUTPUT_NAME _openbabel
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/scripts/${EPYTHON}/openbabel
+ PREFIX ""
+ SUFFIX .so )
+
+ add_dependencies(bindings_python_${EPYTHON} openbabel)
+
+ install(TARGETS bindings_python_${EPYTHON}
+ LIBRARY DESTINATION ${PYTHON_SITEDIR}/openbabel
+ COMPONENT bindings_python)
+ install(FILES ${CMAKE_BINARY_DIR}/scripts/${EPYTHON}/openbabel/__init__.py
+ DESTINATION ${PYTHON_SITEDIR}/openbabel
+ COMPONENT bindings_python)
+ install(FILES ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel.py
+ DESTINATION ${PYTHON_SITEDIR}/openbabel
+ COMPONENT bindings_python)
+ install(FILES ${CMAKE_SOURCE_DIR}/scripts/python/openbabel/pybel.py
+ DESTINATION ${PYTHON_SITEDIR}/openbabel
+ COMPONENT bindings_python)
+
+ if (ENABLE_TESTS)
+ # Make sure all module files are together in the same directory for testing
+ add_custom_command(TARGET bindings_python_${EPYTHON} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/scripts/${EPYTHON}/openbabel.py ${CMAKE_BINARY_DIR}/scripts/${EPYTHON}/openbabel/
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/scripts/python/openbabel/pybel.py ${CMAKE_BINARY_DIR}/scripts/${EPYTHON}/openbabel/)
+ set(TEST_SOURCE_DIR ${CMAKE_SOURCE_DIR}/test)
+ # define TESTDATADIR for tests that need input files
+ add_definitions(-DTESTDATADIR="${TEST_SOURCE_DIR}/files/")
+ # define FORMATDIR for location of format plugin binaries
+ set(FORMATDIR "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}/")
+ add_definitions(-DFORMATDIR="${FORMATDIR}/")
+ include_directories(${TEST_SOURCE_DIR})
+
+ # The macro is modified from cmake/modules/UsePythonTest.cmake
+ MACRO(ADD_PYTHON_TEST TESTNAME FILENAME)
+ GET_SOURCE_FILE_PROPERTY(loc ${FILENAME} LOCATION)
+ STRING(REGEX REPLACE ";" " " wo_semicolumn "${ARGN}")
+ FILE(WRITE ${CMAKE_BINARY_DIR}/test/${TESTNAME}.cmake
+"
+ MESSAGE(\"${PYTHONPATH}\")
+ EXECUTE_PROCESS(
+ COMMAND ${EPYTHON} ${loc} ${wo_semicolumn}
+ RESULT_VARIABLE import_res
+ OUTPUT_VARIABLE import_output
+ ERROR_VARIABLE import_output
+ )
+
+ # Pass the output back to ctest
+ IF(import_output)
+ MESSAGE(\${import_output})
+ ENDIF(import_output)
+ IF(import_res)
+ MESSAGE(SEND_ERROR \${import_res})
+ ENDIF(import_res)
+"
+ )
+ ADD_TEST(${TESTNAME} ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/test/${TESTNAME}.cmake)
+ ENDMACRO(ADD_PYTHON_TEST)
+
+ set(pybindtests
+ bindings
+ _pybel
+ example
+ obconv_writers
+ cdjsonformat
+ pcjsonformat
+ roundtrip
+ )
+ foreach(pybindtest ${pybindtests})
+ ADD_PYTHON_TEST(pybindtest_${pybindtest}_${EPYTHON} ${TEST_SOURCE_DIR}/test${pybindtest}.py)
+ set_tests_properties(pybindtest_${pybindtest}_${EPYTHON} PROPERTIES
+ ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/scripts/${EPYTHON}:${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX};LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/scripts/${EPYTHON}:${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}:\$ENV{LD_LIBRARY_PATH};BABEL_LIBDIR=${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}/;BABEL_DATADIR=${CMAKE_SOURCE_DIR}/data"
+ FAIL_REGULAR_EXPRESSION "ERROR;FAIL;Test failed"
+ )
+ endforeach(pybindtest ${pybindtests})
+ endif (ENABLE_TESTS)
+endif(PYTHON_BINDINGS)
diff --git a/sci-chemistry/openbabel/metadata.xml b/sci-chemistry/openbabel/metadata.xml
index 88ffa5eb106b..f31c73d435ac 100644
--- a/sci-chemistry/openbabel/metadata.xml
+++ b/sci-chemistry/openbabel/metadata.xml
@@ -14,4 +14,8 @@
<upstream>
<remote-id type="sourceforge">openbabel</remote-id>
</upstream>
+ <use>
+ <flag name="inchi">Build support for IUPAC International Chemical Identifier format</flag>
+ <flag name="json">Build support for JSON formats (ChemDoodle, PubChem, etc...)</flag>
+ </use>
</pkgmetadata>
diff --git a/sci-chemistry/openbabel/openbabel-9999.ebuild b/sci-chemistry/openbabel/openbabel-9999.ebuild
new file mode 100644
index 000000000000..8f231a4565a2
--- /dev/null
+++ b/sci-chemistry/openbabel/openbabel-9999.ebuild
@@ -0,0 +1,272 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{7,8,9} )
+WX_GTK_VER=3.0-gtk3
+
+inherit cmake desktop flag-o-matic perl-functions python-r1 toolchain-funcs wxwidgets xdg-utils
+
+DESCRIPTION="Interconverts file formats used in molecular modeling"
+HOMEPAGE="https://openbabel.org/"
+
+if [[ "${PV}" == *9999* ]]; then
+ inherit git-r3
+ EGIT_REPO_URI="https://github.com/openbabel/${PN}.git"
+else
+ if [[ "${PV}" == *_p* ]]; then # eg., openbabel-3.1.1_p20210325
+ # Set to commit hash
+ OPENBABEL_COMMIT=
+ SRC_URI="https://github.com/${PN}/${PN}/archive/${OPENBABEL_COMMIT}.tar.gz -> ${P}.tar.gz"
+ S="${WORKDIR}/${PN}-${OPENBABEL_COMMIT}"
+ else
+ MY_P="${PN}-$(ver_rs 1- -)"
+ SRC_URI="https://github.com/${PN}/${PN}/archive/${MY_P}.tar.gz -> ${P}.tar.gz"
+ S="${WORKDIR}/${PN}-${MY_P}"
+ fi
+ KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
+fi
+
+SRC_URI="${SRC_URI}
+ https://openbabel.org/docs/dev/_static/babel130.png -> ${PN}.png
+ http://openbabel.org/OBTitle.jpg -> ${PN}.jpg"
+
+# See src/CMakeLists.txt for LIBRARY_VERSION
+SLOT="0/7.0.0"
+LICENSE="GPL-2"
+IUSE="cpu_flags_arm_neon cpu_flags_x86_sse2 cpu_flags_x86_sse4_2 doc examples +inchi json minimal openmp perl png python test wxwidgets"
+
+RESTRICT="!test? ( test )"
+
+# Inaccurate dependency logic upstream
+REQUIRED_USE="
+ python? ( ${PYTHON_REQUIRED_USE} )
+ test? ( inchi json !minimal wxwidgets )
+"
+
+BDEPEND="
+ dev-lang/perl
+ doc? (
+ app-doc/doxygen
+ dev-texlive/texlive-latex
+ )
+ perl? ( >=dev-lang/swig-2 )
+ python? ( >=dev-lang/swig-2 )
+ test? ( dev-lang/python )
+"
+
+COMMON_DEPEND="
+ dev-cpp/eigen:3
+ dev-libs/libxml2:2
+ sys-libs/zlib:=
+ inchi? ( sci-libs/inchi )
+ json? ( >=dev-libs/rapidjson-1.1.0 )
+ png? ( x11-libs/cairo )
+ python? ( ${PYTHON_DEPS} )
+ wxwidgets? ( x11-libs/wxGTK:${WX_GTK_VER}[X] )
+"
+
+DEPEND="
+ ${COMMON_DEPEND}
+ perl? ( dev-lang/perl )
+"
+
+RDEPEND="
+ ${COMMON_DEPEND}
+ perl? (
+ dev-lang/perl:=
+ !sci-chemistry/openbabel-perl
+ )
+"
+
+pkg_setup() {
+ use openmp && tc-check-openmp
+}
+
+prepare_python_bindings() {
+ mkdir -p scripts/${EPYTHON} || die
+ # Appends to scripts/CMakeLists.txt, substituting the correct tags, for
+ # each valid python implementation,
+ cat "${FILESDIR}"/${PN}-python.cmake | \
+ sed -e "s|@@EPYTHON@@|${EPYTHON}|" \
+ -e "s|@@PYTHON_INCUDE_DIR@@|$(python_get_includedir)|" \
+ -e "s|@@PYTHON_LIBS@@|$(python_get_LIBS)|" \
+ -e "s|@@PYTHON_SITEDIR@@|$(python_get_sitedir)|" >> \
+ scripts/CMakeLists.txt || die
+}
+
+src_prepare() {
+ cmake_src_prepare
+
+ if use perl; then
+ perl_set_version
+
+ sed -e "/\${LIB_INSTALL_DIR}\/auto/s|\${LIB_INSTALL_DIR}|${VENDOR_ARCH}|" \
+ -e "/\${LIB_INSTALL_DIR}\/Chemistry/s|\${LIB_INSTALL_DIR}|${VENDOR_ARCH}|" \
+ -i scripts/CMakeLists.txt || die
+ fi
+
+ if use python; then
+ # Skip the python bindings sections as we'll append our own
+ sed -e '/^if (PYTHON_BINDINGS)$/s|PYTHON_BINDINGS|false|' \
+ -i {scripts,test}/CMakeLists.txt || die
+ if use test; then
+ # Problems with testbindings built with -O2
+ local test_skip="@unittest.skip('Similar to Issue #2138')"
+ sed -e "/def testTemplates/s|^| ${test_skip}\\n|" \
+ -i test/testbindings.py || die
+ test_skip="@unittest.skip('Similar to Issue #2246')"
+ sed -e "/^def test_write_string/s|^|${test_skip}\\n|" \
+ -i test/testobconv_writers.py || die
+ fi
+ python_foreach_impl prepare_python_bindings
+ fi
+
+ # Remove dependency automagic
+ if ! use png; then
+ sed -e '/^find_package(Cairo/d' -i CMakeLists.txt || die
+ fi
+ if ! use wxwidgets; then
+ sed -e '/^find_package(wxWidgets/d' -i CMakeLists.txt || die
+ fi
+ if ! use inchi; then
+ sed -e '/^else()$/s|else\(\)|elseif\(false\)|' \
+ -i cmake/modules/FindInchi.cmake || die
+ fi
+
+ # Don't install example bins to /usr/bin
+ if use examples; then
+ sed -e "/RUNTIME DESTINATION/s|bin|share/doc/${PF}/examples|" \
+ -i doc/examples/CMakeLists.txt || die
+ fi
+
+ # boost is only used if building with gcc-3.x, which isn't supported in
+ # Gentoo. Still, it shouldn't look for, and include, its headers
+ sed -e '/find_package(Boost/d' -i {{tools,src}/,}CMakeLists.txt || die
+}
+
+src_configure() {
+ if use json; then
+ # -DOPTIMIZE_NATIVE=ON also forces -march=native so use
+ # cpu_flags to set defines instead
+ use cpu_flags_x86_sse2 && append-cppflags -DRAPIDJSON_SSE2
+ use cpu_flags_x86_sse4_2 && append-cppflags -DRAPIDJSON_SSE42
+ use cpu_flags_arm_neon && append-cppflags -DRAPIDJSON_NEON
+ fi
+
+ use wxwidgets && setup-wxwidgets
+
+ use_bindings() {
+ (use perl || use python) && (echo 'yes' || die) || (echo 'no' || die)
+ }
+
+ local mycmakeargs=(
+ -DBUILD_DOCS=$(usex doc)
+ -DBUILD_EXAMPLES=$(usex examples)
+ -DBUILD_GUI=$(usex wxwidgets)
+ -DENABLE_OPENMP=$(usex openmp)
+ -DENABLE_TESTS=$(usex test)
+ -DMINIMAL_BUILD=$(usex minimal)
+ # Set this, otherwise it defaults to true and forces WITH_INCHI=true
+ -DOPENBABEL_USE_SYSTEM_INCHI=$(usex inchi)
+ -DOPTIMIZE_NATIVE=OFF
+ -DPERL_BINDINGS=$(usex perl)
+ -DPYTHON_BINDINGS=$(usex python)
+ -DRUN_SWIG=$(use_bindings)
+ -DWITH_COORDGEN=false
+ -DWITH_INCHI=$(usex inchi)
+ -DWITH_JSON=$(usex json)
+ -DWITH_MAEPARSER=false
+ )
+
+ if use test; then
+ # Help cmake find the python interpreter when dev-lang/python-exec is built
+ # without native-symlinks support.
+ python_setup
+ mycmakeargs+=( -DPYTHON_EXECUTABLE="${PYTHON}" )
+ fi
+
+ cmake_src_configure
+}
+
+src_test() {
+ # Wierd deadlock causes system_load to keep rising
+ cmake_src_test -j1
+}
+
+openbabel-optimize() {
+ python_optimize "${D}/$(python_get_sitedir)"/openbabel || die
+}
+
+src_install() {
+ cmake_src_install
+
+ docinto html
+ for x in doc/*.html; do
+ [[ ${x} != doc/api*.html ]] && dodoc ${x}
+ done
+ # Rendered in some html pages
+ newdoc "${DISTDIR}"/${PN}.png babel130.png
+ newdoc "${DISTDIR}"/${PN}.jpg OBTitle.jpg
+
+ if use doc; then
+ cmake_src_install docs
+ docinto html/API
+ dodoc -r doc/API/html/.
+ fi
+
+ if use examples; then
+ # no compression since we want ready-to-run scripts
+ docompress -x /usr/share/doc/${PF}/examples
+
+ # ${PV} doesn't correspond to the internal BABEL_VERSION for
+ # live or patch release builds so we grep it
+ local babel_ver=$(
+ grep '^#define BABEL_VERSION' < \
+ "${BUILD_DIR}"/include/openbabel/babelconfig.h | \
+ cut -d \" -f 2 || die
+ )
+ docinto examples/povray
+ dodoc doc/dioxin.* doc/README*.pov*
+ # Needed by the povray example
+ dosym ../../../../${PN}/${babel_ver}/babel_povray3.inc \
+ /usr/share/doc/${PF}/examples/povray/babel31.inc
+
+ fi
+
+ if use perl; then
+ docinto /
+ newdoc scripts/perl/Changes Changes.perl
+ newdoc scripts/perl/README README.perl
+ if use examples; then
+ docinto examples/perl
+ dodoc -r scripts/perl/examples/.
+ fi
+ fi
+
+ if use python; then
+ python_foreach_impl openbabel-optimize
+ docinto /
+ newdoc scripts/python/README.rst README.python.rst
+ docinto html
+ dodoc scripts/python/*.html
+ if use examples; then
+ docinto examples/python
+ dodoc -r scripts/python/examples/.
+ fi
+ fi
+
+ if use wxwidgets; then
+ make_desktop_entry obgui "Open Babel" ${PN}
+ doicon "${DISTDIR}"/${PN}.png
+ fi
+}
+
+pkg_postinst() {
+ use wxwidgets && xdg_desktop_database_update
+}
+
+pkg_postrm() {
+ use wxwidgets && xdg_desktop_database_update
+}