- NAME
- SYNOPSIS
- HOW IT WORKS
- FUNCTIONS
- SECURITY
- BUGS/WARNINGS/LIMITATIONS
- FEEDBACK
- SOURCE CODE REPOSITORY
- SEE ALSO
- AUTHOR, LICENCE and COPYRIGHT
- THANKS TO
- CONSPIRACY
NAME
CPAN::FindDependencies - find dependencies for modules on the CPAN
SYNOPSIS
use CPAN::FindDependencies; my @dependencies = CPAN::FindDependencies::finddeps("CPAN"); foreach my $dep (@dependencies) { print ' ' x $dep->depth(); print $dep->name().' ('.$dep->distribution().")\n"; }
HOW IT WORKS
The module uses the CPAN packages index to map modules to distributions and
vice versa, and then fetches distributions' META.yml or Makefile.PL files from
http://search.cpan.org/
to determine pre-requisites. This means that a
working interwebnet connection is required.
FUNCTIONS
There is just one function, which is not exported by default although you can make that happen in the usual fashion.
finddeps
Takes a single compulsory parameter, the name of a module (ie Some::Module); and the following optional named parameters:
- nowarnings
- Warnings about modules where we can't find their META.yml or Makefile.PL, and so can't divine their pre-requisites, will be suppressed;
- fatalerrors
- Failure to get a module's dependencies will be a fatal error instead of merely emitting a warning;
- perl
- Use this version of perl to figure out what's in core. If not specified, it defaults to 5.005. Three part version numbers (eg 5.8.8) are supported but discouraged.
02packages.details.txt.gz
file as a
local filename, with either a relative or an absolute path. If not
specified, it is fetched from a CPAN mirror instead. The file is
fetched just once.
02packages
option.
It returns a list of CPAN::FindDependencies::Dependency objects, whose useful methods are:
- name
- The module's name;
- distribution
- The distribution containing this module;
- version
- The minimum required version of his module (if specified in the requirer's pre-requisites list);
- depth
- How deep in the dependency tree this module is;
- warning
- If any warning was generated (even if suppressed) for the module, it will be recorded here.
Any modules listed as dependencies but which are in the perl core distribution for the version of perl you specified are suppressed.
These objects are returned in a semi-defined order. You can be sure that a module will be immediately followed by one of its dependencies, then that dependency's dependencies, and so on, followed by the 'root' module's next dependency, and so on. You can reconstruct the tree by paying attention to the depth of each object.
The ordering of any particular module's immediate 'children' can be assumed to be random - it's actually hash key order.
SECURITY
If you set usemakefilepl
to a true value, this module may download code
from the internet and execute it. You should think carefully before enabling
that feature.
BUGS/WARNINGS/LIMITATIONS
You must have web access to http://search.cpan.org/ and (unless you tell it where else to look for the index) http://www.cpan.org/, or have all the data cached locally.. If any META.yml or Makefile.PL files are missing, the distribution's dependencies will not be found and a warning will be spat out.
Startup can be slow, especially if it needs to fetch the index from the interweb.
FEEDBACK
I welcome feedback about my code, including constructive criticism and bug reports. The best bug reports include files that I can add to the test suite, which fail with the current code in my git repo and will pass once I've fixed the bug
Feature requests are far more likely to get implemented if you submit a patch yourself.
SOURCE CODE REPOSITORY
git://github.com/DrHyde/perl-modules-CPAN-FindDependencies.git
SEE ALSO
CPAN
AUTHOR, LICENCE and COPYRIGHT
Copyright 2007 - 2015 David Cantrell <david@cantrell.org.uk>
This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
THANKS TO
Stephan Loyd (for fixing problems with some META.yml files)
Alexandr Ciornii (for a patch to stop it segfaulting on Windows)
Brian Phillips (for the code to report on required versions of modules)
Ian Tegebo (for the code to extract deps from Makefile.PL)
Georg Oechsler (for the code to also list 'recommended' modules)
Jonathan Stowe (for making it work through HTTP proxies)
CONSPIRACY
This module is also free-as-in-mason software.