Open Babel 2.3.2

Closes Homebrew/homebrew#16508.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
master
Agilio Padua 2012-12-10 22:08:15 +01:00 committed by Adam Vandenberg
parent c18f402812
commit 770cbfe796
1 changed files with 64 additions and 76 deletions

View File

@ -1,94 +1,82 @@
require 'formula' require 'formula'
class OasaPythonModule < Requirement
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
EOS
end
def satisfied?
args = %W{/usr/bin/env python -c import\ oasa}
quiet_system *args
end
end
class OpenBabel < Formula class OpenBabel < Formula
homepage 'http://openbabel.org/' homepage 'http://www.openbabel.org'
url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.2.3/openbabel-2.2.3.tar.gz' url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz'
sha1 'e396b27551a106e001ca6c953181657a0a53f43f' sha1 'b8831a308617d1c78a790479523e43524f07d50d'
head 'https://openbabel.svn.sourceforge.net/svnroot/openbabel/openbabel/trunk' option 'gui', 'Build the Graphical User Interface'
option 'png', 'Support PNG depiction'
option 'python', 'Compile Python language bindings'
option 'java', 'Compile Java language bindings'
depends_on OasaPythonModule.new depends_on 'cmake' => :build
depends_on 'wxmac' if build.include? 'gui'
def options depends_on 'cairo' if build.include? 'png'
[ depends_on 'eigen' if build.include? 'python'
["--perl", "Perl bindings"], depends_on 'eigen' if build.include? 'java'
["--python", "Python bindings"],
["--ruby", "Ruby bindings"]
]
end
def install def install
args = ["--disable-dependency-tracking", args = %W[ -DCMAKE_INSTALL_PREFIX=#{prefix} ]
"--prefix=#{prefix}"] args << "-DPYTHON_BINDINGS=ON" if build.include? 'python'
args << '--enable-maintainer-mode' if ARGV.build_head? args << "-DJAVA_BINDINGS=ON" if build.include? 'java'
args << "-DBUILD_GUI=ON" if build.include? 'gui'
args << "-DCAIRO_INCLUDE_DIRS=#{include}/cairo "\
"-DCAIRO_LIBRARIES=#{lib}/libcairo.dylib" if build.include? 'png'
system "./configure", *args # Find the right pyhton installation (code from opencv.rb)
system "make" if build.include? 'python'
system "make install" python_prefix = `python-config --prefix`.strip
# Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
ENV['OPENBABEL_INSTALL'] = prefix if File.exist? "#{python_prefix}/Python"
# Python was compiled with --framework:
# Install the python bindings args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
if ARGV.include? '--python' if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
cd 'scripts/python' do # For Xcode-only systems, the headers of system's python are inside of Xcode
system "python", "setup.py", "build" args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
system "python", "setup.py", "install", "--prefix=#{prefix}" else
end args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
end
# 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 end
system "make" else
system "make test" python_lib = "#{python_prefix}/lib/lib#{which_python}"
system "make install" 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 end
args << "-DPYTHON_PACKAGES_PATH='#{lib}/#{which_python}/site-packages'"
end end
# Install the ruby bindings. args << '..'
if ARGV.include? '--ruby'
cd 'scripts/ruby' do
system "ruby", "extconf.rb",
"--with-openbabel-include=#{include}",
"--with-openbabel-lib=#{lib}"
# Don't build i386 version when libopenbabel can't link to it. mkdir 'build' do
inreplace "Makefile", '-arch i386 ', '' system "cmake", *args
system "make"
system "make install"
end
# With the following line it puts things in #{prefix} (where ruby can't find them). if build.include? 'python'
# Without, it puts them in /Library/Ruby/... pydir = lib/which_python/'site-packages'
#ENV['DESTDIR']=prefix pydir.install lib/'openbabel.py', lib/'pybel.py'
system "make" cd pydir do
system "make install" `python -c 'import py_compile;py_compile.compile(\"openbabel.py\");py_compile.compile(\"pybel.py\")'`
end end
end end
end end
def caveats; <<-EOS.undent
Python modules are installed to #{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages
so the PYTHONPATH environment variable should include the paths
#{HOMEBREW_PREFIX}/lib/#{which_python}/site-packages:#{HOMEBREW_PREFIX}/lib
Java libraries are installed to #{HOMEBREW_PREFIX}/lib so this path should be
included in the CLASSPATH environment variable.
EOS
end
def which_python
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
end
end end