Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Open Babel #16508

Closed
wants to merge 5 commits into from

5 participants

@agiliopadua

Open source chemistry and molecular modeling file format conversion and
data analysis tools. Updated to Open Babel 2.3.2.

@agiliopadua agiliopadua Open Babel
Open source chemistry and molecular modeling file format conversion and
data analysis tools.
48e5da9
@jacknagel
Collaborator

Lots of removed code without any explanation...

Library/Formula/open-babel.rb
((43 lines not shown))
def install
- args = ["--disable-dependency-tracking",
- "--prefix=#{prefix}"]
- args << '--enable-maintainer-mode' if ARGV.build_head?
-
- system "./configure", *args
+ args = %W[ -DCMAKE_INSTALL_PREFIX=#{prefix} ]
+ args << '-DPYTHON_BINDINGS=ON' if build.include? 'python-bindings'
+ args << '-DBUILD_GUI=ON' if build.include? 'build-gui'
+ args << '-DCAIRO_INCLUDE_DIRS=/usr/local/include/cairo '\
+ '-DCAIRO_LIBRARIES=/usr/local/lib/libcairo.dylib' if build.include? 'png'
@jacknagel Collaborator

Can't hardcode /usr/local

I've corrected this.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@agiliopadua

I've tried compiling several language bindings with Openbabel 2.3.2.
Python and Java bindings compile fine.
Perl and Ruby bindings fail due to a problem in the build procedure.
Applying known patch 08_perl_cmakelists.diff does not completely solve the problem
I've posted a ticket #850 in the openbabel sourceforge.
It seems openbabel gives priority to support python bindings and support for other languages is falling behind.

@agiliopadua

Concerning your comment on "Lots of removed code without any explanation...", the build procedure completely changed between the previous version (based on configure) and the present one (based on cmake), therefore most of the previous formula is outdated.

@fredrikw

Just wanted to chime in and say that I just successfully installed open-babel with png support and python bindings with the formula in 4437292, although brew did complain about the python bindings were put in "lib".

@agiliopadua

Hi. Good to know! Can you give more details about the complaint? I don't get any...

$ brew install --python --png --java --gui open-babel
==> Downloading http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/open-babel-2.3.2.tar.gz
==> mkdir ../build
==> cd ../build
==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/open-babel/2.3.2 -DPYTHON_BINDINGS=ON -DJAVA_BINDINGS=ON -DBUILD_GUI=ON -DCAIRO_I
==> make
==> make install
==> Caveats
Language bindings will be installed to the same location as the
Open Babel libraries. To prepare to use the bindings, prepend the
install directory to the appropriate environment variable:
PYTHONPATH for Python, CLASSPATH for Java.
==> Summary
/usr/local/Cellar/open-babel/2.3.2: 280 files, 21M, built in 2.4 minutes

I end up with the python bindings openbabel.py, openbabel.pyc, pybel.py in /usr/local/lib without complaints...

@fredrikw

==> Downloading http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/open-babel-2.3.2.tar.gz
==> mkdir ../build
==> cd ../build
==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/open-babel/2.3.2 -DPYTHON_BINDINGS=ON -DCAIRO_INCLUDE_DIRS=/usr/local/Cellar/open-babel/2.3.2/
==> make
==> make install
==> Caveats
Language bindings will be installed to the same location as the
Open Babel libraries. To prepare to use the bindings, prepend the
install directory to the appropriate environment variable:
PYTHONPATH for Python, CLASSPATH for Java.
Warning: Non-libraries were installed to "lib".
Installing non-libraries to "lib" is bad practice.
The offending files are:
/usr/local/Cellar/open-babel/2.3.2/lib/openbabel.py
/usr/local/Cellar/open-babel/2.3.2/lib/pybel.py

@fredrikw

And:

brew --version
0.9.3

@agiliopadua

I also have 0.9.3. openbabel.pyc does not seem to offend.
The recommended place for python modules is lib/pythonX.Y/site-packages, but formulas built with cmake may not easily comply to this. Can try to fix it for python bindings but the same problem will pose for ruby, perl, etc. if these bindings compile successfully in the future. Better if this is solved upstream.

@agiliopadua agiliopadua Python modules now install to lib/python2.7/site-packages
modules openbabel.py and pybel.py are also byte-compiled.
b0e0013
@adamv
Owner

Please squash to a single commit for review

@talipovm

Thank you for the formula! It definitely needs to be in the main repository, as the new release of Open Babel contains really nice features, like png support.
For me this formula works perfect except support of python binding. Although the installation is successful, 'import openbabel' causes Python to crash. Is it a common problem with this formula?

@agiliopadua

I can 'import babel' and use the modules to do conversions without any problems...
Do you have PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib?

@talipovm

Yes, and that's what I got:

import openbabel
Fatal Python error: PyThreadState_Get: no current thread
zsh: abort (core dumped) python

Looks like the problem is not specific to openbabel (titanous/homebrew-gnuradio#7).
Probably, openbabel linked to the Apple's python rather than to Homebrew's. I'll check it out.

@agiliopadua

I don't have Homebrew's python installed.

@talipovm

[SOLVED] The problem was that cbind linked openbabel against Apple's python library in the /usr/lib, whereas I use Homebrew's python installed with the --Framework option. As a result, when I tried to import openbabel in python, I got 'Fatal Python error: PyThreadState_Get: no current thread'.

I found that lines 56-84 in the opencv.rb formula address this particular situation.
I just copied them into openbabel.rb, and cmake picked up the correct library.

@adamv
Owner

Probably needs to be squashed to a single commit for review.

@adamv adamv closed this pull request from a commit
@agiliopadua agiliopadua Open Babel 2.3.2
Closes #16508.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
27eebef
@adamv adamv closed this in 27eebef
@norioxkimura norioxkimura referenced this pull request from a commit in norioxkimura/homebrew
@agiliopadua agiliopadua Open Babel 2.3.2
Closes #16508.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
659393a
@guyzmo guyzmo referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@guyzmo guyzmo referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@cooljeanius cooljeanius referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@rajeeja rajeeja referenced this pull request from a commit
@agiliopadua agiliopadua Open Babel 2.3.2
Closes #16508.

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
63f379b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 10, 2012
  1. @agiliopadua

    Open Babel

    agiliopadua authored
    Open source chemistry and molecular modeling file format conversion and
    data analysis tools.
Commits on Dec 12, 2012
  1. @agiliopadua
  2. @agiliopadua

    Bug fix in deps.

    agiliopadua authored
Commits on Dec 13, 2012
  1. @agiliopadua

    Python modules now install to lib/python2.7/site-packages

    agiliopadua authored
    modules openbabel.py and pybel.py are also byte-compiled.
Commits on Dec 23, 2012
  1. @agiliopadua
This page is out of date. Refresh to see the latest.
Showing with 65 additions and 75 deletions.
  1. +65 −75 Library/Formula/open-babel.rb
View
140 Library/Formula/open-babel.rb
@@ -1,94 +1,84 @@
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
- homepage 'http://openbabel.org/'
- url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.2.3/openbabel-2.2.3.tar.gz'
- sha1 'e396b27551a106e001ca6c953181657a0a53f43f'
+ homepage 'http://www.openbabel.org'
+ url 'http://sourceforge.net/projects/openbabel/files/openbabel/2.3.2/openbabel-2.3.2.tar.gz'
+ 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
-
- def options
- [
- ["--perl", "Perl bindings"],
- ["--python", "Python bindings"],
- ["--ruby", "Ruby bindings"]
- ]
- end
+ 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'
def install
- args = ["--disable-dependency-tracking",
- "--prefix=#{prefix}"]
- args << '--enable-maintainer-mode' if ARGV.build_head?
+ 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'
- system "./configure", *args
- system "make"
- system "make install"
+ # 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
- ENV['OPENBABEL_INSTALL'] = prefix
+ args << '..'
- # 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
+ mkdir 'build' do
+ system "cmake", *args
+ system "make"
+ system "make install"
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
- system "make"
- system "make test"
- system "make install"
+ if build.include? 'python'
+ pydir = lib/which_python/'site-packages'
+ pydir.mkpath
+ mv lib/'openbabel.py', pydir
+ mv lib/'pybel.py', pydir
+ cd pydir do
+ `python -c 'import py_compile;py_compile.compile(\"openbabel.py\");py_compile.compile(\"pybel.py\")'`
end
end
+ 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}"
+ 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
- # Don't build i386 version when libopenbabel can't link to it.
- inreplace "Makefile", '-arch i386 ', ''
+ Java libraries are installed to #{HOMEBREW_PREFIX}/lib so this path should be
+ included in the CLASSPATH environment variable.
+ EOS
+ end
- # 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
- end
+ def which_python
+ "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
end
end
Something went wrong with that request. Please try again.