Skip to content

Loading…

Updated open-babel from 2.2.3 to 2.3.1 and HEAD. #11957

Closed
wants to merge 2 commits into from

2 participants

@rwest

The latest official release (2.3.1) requires eigen2 and doesn't work with
eigen3, which is in homebrew as "eigen"

Update: This open-babel formula now builds both 2.3.1 with eigen2
or --HEAD with eigen3.

@rwest

The above two commits are merged into one at rwest@448308e
The effect is to leave the old 2.2.3 formula, but add a working --HEAD option (recommended)

@adamv

Please squash to a single commit for review.

@rwest

Done (and rebased to current master).

@adamv

I'd rather update to the latest stable release than have a somewhat forked formula with such a large difference between stable and head.

@rwest

I agree, but the latest stable release requires eigen2 (fails with eigen3 - which is what is in homebrew). Any suggestions?

@adamv

Either submit an "eigen2" formula and depend on that, or see if we can package eigen2 as a subformula

rwest added some commits
@rwest rwest Added eigen2 formula for Eigen version 2.x
The eigen formula now points to Eigen 3.x. Some things depend on Eigen 2.x.
They can use this.
e99a06f
@rwest rwest New open-babel formula with version 2.3.1 and HEAD
2.3.1 is close enough to the --HEAD that the formula is not
too different for the two. The previous 2.2.3 was quite different.
One thing is that 2.3.1 requires eigen2 (does not work with eigen
which installs eigen v3).
98ba979
@rwest

OK, I have made an eigen2 formula and managed to get open-babel 2.3.1 to work.
It is much closer to the --HEAD and so the formula is not as forked any more.

@rwest

Is this now acceptable?

@adamv

@Sharpie @mistydemeo how should we be handling eigen? I don't use it to know what it's version-by-version story is.

@adamv

Eigen 2 is headers-only, right? So only needed at build time? Might be able to use it as a subformula.

@adamv adamv was assigned
@adamv

Closing in favor of #16508.

@adamv adamv closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2012
  1. @rwest

    Added eigen2 formula for Eigen version 2.x

    rwest committed
    The eigen formula now points to Eigen 3.x. Some things depend on Eigen 2.x.
    They can use this.
  2. @rwest

    New open-babel formula with version 2.3.1 and HEAD

    rwest committed
    2.3.1 is close enough to the --HEAD that the formula is not
    too different for the two. The previous 2.2.3 was quite different.
    One thing is that 2.3.1 requires eigen2 (does not work with eigen
    which installs eigen v3).
Showing with 92 additions and 60 deletions.
  1. +14 −0 Library/Formula/eigen2.rb
  2. +78 −60 Library/Formula/open-babel.rb
View
14 Library/Formula/eigen2.rb
@@ -0,0 +1,14 @@
+require 'formula'
+
+class Eigen2 < Formula
+ url 'http://bitbucket.org/eigen/eigen/get/2.0.17.tar.gz'
+ homepage 'http://eigen.tuxfamily.org/'
+ md5 'd13ad41c002b3d55cd241f6dbd83cc6c'
+
+ depends_on 'cmake' => :build
+
+ def install
+ system "cmake . #{std_cmake_parameters}"
+ system "make install"
+ end
+end
View
138 Library/Formula/open-babel.rb
@@ -5,6 +5,9 @@ def message; <<-EOS.undent
The oasa Python module is required for some operations.
It can be downloaded from:
http://bkchem.zirael.org/oasa_en.html
+ Or with the command:
+ pip install -f http://bkchem.zirael.org/ oasa==0.13.1
+ (may first require 'brew install py2cairo')
EOS
end
def satisfied?
@@ -13,82 +16,97 @@ def satisfied?
end
end
+def which_python
+ "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
+end
+
+def site_package_dir
+ "#{lib}/#{which_python}/site-packages"
+end
+
class OpenBabel < Formula
homepage 'http://openbabel.org/'
- url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.2.3/openbabel-2.2.3.tar.gz'
- md5 '7ea8845c54d6d3a9be378c78088af804'
-
+ url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.3.1/openbabel-2.3.1.tar.gz'
+ md5 '1f029b0add12a3b55582dc2c832b04f8'
head 'https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/trunk'
depends_on OasaPythonModule.new
- def options
- [
- ["--perl", "Perl bindings"],
- ["--python", "Python bindings"],
- ["--ruby", "Ruby bindings"]
- ]
+ if ARGV.build_head?
+ depends_on 'eigen' # eigen3
+ depends_on 'swig' => :build
+ else
+ depends_on 'eigen2'
end
+ depends_on 'cmake' => :build
+
def install
- args = ["--disable-dependency-tracking",
- "--prefix=#{prefix}"]
- args << '--enable-maintainer-mode' if ARGV.build_head?
-
- system "./configure", *args
- system "make"
- system "make install"
-
- ENV['OPENBABEL_INSTALL'] = prefix
-
- # Install the python bindings
- if ARGV.include? '--python'
- cd 'scripts/python' do
- system "python", "setup.py", "build"
- system "python", "setup.py", "install", "--prefix=#{prefix}"
- end
+ ENV.deparallelize
+ args = std_cmake_parameters.split
+ if ARGV.build_head?
+ args << "-DEIGEN3_INCLUDE_DIR='#{HOMEBREW_PREFIX}/include/eigen3'"
+ else
+ args << "-DEIGEN2_INCLUDE_DIR='#{HOMEBREW_PREFIX}/include/eigen2'"
end
+ args << '-DPYTHON_BINDINGS=ON'
+ args << '-DRUN_SWIG=TRUE' if ARGV.build_head?
- # Install the perl bindings.
- if ARGV.include? '--perl'
- cd 'scripts/perl' do
- # because it's not yet been linked, the perl script won't find the newly
- # compiled library unless we pass it in as LD_LIBRARY_PATH.
- ENV['LD_LIBRARY_PATH'] = "lib"
- system 'perl', 'Makefile.PL'
- # With the additional argument "PREFIX=#{prefix}" it puts things in #{prefix} (where perl can't find them).
- # Without, it puts them in /Library/Perl/...
- inreplace "Makefile" do |s|
- # Fix the broken Makefile (-bundle not allowed with -dynamiclib).
- # I think this is a SWIG error, but I'm not sure.
- s.gsub! '-bundle ', ''
- # Don't waste time building PPC version.
- s.gsub! '-arch ppc ', ''
- # Don't build i386 version when libopenbabel can't link to it.
- s.gsub! '-arch i386 ', ''
- end
- system "make"
- system "make test"
- system "make install"
+ # This block is copied from opencv.rb formula:
+ #
+ # The CMake `FindPythonLibs` Module is dumber than a bag of hammers when
+ # more than one python installation is available---for example, it clings
+ # to the Header folder of the system Python Framework like a drowning
+ # sailor.
+ #
+ # This code was cribbed from the VTK formula and uses the output to
+ # `python-config` to do the job FindPythonLibs should be doing in the first
+ # place.
+ python_prefix = `python-config --prefix`.strip
+ # Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
+ if File.exist? "#{python_prefix}/Python"
+ # Python was compiled with --framework:
+ args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
+ args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
+ else
+ python_lib = "#{python_prefix}/lib/lib#{which_python}"
+ if File.exists? "#{python_lib}.a"
+ args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
+ else
+ args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
end
+ args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
end
- # Install the ruby bindings.
- if ARGV.include? '--ruby'
- cd 'scripts/ruby' do
- system "ruby", "extconf.rb",
- "--with-openbabel-include=#{include}",
- "--with-openbabel-lib=#{lib}"
+ args << '.'
- # Don't build i386 version when libopenbabel can't link to it.
- inreplace "Makefile", '-arch i386 ', ''
+ # The cmake script for 2.3.1 tries to guess where the compiled module ought
+ # to live, and often gets it wrong. We know where we put it, so tell it:
+ inreplace 'scripts/CMakeLists.txt', '${PYTHON_LIB_PATH}/_openbabel.so', "#{site_package_dir}/_openbabel.so" unless ARGV.build_head?
- # With the following line it puts things in #{prefix} (where ruby can't find them).
- # Without, it puts them in /Library/Ruby/...
- #ENV['DESTDIR']=prefix
- system "make"
- system "make install"
- end
+ system "cmake", *args
+ system "make"
+ system "make install"
+
+ if ARGV.build_head?
+ # The simplified build system on the HEAD doesn't put the python stuff in
+ # the right place so we have to move it into #{site_package_dir}
+ mkdir_p site_package_dir
+ mv ["#{lib}/_openbabel.so", "#{lib}/openbabel.py", "#{lib}/pybel.py"], site_package_dir
end
+ # remove the spurious cmake folders from lib
+ rmtree "#{lib}/cmake"
+
+ end
+
+ def caveats; <<-EOS.undent
+ The Python bindings were installed to #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
+ so you may need to update your PYTHONPATH like so:
+ export PYTHONPATH="#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:$PYTHONPATH"
+ To make this permanent, put it in your shell's profile (e.g. ~/.profile).
+
+ To draw images from python, you will need to get the oasa Python module:
+ pip install -f http://bkchem.zirael.org/ oasa==0.13.1
+ EOS
end
end
Something went wrong with that request. Please try again.