Re: [OpenBabel-Devel] [RFC][PATCH] cmake: Enable to build bindings only
On Thu, Oct 18, 2012 at 04:25:59PM -0400, Geoffrey Hutchison wrote: On Oct 16, 2012, at 1:40 PM, Reinis Danne wrote: Still I think this would be useful to have also in OB outside Gentoo packaging. Current implementation shifts all the burden of installing to user, but we can at least to try to make that easier. This doesn't change default behaviour, but it exposes for customization some of build system variables. I think this is likely a useful addition. I haven't looked at the patch itself, but this comes up with Mac. For example, if I wanted to ship Python binary bindings for Mac, I'd have to compile against Apple's Python 2.5, 2.6, 2.7, etc. for different Mac OS versions. I actually have all of those on my drive, but this patch would let me have a general libopenbabel Mac binary, and then different Pybel binaries. Great, then I'll be looking into adding this also for other bindings. I'm not familiar with how Mac handles system packages and how Python behaves there, but this is roughly what I'm doing on Gentoo. Run swig once directly in src dir. For each Python version run configure in separate build dir: local mycmakeargs=${mycmakeargs} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_RPATH= -DBINDINGS_ONLY=ON -DBABEL_SYSTEM_LIBRARY=${EPREFIX}/usr/$(get_libdir)/libopenbabel.so -DOB_MODULE_PATH=${EPREFIX}/usr/$(get_libdir)/openbabel/${PV} -DLIB_INSTALL_DIR=${ED}/usr/$(get_libdir)/${EPYTHON}/site-packages -DPYTHON_BINDINGS=ON -DPYTHON_EXECUTABLE=${PYTHON} -DPYTHON_INCLUDE_DIR=${EPREFIX}/usr/include/${EPYTHON} -DPYTHON_LIBRARY=${EPREFIX}/usr/$(get_libdir)/lib${EPYTHON}.so $(cmake-utils_use_enable test TESTS) For each Python version compile bindings: make bindings_python If tests were enabled, then have to symlink binaries: ln -s ${EPREFIX}/usr/bin/babel bin/babel ln -s ${EPREFIX}/usr/bin/obabel bin/obabel ctest -R py And finally install Python bindings component (_openbabel.so, openbabel.py and pybel.py): python_foreach_impl cmake -DCOMPONENT=bindings_python -P cmake_install.cmake Hope that helps setting it up. Reinis -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct ___ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel
Re: [OpenBabel-Devel] [RFC][PATCH] cmake: Enable to build bindings only
On Oct 16, 2012, at 1:40 PM, Reinis Danne wrote: Still I think this would be useful to have also in OB outside Gentoo packaging. Current implementation shifts all the burden of installing to user, but we can at least to try to make that easier. This doesn't change default behaviour, but it exposes for customization some of build system variables. I think this is likely a useful addition. I haven't looked at the patch itself, but this comes up with Mac. For example, if I wanted to ship Python binary bindings for Mac, I'd have to compile against Apple's Python 2.5, 2.6, 2.7, etc. for different Mac OS versions. I actually have all of those on my drive, but this patch would let me have a general libopenbabel Mac binary, and then different Pybel binaries. -Geoff -- Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_sfd2d_oct ___ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel
Re: [OpenBabel-Devel] [RFC][PATCH] cmake: Enable to build bindings only
My only concern is that this adds to the complexity of maintaining the bindings (or am I wrong about this? - is it the same?). For your own purposes, could you not copy out the installed binding files (there are just two), before rerunning against a different Python (no rebuild of the entire OB library required). I do something similar when creating the Windows Python packages. - Noel On 15 October 2012 16:00, Reinis Danne rei4...@gmail.com wrote: Hi! This is a request for comments. I have implemented bindings only build for OB Python bindings and would like to hear what others think about this. So that don't have to rebuild OB just to add bindings. It allows to, e.g., test Python bindings against multiple Python versions without requiring to rebuild OB for each version. Bindings form separate component to enable their installation using command like this: cmake -DCOMPONENT=bindings_python -P cmake_install.cmake I have not looked at other bindings yet, but I think they should follow similar approach. -- In Gentoo we are providing separate packages for bindings and with distutils it was very simple to build against system installation of OB with a small change to setup.py: obExtension = Extension('_openbabel', [os.path.join(srcdir, openbabel-python.cpp)], - include_dirs=[os.path.join(srcdir, .., .., include), - os.path.join(.., include)], - library_dirs=[os.path.join(srcdir, .., .., lib), - os.path.join(srcdir, .., .., lib64), - os.path.join(.., lib)], + include_dirs=[os.path.join(/usr, include, openbabel-2.0)], libraries=['openbabel'] ) With new build system for bindings it is not quite that straightforward. --- CMakeLists.txt | 13 +++-- scripts/CMakeLists.txt | 24 +++- test/CMakeLists.txt| 11 --- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 449f4b4..1c9ad00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,8 @@ if(NOT MSVC) } SCANDIR_NEEDS_CONST) - set(OB_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/${OB_PLUGIN_INSTALL_DIR}) + set(OB_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/${OB_PLUGIN_INSTALL_DIR} + CACHE PATH Set to system install for bindings only build) add_definitions(-DOB_MODULE_PATH=\\${OB_MODULE_PATH}\\) # Add some visibility support when using GCC @@ -380,7 +381,8 @@ if(UNIX AND BUILD_SHARED) if(APPLE) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}) else() -set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}) +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR} +CACHE PATH Set sane rpath) set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -477,6 +479,13 @@ endif() # Should the language bindings be regenereted? option(RUN_SWIG Generate language bindings with SWIG OFF) +# Build bindings only +option(BINDINGS_ONLY Build bindings only OFF) + +# Point to library if building bindings only +set(BABEL_SYSTEM_LIBRARY ${BABEL_LIBRARY} +CACHE PATH Point to openbabel library if building bindings only) + # Should all bindings be built? option(ALL_BINDINGS Build all languages bindings OFF) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 16e9000..ecd2295 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -92,16 +92,30 @@ if (DO_PYTHON_BINDINGS) endif(RUN_SWIG) add_library(bindings_python MODULE ${openbabel_SOURCE_DIR}/scripts/python/openbabel-python.cpp) -target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_LIBRARY}) +if(BINDINGS_ONLY) +target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_SYSTEM_LIBRARY}) +else() +target_link_libraries(bindings_python ${PYTHON_LIBRARIES} ${BABEL_LIBRARY}) +endif() + if(NOT WIN32) set_target_properties(bindings_python PROPERTIES OUTPUT_NAME _openbabel PREFIX SUFFIX .so ) -add_dependencies(bindings_python openbabel) -install(TARGETS bindings_python LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -install(FILES ${openbabel_SOURCE_DIR}/scripts/python/openbabel.py DESTINATION ${LIB_INSTALL_DIR}) -install(FILES ${openbabel_SOURCE_DIR}/scripts/python/pybel.py DESTINATION ${LIB_INSTALL_DIR}) +if(NOT BINDINGS_ONLY) +add_dependencies(bindings_python openbabel) +endif() + +install(TARGETS bindings_python +LIBRARY DESTINATION ${LIB_INSTALL_DIR} +COMPONENT bindings_python) +install(FILES
Re: [OpenBabel-Devel] [RFC][PATCH] cmake: Enable to build bindings only
On Tue, Oct 16, 2012 at 10:26:24AM +0100, Noel O'Boyle wrote: My only concern is that this adds to the complexity of maintaining the bindings (or am I wrong about this? - is it the same?). For your own purposes, could you not copy out the installed binding files (there are just two), before rerunning against a different Python (no rebuild of the entire OB library required). I do something similar when creating the Windows Python packages. Obviously it adds to the complexity, even more so because the new code is really bare-bones. But I don't think the added overhead is large and I tried to keep it at minimum. Suggestions how to improve it are welcome. For my own purposes I can build also OB five times as I did before the release to test with Python 2.6, 2.7, 3.1 and 3.2 and also the static build (+most of them also with eigen2 and 3). And I didn't even look at other bindings yet. I have a couple of bash convenience functions which help to symlink right build_dir for each configuration, so I don't have to change configuration each time and can use one alias to set paths so I can use any one of them if I choose so. But what I want to do here is different. I don't want to compile OB library and plugins at all if I already have system install with right version (which is the case currently on Gentoo where bindings are compiled after the rest of the OB has already been installed). I want to compile just the bindings against system install, run all Python tests and install bindings (taking care for the RPATHs if necessary) where Python can find them and do that for each Python version I have asked for (now normally that would be 2.7 and 3.2). But without these changes I can't do it. With these I can do it and have written an ebuild using it. I haven't yet pushed the new ebuilds because I want to know if it is acceptable to have it in OB so I don't have to maintain it outside for Gentoo (in which case maintaining the old setup.py file is much more easy). Still I think this would be useful to have also in OB outside Gentoo packaging. Current implementation shifts all the burden of installing to user, but we can at least to try to make that easier. This doesn't change default behaviour, but it exposes for customization some of build system variables. Note that this patch still requires manual copying of bindings to site-packages if building together with the rest of OB, since there is no way to provide different install dirs for bindings. I could try to look into it, but it is not really necessary for what I'm using it. Reinis -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel