Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

"use lib" whith architecture and version specific dirs

by jeorgen (Pilgrim)
on Dec 11, 2000 at 07:16 UTC ( [id://46002]=perlquestion: print w/replies, xml ) Need Help??

jeorgen has asked for the wisdom of the Perl Monks concerning the following question:

Dear fellow monks

I'm installing perl modules at a customer's web account, where we do not have root access. So I have created a local perl library, "/home/customer/customers_perl_modules".

I install modules with CPAN configured for the local library, and sometimes with perl Makefile.PL PREFIX =/home/customer/customers_perl_modules

The info on the local libray is stored in the myconfig.pm in the .cpan directory in the user's home directory.

Now, all the modules installed do indeed end up inside the "/home/customer/customers_perl_modules"directory, but often not directly under it, but deeper, in directories named after the version of perl that is used, the processor architecture, under the library "site_perl". There is:

lib/site_perl, lib/site_perl/5.005/, lib/site_perl/5.005/i386-linux/

Now, writing

use lib "/home/customer/customers_perl_modules";

doesn't work for the below script, I seem to need the two following "use libs" in the script for it to work:

use lib "/home/customer/customers_perl_modules/lib"; use lib "/home/customer/customers_perl_modules/lib/site_perl/5.005/i38 +6-linux/"; use lib "/home/customer/customers_perl_modules/lib/site_perl/5.005/"; use XML::Parser; use Data::DumpXML; print "Hi\n";
It seems kind of counter-productive to manually specify the path to each architecture-specific and version-specific directory. I would have thought that this would be handled automatically either by perl itself or by the lib pragma.

So should I:

a) Use some other way than PREFIX and .cpan/myconfig.pm to tell the modules where to be

b) Manually move the modules up and out of the architecture and version-specific libraries

c) use something else than use lib

d) subclass lib module and auto-create appended paths with version, "site_perl" and architecture values added

e) or is my perl broken

? "perl -V" gives this:

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux, osvers=2.2.5-22smp, archname=i386-linux uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 0 +9:11:51 edt 1999 i686 unknown ' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='-O2 -m486 -fno-strength-reduce', gccversion=egc +s-2.91.66 19990314/Linux (egcs-1.1.2 release) cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include' ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include' stdchar='char', d_stdstdio=undef, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lposix -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Built under linux Compiled at Aug 10 2000 15:33:00 @INC: /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005
Am I missing something?

/jeorgen

Replies are listed 'Best First'.
Re: "use lib" whith architecture and version specific dirs
by Fastolfe (Vicar) on Dec 11, 2000 at 07:27 UTC
    This is standard behavior (the placing of modules in the directory hierarchy like this). Note your perl -V gives you 4 items in @INC that correspond to equally nested directories with a prefix of /usr/lib/perl5. You're either going to have to recompile Perl to look in this place as well, use multiple 'use lib' statements like you're doing, or combine them all onto one 'use lib' statement:
    use lib '/prefix/site_perl', '/prefix/5.00503/', '/prefix/site_perl/5.005/, ...;
    The last alternative I'd recommend is to set the PERL5LIB environment variable to include these alternative directories. Set this like you'd set the PATH under unix: a colon-separated list of directories. If you're running under a web server like Apache, you'll have to tell Apache to set these first, or be sure they're set when Apache starts (in its startup script).
Re: "use lib" whith architecture and version specific dirs
by jeorgen (Pilgrim) on Dec 11, 2000 at 07:46 UTC
    While re-reading the documentation on use lib and looking through the directory structure again, I realise that all modules have ended up in either
    lib/site_perl/5.005/
    or in
    lib/site_perl/5.005/i386-linux/
    ...and according to the documentation on use lib, a:
    use lib "customers_perl_modules/lib/site_perl/5.005";
    Should be enough, since directly underlying architecture-specific libs should be appended to @INC automagically.

    ...should be enough.

    Let me try..

    Yep, works!

    But what happens when perl 5.6 gets installed?

    /jeorgen

      The reason for version-specific directories is that a module compiled for one version of perl may not work with another version of perl; this is particularly true of modules with binary pieces. There may also be modules where the newer versions work with 5.6 but not 5.005, so you would install the newer version in site_perl/5.6 while leaving the old version in site_perl/5.005 unchanged.

      It's possible that none of these conflicts exist for any of the modules you're using, but you can play it safe by reinstalling all the site_perl modules when you upgrade to perl5.6.

      When Perl 5.6 is installed, it'll need to look in 5.6.0 as well as 5.005 (assuming you let it look in the older place), and you'll need to update your paths to look in the 5.6.0 versions as well.
Re: "use lib" whith architecture and version specific dirs
by FouRPlaY (Monk) on Dec 12, 2000 at 01:17 UTC
    Try: perl Makefile.PL PREFIX="some/dir" LIB=some/dir"

    I had to have both to get my modules to work.



    FouRPlaY
    Learning Perl or Going To die() Trying

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://46002]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found