On 4/13/07, Graham Miller <[EMAIL PROTECTED]> wrote:
> So I guess my question would be: what is the best way to install a gem onto
> a machine without having to do the native compilation step?
I had a similar problem, with very little testing (so far), try this
script, if you have any problems let me know.
pth
---------------------------------------------
#!/usr/bin/env ruby -w
require "rbconfig"
require "rubygems"
require "pp"
require "tmpdir"
require "find"
require "fileutils"
Gem.manage_gems
unless gem = ARGV.first
puts "You must provide the name of a gem on the command line."
exit 1
end
gi = Gem::Installer.new(gem)
format = Gem::Format.from_file_by_path(gem)
dir = File.join(Dir.tmpdir, "gembuilder")
FileUtils.rm_r(dir) rescue nil
puts "Unpacking gem"
gi.unpack(dir)
gi.build_extensions(dir, format.spec)
files = []
Find.find(dir) do |fname|
next if fname == dir
files << fname.sub(Regexp.quote(dir+"/"),'')
end
spec = format.spec
spec.extensions = []
spec.files += (files - format.spec.files)
spec.platform = Config::CONFIG['arch'].sub(/[\.0-9]*$/, '')
puts "Building gem in #{dir}"
start_dir = Dir.pwd
Dir.chdir(dir) do
gb = Gem::Builder.new(spec)
gb.build
FileUtils.mv Dir.glob("*.gem"), start_dir
end
puts "Cleaning up #{dir}"
FileUtils.rm_rf(dir)
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers