I am looking for a way to include the module Clone from CPAN with my script so that users need not install the module themselves.
They should just extract the zip file and there would be a subdir Modules in the distribution which contains Clone and works out-of-the-box. Ideally, the solution should be independent from the user's architecture. My own system is Mac OS X.
Read on for what I tried so far...
I followed this guide to install the Module locally to ~/clone. But as I want the module in a subdir of my distribution, I did not leave it there and copied the files Clone.pm, auto/Clone/autosplit.ix, auto/Clone/Clone.bs and auto/Clone/Clone.bundle to the distribution's Modules directory and added ./Modules to @INC. So far, this works on various machines with Mac OS X and devtools installed.
Contents of the disto directory:
test.pl
Modules
Clone.pm
auto
autosplit.ix
Clone.bs
Clone.bundle
Contents of test.pl:
use lib qw(./Modules); use Clone qw(clone); use Data::Dumper 'Dumper'; my $struct = { a => 1, b => [2, 2.5] }; print "The original structure:\n"; print Dumper $struct; my $clonedstruct = clone($struct); print "\n\nThe cloned structure:\n"; print Dumper $clonedstruct;
This works on several OS X machines I tested (v5.8.1-RC3 built for darwin-thread-multi-2level). But on Linux (v5.8.0 built for i586-linux-thread-multi), it gives me an error: Can't locate loadable object for module Clone in @INC. I then did the same procedure again for Linux (installing Clone locally and moving files into Modules dir) when I noticed that the file Clone.bundle appears to be called Clone.so here. I then copied both Clone.bundle and Clone.so into Modules/auto and now it appears to work on both OS X and Linux.
So I assume that this solution (if it may be called so), while it seems to work on OS X and Linux, is some dirty hack which will break as soon as I turn my back. Plus, it probably doesn't work on Win32, which bugs me.
Now, is there a right way to do this? And is this kind of architecture independence which I want even achievable?
--anjoschu
P.S.: I am aware of the fact that I must ensure that the module's license permits bundling it with my distro.
Update: Added cross-platform to the title for search-friendliness.
In reply to Bundling a module with a distribution (cross-platform) by anjoschu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |