Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

How to include CPAN packages in distribution package

by jeanluca (Deacon)
on Dec 03, 2007 at 08:20 UTC ( [id://654522]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks
I've written some perl-packages that I distribute to others. Right now the installation is easy:
make clean perl Makefile.PL make make install
(I've started the project with h2xs)
Anyway, thats all very nice, however, my packages require packages from CPAN, so I tell the users what else they should install.
I realize that this is not the perfect way of distributing software. Is there a way to automate this process (or include the CPAN packages in my distribution)?

Cheers
LuCa

Update: thnx to all. For the moment I'll go for the cpan . solution from eserte, it works and I can include that command in my installtion file!

Replies are listed 'Best First'.
Re: How to include CPAN packages in distribution package
by moritz (Cardinal) on Dec 03, 2007 at 09:56 UTC
    You could use Module::Build to control the building and installation of your modules, and declare the right dependencies on the cpan packages. At least it will complain about missing deps.

    Anybody who has perl installed has CPAN as well, and can install them easily.

    If you upload your module to CPAN, you can automate the installation of all required modules by configure cpan to "follow dependencies".

Re: How to include CPAN packages in distribution package
by andreas1234567 (Vicar) on Dec 03, 2007 at 10:32 UTC
    I'd look up some other modules on CPAN and use those as a starting point. E.g. the first lines of Makefile.PL from the most recent Test::Differences module looks like this:
    use ExtUtils::MakeMaker; WriteMakefile( NAME => "Test::Differences", VERSION_FROM => "Differences.pm", PREREQ_PM => { "Text::Diff" => 0.34, }, );
    Which basically says that Test::Differences requires Text::Diff in version 0.34 (or higher).

    See the ExtUtils::MakeMaker documentation for more information.

    --
    Andreas
Re: How to include CPAN packages in distribution package
by plobsing (Friar) on Dec 03, 2007 at 13:52 UTC
    Have a look at Module::Install::Bundle. If users don't want to go to CPAN, this is the way to go.
Re: How to include CPAN packages in distribution package
by eserte (Deacon) on Dec 03, 2007 at 21:04 UTC
    If your users use a modern CPAN.pm, they need just to type
    cpan . # that is, cpan dot, in case your monitor is dirty, like mine
    which would resolve all dependencies, make, test and install the application.
Re: How to include CPAN packages in distribution package
by girarde (Hermit) on Dec 03, 2007 at 14:41 UTC
    I suppose you could also include ppm, run it to check dependencies, and install the missing bits. But I've never tried that.
Re: How to include CPAN packages in distribution package
by johnnywang (Priest) on Dec 03, 2007 at 19:38 UTC
    Wow, I'm just about to submit the same question when I see this post. Let me add a little detail to my version of the same question.

    I'm trying to add a custom tool that needs a DBI/mysql combination, the perl installation doesn't have DBI/mysql. I'd like the user to be able to use my package (say via gunzip/tar) without installing any perl modules. What's the best way to package it?

      If you intend to embed modules into your application, your application can use lib to find them in your own private library directory (a part of your application). After use lib, perl will see the updated value of @INC in its search for subsequent use statements.
      BEGIN { $INSTALLDIR = my_fun_to_find_my_own_install_dir() } use lib "$INSTALLDIR/privatelib"; use Acme::SuperModule qw(whatever);

      The upside is that you have some control over the versions that folks will use, and thus you can more easily guarantee proper execution. The downside to this approach is that the writer of that embedded module (e.g., Acme::SuperModule) might fix a critical bug, and your customers won't get the benefits until you ship them a new version.

      --
      [ e d @ h a l l e y . c c ]

      Thanks, I knew about "use lib" for my own lib paths, just never tried to have a CPAN module like DBI in my own path.

      I just did a manual make of DBI from source, all the files are in the usual blib directory, I'm thinking that if I put everything of blib (except the docs) as part of my distribution (keeping the same structure like: lib/auto, lib/Bundle, lib/DBD, etc.) it should all work. I guess I'll just go ahead and do that, and report back.

      Update Yes, it's as simple as that, I took the blib/lib directory, and moved it somewhere, and just do "use lib" to point there, all worked fine.

Re: How to include CPAN packages in distribution package
by redhotpenguin (Deacon) on Dec 08, 2007 at 20:15 UTC

    Krang has a nice system of managing packages, which includes being able to build the entire application from scratch. I use my Makefile.PL to document the dependencies, and also download a copy of that CPAN package to a src/ directory in my application. Because it's good to have it there if a few years down the road that package for whatever reason isn't on CPAN or BackPAN.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found