Rubygems, native ruby extensions (and their dependencies)

The title might not be all too clear but here goes:

I'm looking into alternatives for installing my ruby extension library (which is used by some utility applications). I've looked at install.rb, setup.rb, rubyscript2exe/tar2rubyscript and finally RubyGems. Even if I'll right now only will be doing local installations I find RubyGems my current favorite - just some questions:

- How should I handle native ruby extensions (building them at install time is not an option here). Part of the library is implemented natively (Win32 for now).

- How should I handle the native ruby extensions' dependencies (e.g. myrubyext.dll depends on boost-regex-...dll)? Where would such files go[1]?

- [a bit off-topic] Should/could I install applications through RubyGems as well? Any special considerations with regards to application-specific configuration files, invoking the application etc. Ideally I'd just like the user to be able to run <myappname-without-rb-extension> from the command line after installation.

Thanks // Johan

[1] For now I've made a hack where such dlls are put in the same directory as the extension dll - I then load the extension through myrubyextrb.rb, which on it's first line manipulates ENV['PATH'] to include the current directory.

- How should I handle native ruby extensions (building them at install time
is not an option here). Part of the library is implemented natively (Win32
for now).

I released my first binary gem yesterday. What I did: I compiled the gem
software locally on my own machine. Then used the same gemspec I used for
the source distribution with the following changes:

(1) removed the extension
(2) added the arch directory in the lib list
(3) included the .so file in the list of included files.

It seems to be working. It is the x10-cm17a gem for the windows platform if
anyone is interested in trying it.

The rake task for building gems is broken with regard to binary gems. I'll
fix that for the next rake release.

- How should I handle the native ruby extensions' dependencies (e.g.
myrubyext.dll depends on boost-regex-...dll)? Where would such files go[1]?

There is a requirements field in the gemspec that where you can list the
dependencies. This is for comment purposes only, we don't do autodetection
of non-gem dependencies.

- [a bit off-topic] Should/could I install applications through RubyGems as
well? Any special considerations with regards to application-specific
configuration files, invoking the application etc. Ideally I'd just like
the user to be able to run <myappname-without-rb-extension> from the
command line after installation.

I've released applications as gems. Rake is a prime example.

···

On Wednesday 19 January 2005 03:41 am, Johan Nilsson wrote:

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

"Jim Weirich" <jim@weirichhouse.org> wrote in message news:200501190718.30178.jim@weirichhouse.org...

- How should I handle native ruby extensions (building them at install time
is not an option here). Part of the library is implemented natively (Win32
for now).

I released my first binary gem yesterday. What I did: I compiled the gem
software locally on my own machine. Then used the same gemspec I used for
the source distribution with the following changes:

(1) removed the extension

From what? It might be obvious, but please treat me like a total beginner.

(2) added the arch directory in the lib list

Ok, sorry for being ignorant again, but what's the 'arch' directory?

(3) included the .so file in the list of included files.

It seems to be working. It is the x10-cm17a gem for the windows platform if
anyone is interested in trying it.

The rake task for building gems is broken with regard to binary gems. I'll
fix that for the next rake release.

Hmmm, I haven't looked at using rake at all; I was merely trying to put together a gemspec.

- How should I handle the native ruby extensions' dependencies (e.g.
myrubyext.dll depends on boost-regex-...dll)? Where would such files go[1]?

There is a requirements field in the gemspec that where you can list the
dependencies. This is for comment purposes only, we don't do autodetection
of non-gem dependencies.

Could you expand on that a bit - do you mean that:

- The user would him/herself manually have to install such dependencies
- It's not possible to submit them as part of the gem?

- [a bit off-topic] Should/could I install applications through RubyGems as
well? Any special considerations with regards to application-specific
configuration files, invoking the application etc. Ideally I'd just like
the user to be able to run <myappname-without-rb-extension> from the
command line after installation.

I've released applications as gems. Rake is a prime example.

I'll take a look.

Many thanks // Johan

···

On Wednesday 19 January 2005 03:41 am, Johan Nilsson wrote:

"Jim Weirich" <jim@weirichhouse.org> wrote in message
news:200501190718.30178.jim@weirichhouse.org...

>> - How should I handle native ruby extensions (building them at install
>> time
>> is not an option here). Part of the library is implemented natively
>> (Win32
>> for now).
>
> I released my first binary gem yesterday. What I did: I compiled the gem
> software locally on my own machine. Then used the same gemspec I used
> for the source distribution with the following changes:
>
> (1) removed the extension

From what? It might be obvious, but please treat me like a total beginner.

Just to be clear, I had a gemspec for the project (x10-cm17a) that created a
non-binary gem. I started with that gemspec and made the following changes..

(1) The gemspec has an extension field that is filled out if you have
extensions to build. Because the extension is already built when you
distribute an binary gem, you shouldn't set the extension field.

(2) The "arch" directory is a directory that contains the .so files for a
particular architecture. The directory is usually named something like
i386-mswin32 or i686-linux. You can get the name of the arch directory from
the ruby config, e.g.

   require 'rbconfig'
   ARCH = Config::CONFIG['arch']

The 'lib' field of the gemspec is a list if directories to be added to the
load path when the gem is loaded. You need to add the arch directory to that
list. The resulting line will look like this:

  s.require_paths << 'lib' << "lib/#{ARCH}"

(3) The list of files to be included with the gem need to be updated to
include the .so file. I added the following line to append the .so file to
the list of files:

  s.files += ["lib/#{ARCH}/cm17a_api.so"]

(4) Forget to mention this earlier, but I changed the gemspec platform from
the default of 'RUBY' to ARCH (see the definition of ARCH in step 2 above.

  s.platform = ARCH

I've included the modified Rakefile that I used to build the gemspec as an
attachment. That will give the complete details.

> There is a requirements field in the gemspec that where you can list the
> dependencies. This is for comment purposes only, we don't do
> autodetection
> of non-gem dependencies.

Could you expand on that a bit - do you mean that:

- The user would him/herself manually have to install such dependencies
- It's not possible to submit them as part of the gem?

Essentially, yes.

Rakefile (4.63 KB)

···

On Friday 21 January 2005 03:00 am, Johan Nilsson wrote:

> On Wednesday 19 January 2005 03:41 am, Johan Nilsson wrote:

--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)