setup.rb question
by Bill Kelly » Sat, 25 Jun 2005 07:07:04 GMT
Hi,
I'm packaging a ruby extension, and want setup.rb to perform
a particular part of the install only on a particular platform.
I figure others may have dealt with this with their own
extensions, and I was wondering how it's usually done.
On win32, I'm including a pre-built .dll that my extension
requires, because it's kind of a pain to build on windows.
I've put the .dll in the bin/ directory - and setup.rb does
the right thing (for windows) and installs the .dll alongside
the ruby.exe binary, wherever that may be on the system.
However, on Linux, the shared library .so's needed by the
extension a) are easy to build, so I see no need to include
pre-built ones, and b) don't belong next to the ruby
executable anyway... and c) I certainly don't want the
win32 .dll copied into /usr/bin or wherever on Linux. :)
So my question is how to have setup.rb do the right thing
on windows with the files in ./bin (which it currently is)...
and basically ignore the files in ./bin on Linux.
Is it typical to just hack setup.rb to add the desired
behavior? Just wondering how it's usually done.
Thanks,
Bill
Re: setup.rb question
by Timothy Hunter » Sat, 25 Jun 2005 08:13:08 GMT
setup.rb support a set of 8 "hooks" that you might be able to leverage.
You can create a hook to run before or after each of setup's config,
setup, install, and clean steps. Each hook is just a fragment of Ruby
code that setup runs if it's present. Setup defines a few APIs that the
hook code can use to find out about the configuration.
( http://www.**--****.com/ )
Just thinking out loud, maybe you could put the .dll somewhere other
than bin (to keep setup from automatically installing it) and then
create a post-install hook that copied the .dll only for Windows installs.
There's probably a better way but still I don't think you should have to
hack setup.rb itself.
Re: setup.rb question
by Aredridel » Sat, 25 Jun 2005 09:04:02 GMT
> Is it typical to just hack setup.rb to add the desired
Yup. Hack as needed.
Ari
Re: setup.rb question
by Bill Kelly » Sat, 25 Jun 2005 09:27:05 GMT
From: "Timothy Hunter" < XXXX@XXXXX.COM >
Cool, thanks!
It was as simple as creating a post-install.rb containing:
case RUBY_PLATFORM
when /mswin32/
install "./my/win32/library.dll", config('bindir'), 0555
end
=D
Thanks,
Bill
Similar Threads:
1.[ANN] Ruby Setup 5 (setup.rb)
2.Package, a future replacement for setup.rb and mkmf.rb
3.setup.rb problems and possible fix
As I reported earlier there seems to be some issues with setup.rb.
After investingating deeper it appears that there may be some very odd
bugs lurking within. There's is a lot of good code in their, but I'm
starting to think it may need a fresh rewrite. Of course, it doesn't
help that Minero whas not responded to my emails, and appearnetly does
not frequent this list.
The issue I'm currently facing is that setup.rb does not seem to be
handling --prefix correctly. While most things get the prefix, the lib/
directory does not. Looking at the code one sees these relavent pieces.
def install_dir_lib(rel)
install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
end
def install_files(list, dest, mode)
mkdir_p dest, @config.install_prefix
list.each do |fname|
install fname, dest, mode, @config.install_prefix
end
end
def mkdir_p(dirname, prefix = nil)
dirname = prefix + File.expand_path(dirname) if prefix
$stderr.puts "mkdir -p #{dirname}" if verbose?
return if no_harm?
# Does not check '/', it's too abnormal.
dirs = File.expand_path(dirname).split(%r<(?=/)>)
if /\A[a-z]:\z/i =~ dirs[0]
disk = dirs.shift
dirs[0] = disk + dirs[0]
end
dirs.each_index do |idx|
path = dirs[0..idx].join('')
Dir.mkdir path unless File.dir?(path)
end
end
Looking at this code one would expect that @config.install_prefix would
hold the value of the --prefix command line option. But oddly it does
not --I'm almost inclined to think that this is unintended in itself.
But assuming that's not how it's supposed to be, then obviously
config('rbdir') must contain the prefix. But it doesn't. The other
similiar config dirs do, config('bindir'), config('datadir'), etc. But
not 'rbdir', which leads me to think that it should actually be
'libdir'.
T.
P.S. Although I've now subscribed to the RubyGems mailing list and
posted my simple solution to the datadir problem, no one has responded
whatsoever.
4.setup.rb metaconfig
Anyone have a real iusecase of setup.rb's "metaconfig" ability? I'm
curious as to how useful this capability really is.
Thanks,
T.
5.RubyNodes gems and setup.rb failing....
6. State of the art in setup.rb land?
7. setup.rb and shared data
8. need to run setup.rb after 'gem install facets'