Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have recently released Remote::Use at CPAN, which addresses the problem of loading modules from a binary compatible Perl Module Server. It is in partially in debt with this node and idsfa comment.

There was an actual motivation to have - as idsfa remarks - a solution that does not install the module (as Module::AutoINC), but one that only requires limited knowledge and no privileges.

At the institution I work the student laboratories contain hundreds of computers that can be started in Linux or Windows. The OS is replicated from a master copy in a server.
The administrators are reluctant to install all the Perl Modules I need for teaching. The problem is that I keep discovering interesting new modules and introducing them in my lectures, which means I am continuously bothering them, asking for a new module to be introduced in the master copy/computer.
However, I can still install that modules in a machine that is accesible to the students.

Remote::Use helps to solve these sort of problems. It provides ways to run a Perl program even if some libraries aren't availables at start time. The libraries will be downloaded from a specified server using a specified application that runs on top of some protocol. The clients must be binary compatibles with the server if binary libraries - See Remote::Use::Tutorial for examples - are involved. Typical downloaders are "Rsync" and "Wget" but any suitable alternative like lwp-mirror or "CURL" can be used. This means that many different protocols can be used for the transference: SSH, SFTP, HTTP, HTTPS, FTP, etc. This way, my students can download the modules their programs use to a scratch directory. Once the modules are downloaded they will not be downloaded again, unless the modules are removed from the scratch disk.

Read Remote::Use::Tutorial if you want to know more.

The way to make it work is simple. Consider the following program:

$ cat -n prime3.pl 1 #!/usr/bin/perl -I../lib -w 2 # The module Math::Prime::XS isn't installed in the machine 3 # but will be downloaded from some remote server 4 use Math::Prime::XS qw{:all}; 5 6 @all_primes = primes(9); 7 print "@all_primes\n"; 8 9 @range_primes = primes(4, 9); 10 print "@range_primes\n";
The client machine does not have installed Math::Prime::XS. As the name suggest, the modules involves some binary libraries. By declaring the use of Remote::Use first, the libraries will be downloaded and the program can complete its execution:
$ time perl -MRemote::Use=config,rsyncconfig prime3.pl receiving file list ... done >f+++++++++ XS.so sent 42 bytes received 16141 bytes 10788.67 bytes/sec total size is 16043 speedup is 0.99 receiving file list ... done >f+++++++++ XS.bs sent 42 bytes received 94 bytes 90.67 bytes/sec total size is 0 speedup is 0.00 receiving file list ... done >f+++++++++ XS.pm sent 42 bytes received 5733 bytes 11550.00 bytes/sec total size is 5635 speedup is 0.98 2 3 5 7 5 7 real 0m2.349s user 0m0.116s sys 0m0.060s
The libraries are stored in a cache directory. consequently succesive executions don't pay extra overhead:
$ time perl -MRemote::Use=config,rsyncconfig prime3.pl 2 3 5 7 5 7 real 0m0.066s user 0m0.056s sys 0m0.008s
The programmer has however to set a configuration file rsyncconfig setting the parameters that govern the downloading process:
$ cat rsyncconfig package rsyncconfig; sub getarg { my ($class, $self) = @_; return ( host => 'orion:', prefix => '/tmp/perl5lib/', command => 'rsync -i -vaue ssh', ppmdf => '/tmp/perl5lib/.orion.installed.modules', ); } 1;

Casiano


In reply to Re: Remote Module "use" by casiano
in thread Remote Module "use" by idsfa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found