summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shvetsov <alexxy@gentoo.org>2022-04-15 13:00:00 +0300
committerAlexey Shvetsov <alexxy@gentoo.org>2022-04-15 13:00:38 +0300
commita7168ef5c9ef4798fe1f7176c8eea95b33e8d103 (patch)
tree2a13d101bd738c60992c482776feb72345a5bcf8 /sci-chemistry
parentmedia-gfx/renderdoc: drop 1.18-r1 (diff)
downloadgentoo-a7168ef5c9ef4798fe1f7176c8eea95b33e8d103.tar.gz
gentoo-a7168ef5c9ef4798fe1f7176c8eea95b33e8d103.tar.bz2
gentoo-a7168ef5c9ef4798fe1f7176c8eea95b33e8d103.zip
sci-chemistry/openbabel: Resurect opebabel[python]
File ${FILESDIR}/openbabel-python.cmake was accidently removed by astrum in 3b032e0f3d0d837c2faf2051da6257844e7ced55 Closes: https://bugs.gentoo.org/837254 Package-Manager: Portage-3.0.30, Repoman-3.0.3 Signed-off-by: Alexey Shvetsov <alexxy@gentoo.org>
Diffstat (limited to 'sci-chemistry')
-rw-r--r--sci-chemistry/openbabel/files/openbabel-python.cmake104
1 files changed, 104 insertions, 0 deletions
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)