2010-08-20 17:42:07 +00:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
class OpenBabel < Formula
|
2012-12-10 21:08:15 +00:00
|
|
|
homepage 'http://www.openbabel.org'
|
|
|
|
url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz'
|
|
|
|
sha1 'b8831a308617d1c78a790479523e43524f07d50d'
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
option 'gui', 'Build the Graphical User Interface'
|
|
|
|
option 'png', 'Support PNG depiction'
|
|
|
|
option 'python', 'Compile Python language bindings'
|
|
|
|
option 'java', 'Compile Java language bindings'
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
depends_on 'cmake' => :build
|
|
|
|
depends_on 'wxmac' if build.include? 'gui'
|
|
|
|
depends_on 'cairo' if build.include? 'png'
|
|
|
|
depends_on 'eigen' if build.include? 'python'
|
|
|
|
depends_on 'eigen' if build.include? 'java'
|
2010-08-20 17:42:07 +00:00
|
|
|
|
|
|
|
def install
|
2012-12-10 21:08:15 +00:00
|
|
|
args = %W[ -DCMAKE_INSTALL_PREFIX=#{prefix} ]
|
|
|
|
args << "-DPYTHON_BINDINGS=ON" if build.include? 'python'
|
|
|
|
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'
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
# Find the right pyhton installation (code from opencv.rb)
|
|
|
|
if build.include? 'python'
|
|
|
|
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'"
|
|
|
|
if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
|
|
|
|
# For Xcode-only systems, the headers of system's python are inside of Xcode
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
|
|
|
|
else
|
|
|
|
args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
|
|
|
|
end
|
|
|
|
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
|
|
|
|
args << "-DPYTHON_PACKAGES_PATH='#{lib}/#{which_python}/site-packages'"
|
|
|
|
end
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
args << '..'
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
mkdir 'build' do
|
|
|
|
system "cmake", *args
|
|
|
|
system "make"
|
|
|
|
system "make install"
|
2010-08-20 17:42:07 +00:00
|
|
|
end
|
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
if build.include? 'python'
|
|
|
|
pydir = lib/which_python/'site-packages'
|
|
|
|
pydir.install lib/'openbabel.py', lib/'pybel.py'
|
|
|
|
cd pydir do
|
|
|
|
`python -c 'import py_compile;py_compile.compile(\"openbabel.py\");py_compile.compile(\"pybel.py\")'`
|
2010-08-20 17:42:07 +00:00
|
|
|
end
|
|
|
|
end
|
2012-12-10 21:08:15 +00:00
|
|
|
end
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
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
|
2012-03-11 20:16:36 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
Java libraries are installed to #{HOMEBREW_PREFIX}/lib so this path should be
|
|
|
|
included in the CLASSPATH environment variable.
|
|
|
|
EOS
|
|
|
|
end
|
2010-08-20 17:42:07 +00:00
|
|
|
|
2012-12-10 21:08:15 +00:00
|
|
|
def which_python
|
|
|
|
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
|
2010-08-20 17:42:07 +00:00
|
|
|
end
|
|
|
|
end
|