X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Flocal%2Flib.pm;h=8c38bc687103cb6bcd39061ca3827cd44cedd488;hb=e12c866308e6bbd76233b3c8805721c93fa65a29;hp=6b1f5f9c00080343fbd9f1e7877c98ecb489b021;hpb=fe03358f442f762eb8872cbb9ede5b4380493c72;p=p5sagit%2Flocal-lib.git diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 6b1f5f9..8c38bc6 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -11,7 +11,7 @@ use File::Path (); use Carp (); use Config; -our $VERSION = '1.004008'; # 1.4.7 +our $VERSION = '1.005000'; # 1.5.0 my @KNOWN_FLAGS = (qw/--self-contained/); sub import { @@ -21,7 +21,7 @@ Please see `perldoc local::lib` for directions on using this module. DEATH # Remember what PERL5LIB was when we started - my $perl5lib = $ENV{PERL5LIB}; + my $perl5lib = $ENV{PERL5LIB} || ''; my %arg_store; for my $arg (@args) { @@ -49,7 +49,7 @@ DEATH } } - if($arg_store{'self-contained'}) { + if($arg_store{self-contained}) { # The only directories that remain are those that we just defined and those # where core modules are stored. We put PERL5LIB first, so it'll be favored # over privlibexp and archlibexp @@ -157,11 +157,7 @@ sub resolve_home_path { my ($user) = ($path =~ /^~([^\/]+)/); # can assume ^~ so undef for 'us' my $tried_file_homedir; my $homedir = do { - if ( - eval { require File::HomeDir } - # Use CPAN::Version if available as it deals correctly with dev releases - && (eval { require CPAN::Version; } ? CPAN::Version->vgt($File::HomeDir::VERSION, 0.65) : $File::HomeDir::VERSION >= 0.65 - )) { + if (eval { require File::HomeDir } && $File::HomeDir::VERSION >= 0.65) { $tried_file_homedir = 1; if (defined $user) { File::HomeDir->users_home($user); @@ -354,7 +350,7 @@ sub build_environment_vars_for { PERL5LIB => join($Config{path_sep}, $class->install_base_perl_path($path), $class->install_base_arch_path($path), - ($ENV{PERL5LIB} ? + (($ENV{PERL5LIB}||()) ? ($interpolate == INTERPOLATE_ENV ? ($ENV{PERL5LIB}) : (($^O ne 'MSWin32') ? '$PERL5LIB' : '%PERL5LIB%' )) @@ -363,7 +359,7 @@ sub build_environment_vars_for { PATH => join($Config{path_sep}, $class->install_base_bin_path($path), ($interpolate == INTERPOLATE_ENV - ? $ENV{PATH} + ? ($ENV{PATH}||()) : (($^O ne 'MSWin32') ? '$PATH' : '%PATH%' )) ), ) @@ -401,7 +397,7 @@ In code - From the shell - - # Install LWP and it's missing dependencies to the 'my_lwp' directory + # Install LWP and its missing dependencies to the 'my_lwp' directory perl -MCPAN -Mlocal::lib=my_lwp -e 'CPAN::install(LWP)' # Install LWP and *all non-core* dependencies to the 'my_lwp' directory @@ -467,7 +463,7 @@ installing modules by using the C<--no-manpages> argument when bootstrapping: perl Makefile.PL --bootstrap --no-manpages -If you want to install multiple Perl module environments, say for application evelopment, +If you want to install multiple Perl module environments, say for application development, install local::lib globally and then: cd ~/mydir1 @@ -571,6 +567,26 @@ PATH is appended to, rather than clobbered. These values are then available for reference by any code after import. +=head1 CREATING A SELF-CONTAINED SET OF MODULES + +You can use local::lib to prepare a directory which contains a module and all +of its non-core dependencies. The C<--self-contained> option ignores any +globally installed modules when resolving dependencies, only considering +modules installed in a "local::lib" directory or provided by core Perl. + +A use-case for this feature would be to prepare to deploy a whole "stack" of +module dependencies on a new machine, even if you have copies of the same +dependencies installed globally already. + +The C<--self-contained> option should be used like this: + + # Install LWP and *all non-core* dependencies to the 'my_lwp' directory + perl -MCPAN -Mlocal::lib=--self-contained,my_lwp -e 'CPAN::install(LWP)' + +Note that some dependencies may involve C-based "XS" code even if your target +module doesn't. The issue of dealing with XS vs Pure Perl code is beyond the scope +of what local::lib provides. + =head1 METHODS =head2 ensure_directory_structure_for @@ -793,6 +809,9 @@ section. Many thanks! Patch to add Win32 support contributed by Curtis Jewell . +Warnings for missing PATH/PERL5LIB (as when not running interactively) silenced +by a patch from Marco Emilio Poleggi. + =head1 COPYRIGHT Copyright (c) 2007 - 2009 the local::lib L and L as