Sign in to PrePAN

Dependencies::Searcher Search for modules used or required by a distribution and build a report that can be used as a Carton cpanfile



use Dependencies::Searcher;

my $searcher = Dependencies::Searcher->new();
my @elements = $searcher->get_files();
my @uses = $searcher->get_modules($path, "use");
my @uniq_modules = $searcher->uniq(@uses);



# Prints to cpanfile
requires 'Module::Name', '0.32';
requires 'Module::Name::Foo', '0.000017';
requires 'Module::Name::Bar', '1.15';


Description and why this module ?

Maybe you don't want to have to list all the dependencies of your Perl application by hand and want an automated way to build it. Maybe you forgot to do it for a long time ago. Or just during a short period.

Anyway, you've add lots of CPAN modules. Carton is here to help you manage dependencies between your development environment and production, but how to keep track of the list of modules you will pass to Carton?

Event if it is a no brainer to keep track of this list by adding it by hand, it can be much better not to have to do it.

You will need a tool that will check for any requires or use in your module package, and report it into a formated file that could be used as an input Carton cpanfile. Any duplicated entry will be removed and modules versions will be checked and made available. Core modules will be ommited because you don't need to install them (except in some special case).

This project has begun because it has happened to me, and I don't want to search for modules to install by hand, I just want to run a simple script that update the list in a convenient way. It was much more longer to write the module than to search by hand so I wish it could be useful for you now.

This module is made to search dependencies for installed distributions, it is not supposed to manage anything else.

Why isn't it just yet another Module::Scandeps ?

Module::ScanDeps is a bi-dimentional recursive scanner: it features dependencies and directories recursivity.

Dependencies::Searcher only found direct dependencies, not dependencies of dependencies, it scans recursively directories but not dependencies..

These direct dependencies are passed to the Perl toolchain (cpanminus, Carton) that will take care of any recursive dependencies.


Isn't it ok to not list dependencies of dependencies? After all installing the highest depedendency in the tree will also add the other deps.

I wrote something similar, App::Prove::Plugin::TraceUse. It is a plugin to the tool "prove", used for running tests. It makes each test file run with Devel::TraceUse, which lists all modules used by that perl script. (And discards modules from core). It then examines Build.PL and Makefile.PL to see which of those found dependencies were not listed already with your installed version.

The bonus is that as long as you test all features of your code, it will list all dependencies used.

The implementation may be so so, but the idea is good. Regardless, Devel::TraceUse may be useful for you for this module.
See also Dist::Zilla::Plugin::AutoPrereqs.

Please sign up to post a review.