Skip to content

Commit

Permalink
Merge pull request #2060 from e-kwsm/OB3
Browse files Browse the repository at this point in the history
Update for Open Babel 3
  • Loading branch information
ghutchis committed Oct 24, 2019
2 parents 6ef538d + 7bf2ec2 commit f84536d
Show file tree
Hide file tree
Showing 30 changed files with 147 additions and 146 deletions.
3 changes: 0 additions & 3 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ install Open Babel on most systems. If you are using unique install locations
and/or libraries are not automatically detected please consult the 'Advanced'
section.

The following instructions assume that the Open Babel source distribution is in
the directory ~/openbabel-2.4.0.

1. Create a 'build' directory:

mkdir build
Expand Down
20 changes: 10 additions & 10 deletions OpenBabel3Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# The OpenBabel2 config file. To get the targets include the exports file.
get_filename_component(OpenBabel2_INSTALL_PREFIX "${OpenBabel2_DIR}@REL_REF@"
# The OpenBabel3 config file. To get the targets include the exports file.
get_filename_component(OpenBabel3_INSTALL_PREFIX "${OpenBabel3_DIR}@REL_REF@"
ABSOLUTE)

set(OpenBabel2_VERSION_MAJOR "@BABEL_MAJ_VER@")
set(OpenBabel2_VERSION_MINOR "@BABEL_MIN_VER@")
set(OpenBabel2_VERSION_PATCH "@BABEL_PATCH_VER@")
set(OpenBabel2_VERSION "@BABEL_VERSION@")
set(OpenBabel3_VERSION_MAJOR "@BABEL_MAJ_VER@")
set(OpenBabel3_VERSION_MINOR "@BABEL_MIN_VER@")
set(OpenBabel3_VERSION_PATCH "@BABEL_PATCH_VER@")
set(OpenBabel3_VERSION "@BABEL_VERSION@")

set(OpenBabel2_INCLUDE_DIRS "@OpenBabel2_INCLUDE_DIRS@")
set(OpenBabel2_EXPORTS_FILE "@OB_EXPORTS_FILE@")
set(OpenBabel2_ENABLE_VERSIONED_FORMATS "@ENABLE_VERSIONED_FORMATS@")
set(OpenBabel3_INCLUDE_DIRS "@OpenBabel3_INCLUDE_DIRS@")
set(OpenBabel3_EXPORTS_FILE "@OB_EXPORTS_FILE@")
set(OpenBabel3_ENABLE_VERSIONED_FORMATS "@ENABLE_VERSIONED_FORMATS@")

# Include the exports file to import the exported OpenBabel targets
include("${OpenBabel2_EXPORTS_FILE}")
include("${OpenBabel3_EXPORTS_FILE}")
2 changes: 1 addition & 1 deletion OpenBabel3ConfigVersion.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OpenBabel2 CMake version file - http://www.openbabel.org/
# OpenBabel3 CMake version file - http://www.openbabel.org/

set(PACKAGE_VERSION @BABEL_MAJ_VER@.@BABEL_MIN_VER@.@BABEL_PATCH_VER@)

Expand Down
18 changes: 9 additions & 9 deletions doc/examples/static_executable/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#
# This script can be used to create static executables linking to the static
# OpenBabel2 library.
# OpenBabel3 library.
#
# This script requires OpenBabel to be build and installed. For example:
#
# cd openbabel-2.3
# cd openbabel
# mkdir build
# cd build
# cmake -DBUILD_SHARED=OFF -DCMAKE_INSTALL_PREFIX=/home/me/some/path ..
Expand All @@ -16,7 +16,7 @@
# cd myproject
# mkdir build
# cd build
# cmake -DOpenBabel2_DIR=/home/me/some/path/lib/openbabel ..
# cmake -DOpenBabel3_DIR=/home/me/some/path/lib/openbabel ..
# make
#
# All plugins are inside the static libopenbabel.a but the symbols for the
Expand Down Expand Up @@ -53,17 +53,17 @@ else()
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()

# Set the path containing OpenBabel2Config.cmake, needed for find_package below.
find_path(OpenBabel2_DIR OpenBabel2Config.cmake PATHS
${OpenBabel2_DIR}
# Set the path containing OpenBabel3Config.cmake, needed for find_package below.
find_path(OpenBabel3_DIR OpenBabel3Config.cmake PATHS
${OpenBabel3_DIR}
"/usr/lib/openbabel"
"/usr/local/lib/openbabel")

#
# Find and setup OpenBabel2.
# Find and setup OpenBabel3.
#
find_package(OpenBabel2 REQUIRED)
include_directories(${OpenBabel2_INCLUDE_DIRS})
find_package(OpenBabel3 REQUIRED)
include_directories(${OpenBabel3_INCLUDE_DIRS})

# Dependencies
find_package(LibXml2)
Expand Down
4 changes: 2 additions & 2 deletions doc/obabel.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obabel 1 URM
.Sh NAME
.Nm obabel
Expand Down
4 changes: 2 additions & 2 deletions doc/obchiral.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obchiral 1 URM
.Sh NAME
.Nm obchiral
Expand Down
4 changes: 2 additions & 2 deletions doc/obconformer.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obconformer 1 URM
.Sh NAME
.Nm obconformer
Expand Down
4 changes: 2 additions & 2 deletions doc/obdistgen.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd October 26, 2017
.Os "Open Babel" 2.4.1
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obdistgen 1 URM
.Sh NAME
.Nm obdistgen
Expand Down
4 changes: 2 additions & 2 deletions doc/obenergy.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obenergy 1 URM
.Sh NAME
.Nm obenergy
Expand Down
4 changes: 2 additions & 2 deletions doc/obfit.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obfit 1 URM
.Sh NAME
.Nm obfit
Expand Down
4 changes: 2 additions & 2 deletions doc/obgen.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obgen 1 URM
.Sh NAME
.Nm obgen
Expand Down
4 changes: 2 additions & 2 deletions doc/obgrep.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obgrep 1 URM
.Sh NAME
.Nm obgrep
Expand Down
4 changes: 2 additions & 2 deletions doc/obgui.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd June 2, 2012
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obgui 1 URM
.Sh NAME
.Nm obgui
Expand Down
4 changes: 2 additions & 2 deletions doc/obminimize.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obminimize 1 URM
.Sh NAME
.Nm obminimize
Expand Down
4 changes: 2 additions & 2 deletions doc/obprobe.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obprobe 1 URM
.Sh NAME
.Nm obprobe
Expand Down
4 changes: 2 additions & 2 deletions doc/obprop.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obprop 1 URM
.Sh NAME
.Nm obprop
Expand Down
4 changes: 2 additions & 2 deletions doc/obrms.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd October 26, 2017
.Os "Open Babel" 2.4.1
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obrms 1 URM
.Sh NAME
.Nm obrms
Expand Down
4 changes: 2 additions & 2 deletions doc/obrotamer.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obrotamer 1 URM
.Sh NAME
.Nm obrotamer
Expand Down
4 changes: 2 additions & 2 deletions doc/obrotate.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obrotate 1 URM
.Sh NAME
.Nm obrotate
Expand Down
4 changes: 2 additions & 2 deletions doc/obspectrophore.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd June 2, 2012
.Os "Open Babel" 2.3
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obspectrophore 1 URM
.Sh NAME
.Nm obspectrophore
Expand Down
4 changes: 2 additions & 2 deletions doc/obsym.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd October 26, 2017
.Os "Open Babel" 2.4.1
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obsym 1 URM
.Sh NAME
.Nm obsym
Expand Down
4 changes: 2 additions & 2 deletions doc/obtautomer.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd October 26, 2017
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obtautomer 1 URM
.Sh NAME
.Nm obtautomer
Expand Down
4 changes: 2 additions & 2 deletions doc/obthermo.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd October 26, 2017
.Os "Open Babel" 2.4.1
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt obthermo 1 URM
.Sh NAME
.Nm obthermo
Expand Down
4 changes: 2 additions & 2 deletions doc/roundtrip.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.Dd July 4, 2008
.Os "Open Babel" 2.2
.Dd Oct 10, 2019
.Os "Open Babel" 3.0
.Dt roundtrip 1 URM
.Sh NAME
.Nm roundtrip
Expand Down
2 changes: 1 addition & 1 deletion scripts/java/README
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ http://openbabel.org/wiki/Java

First of all, set some environment variables (remember to change the paths to correspond to your system):
$ export JAVA_HOME=/home/noel/Tools/jdk1.5.0_15
$ export OB_JAVADIR=/home/noel/Tools/openbabel-2.2.0/scripts/java
$ export OB_JAVADIR=/home/noel/Tools/openbabel-3.0.0/scripts/java
$ export OB_LIBDIR=/home/noel/tree/lib # The install location of libopenbabel.so

Next, compile the Java bindings:
Expand Down
2 changes: 1 addition & 1 deletion scripts/perl/META.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Chemistry-OpenBabel
version: 1.3
version: 1.4
version_from:
installdirs: site
requires:
Expand Down
4 changes: 2 additions & 2 deletions scripts/perl/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Chemistry::OpenBabel version 1.3
Chemistry::OpenBabel version 1.4
================================

This module provides a Perl interface to the Open Babel chemistry library.
Expand Down Expand Up @@ -34,7 +34,7 @@ installed Open Babel):
DEPENDENCIES

perl-5.6.0 or a more recent version.
openbabel-2.1 or a more recent version.
openbabel-3 or a more recent version.

Note that if you are trying to build/run this Perl code in the Open
Babel source/build directory BEFORE you install Open Babel, you may
Expand Down
6 changes: 3 additions & 3 deletions scripts/python/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Dependencies
------------

- Python 2.4 or a more recent version.
- Open Babel 2.3.0 or a more recent version.
- Open Babel 3 or a more recent version.

Installation
------------
Expand All @@ -45,8 +45,8 @@ Installation

::

tar -xzvf openbabel-1.8.1.tar.gz
cd openbabel-1.8.1
tar -xzvf openbabel-3-0-0.tar.gz
cd openbabel-openbabel-3-0-0
python setup.py install
**Option 3**: While building Open Babel itself.
Expand Down
32 changes: 18 additions & 14 deletions scripts/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def find_version():
def pkgconfig(package, option):
"""Wrapper around pkg-config command line tool."""
try:
return subprocess.check_output(['pkg-config', option, package]).strip()
return subprocess.check_output(['pkg-config', option, package],
universal_newlines=True).strip()
except subprocess.CalledProcessError:
raise Exception('Failed to run pkg-config')

Expand All @@ -41,17 +42,19 @@ def locate_ob():
"""Try use pkgconfig to locate Open Babel, otherwise guess default location."""
try:
# Warn if the (major, minor) version of the installed OB doesn't match these python bindings
ob_ver = StrictVersion(pkgconfig('openbabel-2.0', '--modversion'))
py_ver = StrictVersion(find_version())
py_major_ver, py_minor_ver = py_ver.version[:2]
pcfile = 'openbabel-{}'.format(py_major_ver)
ob_ver = StrictVersion(pkgconfig(pcfile, '--modversion'))
if not ob_ver.version[:2] == py_ver.version[:2]:
print('Warning: Open Babel %s.%s.x is required. Your version (%s) may not be compatible.'
% (py_ver.version[0], py_ver.version[1], ob_ver))
include_dirs = pkgconfig('openbabel-2.0', '--variable=pkgincludedir')
library_dirs = pkgconfig('openbabel-2.0', '--variable=libdir')
print('Warning: Open Babel {}.{}.x is required. Your version ({}) may not be compatible.'
.format(py_major_ver, py_minor_ver, ob_ver))
include_dirs = pkgconfig(pcfile, '--variable=pkgincludedir')
library_dirs = pkgconfig(pcfile, '--variable=libdir')
print('Open Babel location automatically determined by pkg-config:')
except Exception as e:
print('Warning: %s.\nGuessing Open Babel location:' % e)
include_dirs = '/usr/local/include/openbabel-2.0'
include_dirs = '/usr/local/include/openbabel3'
library_dirs = '/usr/local/lib'
return include_dirs, library_dirs

Expand Down Expand Up @@ -86,9 +89,9 @@ def finalize_options(self):
# Setting include_dirs, library_dirs, swig_opts here instead of in Extension constructor allows them to be
# overridden using -I and -L command line options to python setup.py build_ext.
build_ext.finalize_options(self)
include_dirs, library_dirs = locate_ob()
self.include_dirs.append(include_dirs)
self.library_dirs.append(library_dirs)
self.ob_include_dir, self.ob_library_dir = locate_ob()
self.include_dirs.append(self.ob_include_dir)
self.library_dirs.append(self.ob_library_dir)
self.swig_opts = ['-c++', '-small', '-O', '-templatereduce', '-naturalvar']
self.swig_opts += ['-I%s' % i for i in self.include_dirs]
print('- include_dirs: %s\n- library_dirs: %s' % (self.include_dirs, self.library_dirs))
Expand All @@ -97,11 +100,12 @@ def swig_sources(self, sources, extension):
try:
return build_ext.swig_sources(self, sources, extension)
except DistutilsExecError:
print('\nError: SWIG failed. Is Open Babel installed?\n'
print('\nError: SWIG failed. Is Open Babel installed?',
'You may need to manually specify the location of Open Babel include and library directories. '
'For example:\n'
' python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib\n'
' python setup.py install')
'For example:',
' python setup.py build_ext -I{} -L{}'.format(self.ob_include_dir, self.ob_library_dir),
' python setup.py install',
sep='\n')
sys.exit(1)


Expand Down
Loading

0 comments on commit f84536d

Please sign in to comment.