- backport upstream patch to split Python binding (should fix #427700 for

good)
- drop no longer needed ppc64 SWIG/GCC flag hackery
This commit is contained in:
Kevin Kofler 2008-06-06 18:24:19 +00:00
parent 4bce72d62d
commit 8550af93ff
2 changed files with 460 additions and 9 deletions

View File

@ -0,0 +1,450 @@
Index: scripts/openbabel-python2.i
===================================================================
--- scripts/openbabel-python2.i (revision 0)
+++ scripts/openbabel-python2.i (revision 2535)
@@ -0,0 +1,92 @@
+%module obconversion
+
+%{
+// used to set import/export for Cygwin DLLs
+#ifdef WIN32
+#define USING_OBDLL
+#endif
+
+#include <openbabel/base.h>
+
+#include <openbabel/generic.h>
+#include <openbabel/griddata.h>
+#include <openbabel/math/vector3.h>
+#include <openbabel/bitvec.h>
+
+#include <openbabel/mol.h>
+#include <openbabel/obconversion.h>
+#include <openbabel/oberror.h>
+#include <openbabel/plugin.h>
+#include <openbabel/fingerprint.h>
+#include <openbabel/descriptor.h>
+#include <openbabel/format.h>
+#include <openbabel/forcefield.h>
+#include <openbabel/op.h>
+
+%}
+
+// These methods are renamed to valid Python method names, as otherwise
+// they cannot be used from Python
+%rename(inc) *::operator++;
+%rename(good) *::operator bool;
+
+%import <openbabel/babelconfig.h>
+
+%import <openbabel/base.h>
+%import <openbabel/generic.h>
+%import <openbabel/griddata.h>
+
+%import <openbabel/math/vector3.h>
+%import <openbabel/bitvec.h>
+
+%import <openbabel/chains.h>
+%import <openbabel/typer.h>
+
+%include <openbabel/plugin.h>
+%include <openbabel/oberror.h>
+%include <openbabel/format.h>
+%include <openbabel/obconversion.h>
+%import <openbabel/residue.h>
+%import <openbabel/internalcoord.h>
+%import <openbabel/atom.h>
+%import <openbabel/bond.h>
+%import <openbabel/mol.h>
+%import <openbabel/ring.h>
+%import <openbabel/parsmart.h>
+
+%include <openbabel/fingerprint.h>
+%include <openbabel/descriptor.h>
+%include <openbabel/forcefield.h>
+
+%include <openbabel/op.h>
+%include <openbabel/bitvec.h>
+
+%ignore *::operator=;
+
+%include "carrays.i"
+%array_class(double, doubleArray)
+%pythoncode %{
+def double_array(mylist):
+ """Create a C array of doubles from a list."""
+ c = doubleArray(len(mylist))
+ for i,v in enumerate(mylist):
+ c[i] = v
+ return c
+%}
+
+# Functions to set the log file to std::cout and std::cerr
+
+%ignore OBForceField::SetLogFile(std::ostream *pos);
+%extend OpenBabel::OBForceField {
+ void SetLogToStdOut()
+ {
+ self->SetLogFile(&std::cout);
+ }
+
+ void SetLogToStdErr()
+ {
+ self->SetLogFile(&std::cerr);
+ }
+};
+
+
Index: scripts/openbabel-python3.i
===================================================================
--- scripts/openbabel-python3.i (revision 0)
+++ scripts/openbabel-python3.i (revision 2535)
@@ -0,0 +1,65 @@
+%module obtemplate
+
+%{
+// used to set import/export for Cygwin DLLs
+#ifdef WIN32
+#define USING_OBDLL
+#endif
+
+#include <openbabel/base.h>
+#include <openbabel/mol.h>
+#include <openbabel/atom.h>
+#include <openbabel/bond.h>
+#include <openbabel/residue.h>
+#include <openbabel/ring.h>
+
+%}
+
+%include "std_list.i"
+%include "std_map.i"
+%include "std_vector.i"
+%include "std_string.i"
+
+namespace std {
+%template (vectorInt) vector<int>;
+%template (vectorUnsignedInt) vector<unsigned int>;
+%template (vvInt) vector< vector<int> >;
+%template (vectorDouble) vector<double>;
+%template (vectorString) vector<std::string>;
+%template (vVector3) vector<OpenBabel::vector3>;
+
+%template (vectorMol) vector<OpenBabel::OBMol>;
+%template (vectorBond) vector<OpenBabel::OBBond>;
+%template (vectorResidue) vector<OpenBabel::OBResidue>;
+%template (vectorRing) vector<OpenBabel::OBRing>;
+%template (vectorpRing) vector<OpenBabel::OBRing*>;
+%template (vectorData) vector<OpenBabel::OBGenericData*>;
+}
+
+// These methods are renamed to valid Python method names, as otherwise
+// they cannot be used from Python
+%rename(inc) *::operator++;
+%rename(good) *::operator bool;
+
+%import <openbabel/babelconfig.h>
+
+%import <openbabel/base.h>
+%import <openbabel/residue.h>
+%import <openbabel/atom.h>
+%import <openbabel/bond.h>
+%import <openbabel/mol.h>
+%import <openbabel/ring.h>
+
+%ignore *::operator=;
+
+%include "carrays.i"
+%array_class(double, doubleArray)
+%pythoncode %{
+def double_array(mylist):
+ """Create a C array of doubles from a list."""
+ c = doubleArray(len(mylist))
+ for i,v in enumerate(mylist):
+ c[i] = v
+ return c
+%}
+
Index: scripts/python/setup.py
===================================================================
--- scripts/python/setup.py (revision 2534)
+++ scripts/python/setup.py (revision 2535)
@@ -60,13 +60,27 @@
OBinclude,OBlibrary = find_likely_directory()
-obExtension = Extension('_openbabel',
- ['openbabel_python.cpp'],
- include_dirs=OBinclude,
- library_dirs=OBlibrary,
- libraries=['openbabel']
- )
+obCore = Extension('_obcore',
+ ['obcore.cpp'],
+ include_dirs=OBinclude,
+ library_dirs=OBlibrary,
+ libraries=['openbabel']
+ )
+obConversion = Extension('_obconversion',
+ ['obconversion.cpp'],
+ include_dirs=OBinclude,
+ library_dirs=OBlibrary,
+ libraries=['openbabel']
+ )
+
+obTemplate = Extension('_obtemplate',
+ ['obtemplate.cpp'],
+ include_dirs=OBinclude,
+ library_dirs=OBlibrary,
+ libraries=['openbabel']
+ )
+
setup(name='openbabel',
version='1.3',
author='Noel O\'Boyle',
@@ -74,7 +88,7 @@
url='http://openbabel.sourceforge.net/',
license='http://www.gnu.org/copyleft/gpl.html',
py_modules=['openbabel','pybel'],
- ext_modules=[obExtension],
+ ext_modules=[obCore, obConversion, obTemplate],
description = 'openbabel: Python interface to the Open Babel chemistry library',
classifiers=[
'Development Status :: 5 - Production/Stable',
Index: scripts/python/openbabel.py
===================================================================
--- scripts/python/openbabel.py (revision 0)
+++ scripts/python/openbabel.py (revision 2535)
@@ -0,0 +1,11 @@
+import sys
+if sys.platform.find("linux") != -1:
+ try:
+ import dl
+ except ImportError:
+ import DLFCN as dl
+ sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)
+
+import obcore
+import obconversion
+import obtemplate
Index: scripts/Makefile.in
===================================================================
--- scripts/Makefile.in (revision 2534)
+++ scripts/Makefile.in (revision 2535)
@@ -34,8 +34,12 @@
subdir = scripts
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.in
+am__aclocal_m4_deps = $(top_srcdir)/autoconf/libtool.m4 \
+ $(top_srcdir)/autoconf/ltoptions.m4 \
+ $(top_srcdir)/autoconf/ltsugar.m4 \
+ $(top_srcdir)/autoconf/ltversion.m4 \
+ $(top_srcdir)/autoconf/lt~obsolete.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -89,6 +93,7 @@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
@@ -98,6 +103,8 @@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@@ -173,6 +180,7 @@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = openbabel-perl.i perl \
@@ -185,9 +193,11 @@
# build the scripting language interfaces if --enable-maintainer-mode was set
# and SWIG is available -- please use the most recent version of SWIG
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@BUILT_SOURCES = perl/openbabel_perl.cpp \
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/openbabel_python.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ java/openbabel_java.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ csharp/openbabel_csharp.cpp \
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obcore.cpp \
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obconversion.cpp \
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ python/obtemplate.cpp \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(am__append_1)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@script_includes = $(top_srcdir)/include/openbabel
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@script_headers = $(script_includes)/mol.h $(script_includes)/obconversion.h \
@@ -386,20 +396,18 @@
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ sed -e "s/^@EXPORT.*/& sub dl_load_flags { 0x01 }/" <perl/OpenBabel.pm >perl/OpenBabel.new;
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ mv perl/OpenBabel.new perl/OpenBabel.pm;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/openbabel_python.cpp: openbabel-python.i $(script_headers)
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obconversion.cpp: openbabel-python2.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo "import sys" >python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo "if sys.platform.find(\"linux\") != -1:" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " try:" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " import dl" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " except ImportError:" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " import DLFCN as dl" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo " sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)" >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ echo >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ cat python/openbabel.py >>python/ob.py;
-@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ mv python/ob.py python/openbabel.py;
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obtemplate.cpp: openbabel-python3.i $(script_headers)
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
+
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@python/obcore.cpp: openbabel-python.i $(script_headers)
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -python -templatereduce -naturalvar \
+@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
+
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@java/openbabel_java.cpp: openbabel-java.i $(script_headers)
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ $(SWIG) -small -O -java -naturalvar -templatereduce -c++ -o $@ \
@BUILD_SWIG_TRUE@@MAINTAINER_MODE_TRUE@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
Index: scripts/perl/Makefile.PL
===================================================================
--- scripts/perl/Makefile.PL (revision 2534)
+++ scripts/perl/Makefile.PL (revision 2535)
@@ -9,9 +9,9 @@
# check if we're compiling in the source directory
$ldfrom = "\$(OBJECT) -L$srcdir/.libs -lopenbabel -lz"
+ if (-r "$srcdir/.libs/libopenbabel.dylib") and (-s _) and (-B _);
+$ldfrom = "\$(OBJECT) -L$srcdir/.libs -lopenbabel -lz"
if (-r "$srcdir/.libs/libopenbabel.so") and (-s _) and (-B _);
-$ldfrom = "\$(OBJECT) -L$srcdir/.libs -lopenbabel -lz"
- if (-r "$srcdir/.libs/libopenbabel.dylib") and (-s _) and (-B _);
$ldfrom = "\$(OBJECT) $srcdir/.libs/libopenbabel.a -lz"
if (-r "$srcdir/.libs/libopenbabel.a") and (-s _) and (-B _);
Index: scripts/Makefile.am
===================================================================
--- scripts/Makefile.am (revision 2534)
+++ scripts/Makefile.am (revision 2535)
@@ -20,8 +20,9 @@
if MAINTAINER_MODE
if BUILD_SWIG
-BUILT_SOURCES = perl/openbabel_perl.cpp python/openbabel_python.cpp \
- java/openbabel_java.cpp csharp/openbabel_csharp.cpp
+BUILT_SOURCES = perl/openbabel_perl.cpp \
+ java/openbabel_java.cpp csharp/openbabel_csharp.cpp \
+ python/obcore.cpp python/obconversion.cpp python/obtemplate.cpp
script_includes = $(top_srcdir)/include/openbabel
script_headers = $(script_includes)/mol.h $(script_includes)/obconversion.h \
@@ -34,20 +35,18 @@
sed -e "s/^@EXPORT.*/& sub dl_load_flags { 0x01 }/" <perl/OpenBabel.pm >perl/OpenBabel.new;
mv perl/OpenBabel.new perl/OpenBabel.pm;
-python/openbabel_python.cpp: openbabel-python.i $(script_headers)
+python/obconversion.cpp: openbabel-python2.i $(script_headers)
$(SWIG) -small -O -python -templatereduce -naturalvar \
-c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
- echo "import sys" >python/ob.py;
- echo "if sys.platform.find(\"linux\") != -1:" >>python/ob.py;
- echo " try:" >>python/ob.py;
- echo " import dl" >>python/ob.py;
- echo " except ImportError:" >>python/ob.py;
- echo " import DLFCN as dl" >>python/ob.py;
- echo " sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL)" >>python/ob.py;
- echo >>python/ob.py;
- cat python/openbabel.py >>python/ob.py;
- mv python/ob.py python/openbabel.py;
+python/obtemplate.cpp: openbabel-python3.i $(script_headers)
+ $(SWIG) -small -O -python -templatereduce -naturalvar \
+ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
+
+python/obcore.cpp: openbabel-python.i $(script_headers)
+ $(SWIG) -small -O -python -templatereduce -naturalvar \
+ -c++ -o $@ -I$(top_srcdir)/include -I$(top_builddir)/include $<;
+
java/openbabel_java.cpp: openbabel-java.i $(script_headers)
$(SWIG) -small -O -java -naturalvar -templatereduce -c++ -o $@ \
-I$(top_srcdir)/include -I$(top_builddir)/include $<;
Index: scripts/openbabel-python.i
===================================================================
--- scripts/openbabel-python.i (revision 2534)
+++ scripts/openbabel-python.i (revision 2535)
@@ -1,4 +1,4 @@
-%module openbabel
+%module obcore
%{
// used to set import/export for Cygwin DLLs
@@ -41,28 +41,6 @@
%}
-%include "std_list.i"
-%include "std_map.i"
-%include "std_vector.i"
-%include "std_string.i"
-
-namespace std {
-%template (vectorInt) vector<int>;
-%template (vectorUnsignedInt) vector<unsigned int>;
-%template (vvInt) vector< vector<int> >;
-%template (vectorDouble) vector<double>;
-%template (vectorString) vector<std::string>;
-%template (vVector3) vector<OpenBabel::vector3>;
-
-%template (vectorMol) vector<OpenBabel::OBMol>;
-%template (vectorBond) vector<OpenBabel::OBBond>;
-%template (vectorResidue) vector<OpenBabel::OBResidue>;
-%template (vectorRing) vector<OpenBabel::OBRing>;
-%template (vectorpRing) vector<OpenBabel::OBRing*>;
-%template (vectorData) vector<OpenBabel::OBGenericData*>;
-}
-
-
%inline %{
OpenBabel::OBPairData *toPairData(OpenBabel::OBGenericData *data) {
return (OpenBabel::OBPairData *) data;
@@ -95,11 +73,11 @@
//# %import <openbabel/bitvec.h>
%import <openbabel/typer.h>
-%include <openbabel/plugin.h>
+%import <openbabel/plugin.h>
-%include <openbabel/oberror.h>
-%include <openbabel/format.h>
-%include <openbabel/obconversion.h>
+%import <openbabel/oberror.h>
+%import <openbabel/format.h>
+%import <openbabel/obconversion.h>
%include <openbabel/residue.h>
%include <openbabel/internalcoord.h>
%include <openbabel/atom.h>
@@ -110,11 +88,11 @@
%include <openbabel/alias.h>
%include <openbabel/atomclass.h>
-%include <openbabel/fingerprint.h>
-%include <openbabel/descriptor.h>
-%include <openbabel/forcefield.h>
+%import <openbabel/fingerprint.h>
+%import <openbabel/descriptor.h>
+%import <openbabel/forcefield.h>
-%include <openbabel/op.h>
+%import <openbabel/op.h>
%include <openbabel/bitvec.h>

View File

@ -9,7 +9,7 @@
Name: openbabel
Version: 2.2.0
Release: 0.4.%{beta_ver}%{?dist}
Release: 0.5.%{beta_ver}%{?dist}
Summary: Chemistry software file format converter
License: GPLv2
Group: Applications/File
@ -17,6 +17,10 @@ URL: http://openbabel.sourceforge.net/
Source: http://dl.sourceforge.net/sourceforge/openbabel/%{name}-%{version}%{beta_str}.tar.gz
Patch: %{name}-gcc43.patch
Patch1: %{name}-rpm.patch
# backport upstream patch to split the huge Python binding:
# http://openbabel.svn.sourceforge.net/viewvc/openbabel?view=rev&revision=2535
# fixes ppc64 build (#427700)
Patch2: openbabel-python-ppc64.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: inchi-devel
BuildRequires: libtool
@ -90,16 +94,9 @@ Ruby wrapper for the Open Babel library.
%setup -q -n %{name}-%{version}%{beta_ver}
%patch -p1 -b .gcc43
%patch1 -p1 -b .r
%patch2 -p0 -b .python-ppc64
%build
%if 0%{?fedora} >= 9
%ifarch ppc64
# hackery to get rid of excess TOC1 entries
sed -i -e 's/-python /-python -fastdispatch /g' scripts/Makefile.am
export CFLAGS="$RPM_OPT_FLAGS -mno-sum-in-toc"
export CXXFLAGS="$RPM_OPT_FLAGS -mno-sum-in-toc"
%endif
%endif
# don't reference m4 include directory which isn't shipped in the tarball
# there's also a typo ("autconf" instead of "autoconf")
sed -i -e 's/ACLOCAL_AMFLAGS=/#ACLOCAL_AMFLAGS=/g' Makefile.am
@ -194,6 +191,10 @@ popd
%{ruby_sitearch}/openbabel.so
%changelog
* Fri Jun 06 2008 Kevin Kofler <Kevin@tigcc.ticalc.org> 2.2.0-0.5.b5
- backport upstream patch to split Python binding (should fix #427700 for good)
- drop no longer needed ppc64 SWIG/GCC flag hackery
* Thu May 29 2008 Kevin Kofler <Kevin@tigcc.ticalc.org> 2.2.0-0.4.b5
- update to 2.2.0 beta5