Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [ANN] RubyScript2Exe 0.2.0

Reply
Thread Tools

[ANN] RubyScript2Exe 0.2.0

 
 
Erik Veenstra
Guest
Posts: n/a
 
      12-08-2004

I just want to say that RubyScript2Exe 0.2.0 [1] has been
released. Both Windows and Linux are supported.

gegroet,
Erik V.

[1] http://www.erikveen.dds.nl/rubyscript2exe/index.html

----------------------------------------------------------------

RubyScript2Exe transforms your Ruby script into a standalone
Windows or Linux executable. You can look at it as a
"compiler". Not in the sense of a source-code-to-byte-code
compiler, but as a "collector", for it collects all necessary
files to run your script on an other machine: the Ruby script,
the Ruby interpreter and the Ruby runtime library (stripped
down for this script). Anyway, the result is the same: a
standalone exe-file (Windows) or bin-file (Linux). And that's
what we want!

Because of the gathering of files from your own Ruby
installation, RubyScript2Exe creates an executable for the
platform it's being run on. No cross compile.

And when I say Windows, I mean both Windows (RubyInstaller,
MinGW and MSWin32) and Cygwin. But the generated exe under
Cygwin is very, very big, because its exe's are very big
(static?) and it includes cygwin1.dll, so it can run on
machines without Cygwin.

----------------------------------------------------------------

 
Reply With Quote
 
 
 
 
Florian Gross
Guest
Posts: n/a
 
      12-08-2004
Erik Veenstra wrote:

> I just want to say that RubyScript2Exe 0.2.0 [1] has been
> released. Both Windows and Linux are supported.


Is a change list available somewhere? I couldn't find one on the homepage.

Also while I'm writing to you, would it be possible to allow custom
..DLLs and resources to be added? I have an application that uses a C++
extension which loads more .DLLs -- RubyScript2Exe does not
automatically include those and I can't find a way of manually including
them that works. (I can unpack and repackage, but then the .DLLs will
still not get loaded from the temporary directory.)

Being able to easily include own media would also be very nifty in my
use case. (I'm writing games with Ruby -- it's always nice to have a
single EXE distribution that contains all the game media.)

Thank you for a great library!
 
Reply With Quote
 
 
 
 
Erik Veenstra
Guest
Posts: n/a
 
      12-08-2004
On Wed, 08 Dec 2004 15:16:02 +0100, Florian Gross wrote:

> Erik Veenstra wrote:
>
> > I just want to say that RubyScript2Exe 0.2.0 [1] has been
> > released. Both Windows and Linux are supported.

>
> Is a change list available somewhere? I couldn't find one on
> the homepage.


It's there, really... The Download section [1] has a link to
both [2] and [3]. I think you are interested in [2].

> Also while I'm writing to you, would it be possible to allow
> custom .DLLs and resources to be added? I have an application
> that uses a C++ extension which loads more .DLLs --
> RubyScript2Exe does not automatically include those and I
> can't find a way of manually including them that works. (I
> can unpack and repackage, but then the .DLLs will still not
> get loaded from the temporary directory.)


There's a link to Tar2RubyScript [4] on the page as well.
Tar2RubyScript generates a standalone Ruby script from an
existing directory, which contains a complete Ruby application
(scripts, DLL's and resources). This standalone Ruby script can
be converted to an executable with RubyScript2Exe.

That's how I distribute all my applications, complete with
resources, help files, licenses, readme, images, default
configurations, everything. Even including the graphical front
end (WXRuby or RubyWebDialogs [5]). And it just works...

> Being able to easily include own media would also be very
> nifty in my use case. (I'm writing games with Ruby -- it's
> always nice to have a single EXE distribution that contains
> all the game media.)
>
> Thank you for a great library!


[1] http://www.erikveen.dds.nl/rubyscrip...ml#6..Download
[2] http://www.erikveen.dds.nl/rubyscript2exe/download.html
[3] http://www.erikveen.dds.nl/rubyscrip...story.txt.html
[4] http://www.erikveen.dds.nl/tar2rubyscript/index.html
[5] http://www.erikveen.dds.nl/rubywebdialogs/index.html

 
Reply With Quote
 
Erik Veenstra
Guest
Posts: n/a
 
      12-08-2004
> "Erik Veenstra" <(E-Mail Removed)> wrote in message
>
> > I just want to say that RubyScript2Exe 0.2.0 [1] has been
> > released. Both Windows and Linux are supported.

>
> Will this support all manner of 'require'd files, including
> those loaded by the gems require-hack?


Never worked with gems before...

I did a test (on Linux) with the progressbar example. Yes,
RubyScript2Exe detects progressbar.rb [1] and yes, it is
included in the executable [2]. But when the executable is run,
require_gem only searches for progressbar.rb in its own dirs,
not in the regular places. Resulting in an Gem::LoadError. If I
catch this exception, it does work. See below.

I'll have a look at it.

Thanks.

gegroet,
Erik V.

[1] /usr/local/lib/ruby/gems/1.8/gems/progressbar-0.0.3/lib/progressbar.rb
[2] ./lib/progressbar.rb

----------------------------------------------------------------

Development machine:

[erik@devel]$ ruby rubyscript2exe.rb testgem.rb
Tracing testgem...
Gathering files...% |oooooooooooooooooooooooooooooooooooooooo| ETA: 00:00:00
Copying files...
Copying /lib/ld-linux.so.2 ...
Copying /usr/local/bin/ruby ...
Copying /scratch/testgem.rb ...
Creating testgem.bin ...

Test machine:

[erik@test1]$ ./testgem.bin
Example progr: 100% |oooooooooooooooooooooooooooooooooooooooo| ETA: 00:00:00

----------------------------------------------------------------

# Doesn't work.

require 'rubygems'
require_gem 'progressbar'

----------------------------------------------------------------

# Does work.

require 'rubygems'
begin
require_gem 'progressbar'
rescue Gem::LoadError
require 'progressbar'
end

----------------------------------------------------------------

 
Reply With Quote
 
Gavin Sinclair
Guest
Posts: n/a
 
      12-08-2004
On Thursday, December 9, 2004, 2:47:29 AM, Erik wrote:

>> Will this support all manner of 'require'd files, including
>> those loaded by the gems require-hack?


> [......]


> ----------------------------------------------------------------
>
> # Doesn't work.
>
> require 'rubygems'
> require_gem 'progressbar'
>
> ----------------------------------------------------------------
>
> # Does work.
>
> require 'rubygems'
> begin
> require_gem 'progressbar'
> rescue Gem::LoadError
> require 'progressbar'
> end
>
> ----------------------------------------------------------------


Try:

require 'rubygems'
require 'progressbar'

Cheers,
Gavin




 
Reply With Quote
 
Mauricio Fernández
Guest
Posts: n/a
 
      12-08-2004
On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
>
> "Gavin Sinclair" <(E-Mail Removed)> wrote in message
> > Try:
> >
> > require 'rubygems'
> > require 'progressbar'

>
> Will this allow nested (gem and non-gem) requires within 'progressbar' to
> work?


require 'foo' will always load the version from RubyGems, if you're
referring to that. Once you require 'rubygems', it overrides
Kernel.require and it is no longer possible to load the files in the
standard library dir, unless you use the GEM_SKIP env. variable.

> Is the "ruby -r ubygems myfile.rb" and then just plain "require progressbar"
> no longer recommended? Or the environment variable GEM_PATH (on WinXP) ?


ruby -rubygems foo is equivalent to doing a require 'rubygems'...

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyarchive.org/


 
Reply With Quote
 
James Edward Gray II
Guest
Posts: n/a
 
      12-08-2004
On Dec 8, 2004, at 10:57 AM, Mauricio Fernández wrote:

> On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
>>
>> "Gavin Sinclair" <(E-Mail Removed)> wrote in message
>>> Try:
>>>
>>> require 'rubygems'
>>> require 'progressbar'

>>
>> Will this allow nested (gem and non-gem) requires within
>> 'progressbar' to
>> work?

>
> require 'foo' will always load the version from RubyGems, if you're
> referring to that. Once you require 'rubygems', it overrides
> Kernel.require and it is no longer possible to load the files in the
> standard library dir, unless you use the GEM_SKIP env. variable.


Hmm, is this a good thing? If Ruby Gems replaces the require(),
couldn't it be set to try the old require() when a Gem require fails?
Just a thought.

James Edward Gray II




 
Reply With Quote
 
Mauricio Fernández
Guest
Posts: n/a
 
      12-08-2004
On Thu, Dec 09, 2004 at 02:02:37AM +0900, James Edward Gray II wrote:
> On Dec 8, 2004, at 10:57 AM, Mauricio Fernández wrote:
>
> >On Thu, Dec 09, 2004 at 01:22:30AM +0900, itsme213 wrote:
> >>
> >>"Gavin Sinclair" <(E-Mail Removed)> wrote in message
> >>>Try:
> >>>
> >>> require 'rubygems'
> >>> require 'progressbar'
> >>
> >>Will this allow nested (gem and non-gem) requires within
> >>'progressbar' to
> >>work?

> >
> >require 'foo' will always load the version from RubyGems, if you're
> >referring to that. Once you require 'rubygems', it overrides
> >Kernel.require and it is no longer possible to load the files in the
> >standard library dir, unless you use the GEM_SKIP env. variable.

>
> Hmm, is this a good thing? If Ruby Gems replaces the require(),
> couldn't it be set to try the old require() when a Gem require fails?
> Just a thought.


I didn't phrase that correctly. require 'foo' will load preferentially
the file in the gemdir (instead of the one in sitelibdir as usual).

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyarchive.org/


 
Reply With Quote
 
Erik Veenstra
Guest
Posts: n/a
 
      12-08-2004
> > > Will this support all manner of 'require'd files,
> > > including those loaded by the gems require-hack?

> >
> > [......]

>
> Try:
>
> require 'rubygems'
>
> require 'progressbar'


$ grep * -wie def | grep -wie require
loadpath_manager.rb: def require(file)

Looks like RubyGems does an overwrite of Kernel.require:

module Kernel
alias require__ require
def require(file)
Gem::LoadPathManager.search_loadpath(file) || Gem::LoadPathManager.search_gempath(file)
require__(file)
end
end

That will do the trick in our application. But what happens
when a library does a require_gem? Time for the next test. I
don't know Rails, but I think it has some dependencies. Just
giving it a shot...

Test 1:

$ cat test1.rb
require "rubygems"
require_gem "rails"

$ ruby test1.rb

Looks good. It's useless, but the dependencies are fullfilled.

Test 2:

$ cat test2.rb
require "rubygems"
require "rails"

$ ruby test2.rb
/usr/local/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require__': No such file to load -- rails (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `require'
from test2.rb:2

Oops! I think it hasn't anything to do with dependencies. The
trick doesn't work.

Any RubyGem hacker, out there?

gegroet,
Erik V.

 
Reply With Quote
 
Jim Weirich
Guest
Posts: n/a
 
      12-08-2004

Erik Veenstra said:
> I did a test (on Linux) with the progressbar example. Yes,
> RubyScript2Exe detects progressbar.rb [1] and yes, it is
> included in the executable [2]. But when the executable is run,
> require_gem only searches for progressbar.rb in its own dirs,
> not in the regular places. Resulting in an Gem::LoadError.


require_gem does not search for progressbar.rb. It searches for the
progressbar *gem* (progressbar.rb gets required as a side effect if the
gem specifies an autorequire file). Since you are not replicating the
gems metadata structure in your packaged app, its not surprizing that it
is not found.

There are a couple of ways of attacking this. You /could/ replicate the
gem metadata (not really recommended). Perhaps supplying a custom
require_gem that works in your packaged app. I think the only thing the
custom require_gem would need to do is do a require on that gems
autorequire file (if any).

Contact me (or another gem developer) if you need help pursuing this. We
would be glad to help.

--
-- Jim Weirich http://www.velocityreviews.com/forums/(E-Mail Removed) 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)



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[ANN] RubyScript2Exe 0.3.2 Erik Veenstra Ruby 2 01-20-2005 07:47 PM
[ANN] RubyScript2Exe 0.3.1 Erik Veenstra Ruby 6 01-16-2005 08:42 PM
[ANN] RubyScript2Exe 0.3.0 Erik Veenstra Ruby 7 12-28-2004 03:28 PM
RubyScript2Exe 0.2.1 Erik Veenstra Ruby 1 12-23-2004 11:52 PM
[ANN} RubyScript2Exe Erik Veenstra Ruby 5 10-19-2003 10:46 PM



Advertisments