summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-03-30 19:50:48 +0200
committerChristoph Helma <helma@in-silico.ch>2016-03-30 19:50:48 +0200
commitb2094369d3352a6d4ff0a928a206a62015e36b61 (patch)
tree5edd469ac166ddbaae056cb83f94d09662ecf3c7
parent81c6e837e24ad503cc5d5c4954bf313e09a23200 (diff)
uses master branch from https://github.com/openbabel/openbabel.git, simplified installation, workarounds for previous versions removed
-rw-r--r--.gitignore1
-rw-r--r--ext/openbabel/extconf.rb110
-rw-r--r--lib/openbabel/version.rb2
-rw-r--r--openbabel.gemspec4
-rw-r--r--test/test_openbabel.rb1
5 files changed, 46 insertions, 72 deletions
diff --git a/.gitignore b/.gitignore
index 9eb254e..4040c6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
*.gem
.bundle
Gemfile.lock
-Makefile
pkg/*
diff --git a/ext/openbabel/extconf.rb b/ext/openbabel/extconf.rb
index aa90d76..7f2bf8b 100644
--- a/ext/openbabel/extconf.rb
+++ b/ext/openbabel/extconf.rb
@@ -1,83 +1,57 @@
require 'fileutils'
-require 'mkmf'
require 'rbconfig'
-$:.unshift File.expand_path('../../../lib', __FILE__)
-require 'openbabel/version'
+require 'mkmf'
+
+main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..",".."))
-ob_num_ver = OpenBabel::VERSION
-ob_ver = "openbabel-"+ob_num_ver
+# install OpenBabel
-RUBY=File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
+openbabel_version = "2.3.2"
-main_dir = File.expand_path(File.join(File.dirname(__FILE__),"..",".."))
-src_dir = File.join main_dir, ob_ver
-build_dir = File.join main_dir, "build"
-install_dir = main_dir
+openbabel_dir = File.join main_dir, "openbabel"
+src_dir = openbabel_dir
+build_dir = File.join src_dir, "build"
+install_dir = openbabel_dir
install_lib_dir = File.join install_dir, "lib"
-lib_dir = File.join main_dir, "lib", "openbabel"
+lib_dir = File.join openbabel_dir, "lib", "openbabel"
ruby_src_dir = File.join src_dir, "scripts", "ruby"
begin
- nr_processors = `grep processor /proc/cpuinfo | wc -l` # speed up compilation, Linux only
+ nr_processors = `getconf _NPROCESSORS_ONLN`.to_i # should be POSIX compatible
rescue
nr_processors = 1
end
-begin
- Dir.chdir main_dir do
- FileUtils.rm_rf src_dir
- puts "Downloading OpenBabel sources"
- system "curl -L -d use_mirror=netcologne 'http://downloads.sourceforge.net/project/openbabel/openbabel/#{ob_num_ver}/openbabel-#{ob_num_ver}.tar.gz' | tar xz"
- system "sed -i -e 's/-Wl,-flat_namespace//;s/-flat_namespace//' #{File.join ruby_src_dir, "extconf.rb"}" # remove unrecognized compiler option
- system "sed -i -e 's/Init_OpenBabel/Init_openbabel/g' #{File.join ruby_src_dir,"*cpp"}" # fix swig bindings
- system "sed -i -e 's/Config::CONFIG/RbConfig::CONFIG/' #{File.join src_dir, "scripts", "CMakeLists.txt" }" # fix Ruby Config
- system "sed -i -e 's/Config::CONFIG/RbConfig::CONFIG/' #{File.join ruby_src_dir, "extconf.rb" }" # fix Ruby Config
- end
- FileUtils.mkdir_p build_dir
- FileUtils.mkdir_p install_dir
- Dir.chdir build_dir do
- puts "Configuring OpenBabel"
- cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUBY_BINDINGS=ON"
- # set rpath for local installations
- # http://www.cmake.org/Wiki/CMake_RPATH_handling
- # http://vtk.1045678.n5.nabble.com/How-to-force-cmake-not-to-remove-install-rpath-td5721193.html
- cmake += " -DCMAKE_INSTALL_RPATH:STRING=\"#{install_lib_dir}\"" unless have_library('openbabel')
- system cmake
- end
- unless have_library('openbabel')
- # local installation in gem directory
- Dir.chdir build_dir do
- puts "OpenBabel not installed. Compiling sources."
- system "make -j#{nr_processors}"
- system "make install"
- ENV["PKG_CONFIG_PATH"] = File.dirname(File.expand_path(Dir["#{install_dir}/**/openbabel*pc"].first))
- end
- end
- # compile ruby bindings
- puts "Compiling and installing OpenBabel Ruby bindings."
- Dir.chdir ruby_src_dir do
- # fix rpath
- system "sed -i 's|with_ldflags.*$|with_ldflags(\"#\$LDFLAGS -dynamic -Wl,-rpath,#{install_lib_dir}\") do|' #{File.join(ruby_src_dir,'extconf.rb')}" unless have_library('openbabel')
- # get include and lib from pkg-config
- ob_include=`pkg-config openbabel-2.0 --cflags-only-I`.sub(/\s+/,'').sub(/-I/,'')
- ob_lib=`pkg-config openbabel-2.0 --libs-only-L`.sub(/\s+/,'').sub(/-L/,'')
- system "#{RUBY} extconf.rb --with-openbabel-include=#{ob_include} --with-openbabel-lib=#{ob_lib}"
- system "make -j#{nr_processors}"
- end
- FileUtils.cp(ruby_src_dir+"/openbabel.#{RbConfig::CONFIG["DLEXT"]}", "./")
- File.open('Makefile', 'w') do |makefile|
- makefile.write <<"EOF"
-.PHONY: openbabel.#{RbConfig::CONFIG["DLEXT"]}
-openbabel.#{RbConfig::CONFIG["DLEXT"]}:
- chmod 755 openbabel.#{RbConfig::CONFIG["DLEXT"]}
+FileUtils.mkdir_p openbabel_dir
+Dir.chdir main_dir do
+ FileUtils.rm_rf src_dir
+ puts "Downloading OpenBabel sources"
+ system "git clone https://github.com/openbabel/openbabel.git"
+end
+
+FileUtils.mkdir_p build_dir
+FileUtils.mkdir_p install_dir
+Dir.chdir build_dir do
+ puts "Configuring OpenBabel"
+ cmake = "cmake #{src_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir} -DBUILD_GUI=OFF -DENABLE_TESTS=OFF -DRUN_SWIG=ON -DRUBY_BINDINGS=ON"
+ # set rpath for local installations
+ # http://www.cmake.org/Wiki/CMake_RPATH_handling
+ # http://vtk.1045678.n5.nabble.com/How-to-force-cmake-not-to-remove-install-rpath-td5721193.html
+ cmake += " -DCMAKE_INSTALL_RPATH:STRING=\"#{install_lib_dir}\""
+ system cmake
+end
-.PHONY: install
-install:
- mkdir -p #{lib_dir}
- mv openbabel.#{RbConfig::CONFIG["DLEXT"]} #{lib_dir}
-EOF
- FileUtils.remove_entry_secure src_dir, build_dir
- end
-ensure
- # Do NOT remove scr_dir and build_dir after build fails, they are necessary for debugging.
+# local installation in gem directory
+Dir.chdir build_dir do
+ puts "Compiling OpenBabel sources."
+ system "make -j#{nr_processors}"
+ system "make install"
+ ENV["PKG_CONFIG_PATH"] = File.dirname(File.expand_path(Dir["#{install_dir}/**/openbabel*pc"].first))
end
+
+# create a fake Makefile
+File.open(File.join(File.dirname(__FILE__),"Makefile"),"w+") do |makefile|
+ makefile.puts "all:\n\ttrue\n\ninstall:\n\ttrue\n"
+end
+
+$makefile_created = true
diff --git a/lib/openbabel/version.rb b/lib/openbabel/version.rb
index fec4792..768e494 100644
--- a/lib/openbabel/version.rb
+++ b/lib/openbabel/version.rb
@@ -1,4 +1,4 @@
module OpenBabel
VERSION = '2.3.2'
- GEMVERSION = VERSION + '.1'
+ GEMVERSION = VERSION + '.2'
end
diff --git a/openbabel.gemspec b/openbabel.gemspec
index 4c8b6d6..7eff2e6 100644
--- a/openbabel.gemspec
+++ b/openbabel.gemspec
@@ -6,14 +6,14 @@ Gem::Specification.new do |s|
s.version = OpenBabel::GEMVERSION
s.authors = ["Andreas Maunz, Christoph Helma, Katsuhiko Nishimra"]
- s.date = %q{2012-04-03}
+ s.date = %q{2016-03-30}
s.description = %q{OpenBabel as a GEM}
s.email = ["andreas@maunz.de","helma@in-silico.ch"]
s.homepage = %q{http://github.com/opentox/openbabel-gem}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2}
s.summary = %q{OpenBabel!}
- s.license = "GPL-3"
+ s.license = "GPL-3.0"
s.test_files = ["test/test_openbabel.rb"]
s.files = %w{Rakefile lib/openbabel.rb lib/openbabel/version.rb}
diff --git a/test/test_openbabel.rb b/test/test_openbabel.rb
index ed4a19b..7e072af 100644
--- a/test/test_openbabel.rb
+++ b/test/test_openbabel.rb
@@ -3,6 +3,7 @@ require 'test/unit'
$:.unshift File.expand_path('../../lib', __FILE__)
$:.unshift File.expand_path('../../ext', __FILE__)
require 'openbabel'
+#require_relative '../openbabel/lib/openbabel'
include OpenBabel
class OBTest < Test::Unit::TestCase