1 # $Id: dependencies.pl 10084 2006-07-04 22:23:29Z cjfields $
11 use CPANPLUS
::Backend
;
13 my $dep_header = <<HEADER;
16 NOTE : This file was auto-generated by the helper script
17 maintenance/dependencies.pl. Do not edit directly!
19 The following packages are used by BioPerl. While not all are required for
20 BioPerl to operate properly, some functionality will be missing without them.
21 You can easily choose to install all of these during the normal installation
22 process. Note that the PPM version of the BioPerl packages always tries to
23 install all dependencies.
25 The DBD::mysql, DB_File and XML::Parser modules require other applications or
26 databases: MySQL, Berkeley DB, and expat respectively.
28 NB: This list of packages is not authoritative. See the 'requires',
29 'build_requires' and 'recommends' sections of Build.PL instead.
34 # command line options
37 my ($verbose, $dir, $depfile, $help, $version, $skipbio) = (0, undef, "../DEPENDENCIES.NEW", undef, "5.006001", 0);
39 'v|verbose' => \
$verbose,
41 'depfile:s' => \
$depfile,
42 'p|perl:s' => \
$version,
43 's|skipbio' => \
$skipbio,
44 'h|help|?' => sub{ exec('perldoc',$0); exit(0) }
47 # Directories to check
48 my @dirs = qw(../Bio/ );
56 my %core = %{$Module::CoreList
::version
{$version}};
58 # pragmas and BioPerl modules not in core (not required)
59 my %SKIP = map {$_ => 1} qw(base
65 Bio::Tools::Run::Ensembl
70 find
{wanted
=> \
&parse_core
, no_chdir
=> 1}, $dir;
72 find
{wanted
=> \
&parse_core
, no_chdir
=> 1}, @dirs;
79 for my $k (keys %dependencies) {
80 if (exists $bp_packages{$k} || exists $core{$k}) {
81 delete $dependencies{$k};
85 my $b = CPANPLUS
::Backend
->new();
87 # sort by distribution into a hash, keep track of modules
91 for my $key (sort keys %dependencies) {
93 for my $m ($b->module_tree($key)) {
95 warn "$key not found, skipping";
98 push @
{$distrib{$m->package_name}}, [$m, @
{$dependencies{$m->module}}]
102 open my $dfile, '>', $depfile or die "Could not write dependency file '$depfile': $!\n";
104 print $dfile $dep_header;
106 for my $d (sort keys %distrib) {
108 for my $moddata (@
{$distrib{$d}}) {
109 my ($mod, @bp) = @
$moddata;
111 $min_ver = $bp->{ver
} if $bp->{ver
} > $min_ver;
117 " ============================================================================== ",
118 "| Distribution | Module used - Description | Min. ver. |",
119 "|---------------------------+--------------------------------------+-----------|",
120 "| {<<<<<<<<<<<<<<<<<<<<<<<} | * {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[} | {|||||||} |",
124 $_->[0]->module.' - '.$_->[1]
126 [$_->[0], $_->[0]->description || 'NA']
129 $min_ver eq 0 ?
'None' : $min_ver,
130 "|==============================================================================|",
132 "|------------------------------------------------------------------------------|",
133 "| * {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[} |",
136 my $md = $_->[0]->module;
137 map {join(' - ',( $_->{file
}.' - '. $md ))} @
{$_}[1..$#{$_}] # obfuscated ain't it!!!
140 " ============================================================================== ";
153 # this is where the action is
158 return unless $file =~ /\.PLS$/ || $file =~ /\.p[ml]$/ ;
159 return unless -e
$file;
160 open my $F, '<', $file or die "Could not read file '$file': $!\n";
163 while (my $line = <$F>) {
164 # skip POD, starting comments
165 next if $line =~ /^\s*\#/xms;
166 if ($line =~ /^=(\w+)/) {
176 # strip off end comments
177 $line =~ s/\#[^\n]+//;
178 if ($line =~ /^\bpackage\s+(\S+)\s*;/) {
180 } elsif ($line =~ /(?:['"])?\b(use|require)\s+([A-Za-z0-9:_\.\(\)]+)\s*([^;'"]+)?(?:['"])?\s*;/) {
181 my ($use, $mod, $ver) = ($1, $2, $3);
183 print "$File::Find::name: $. $line";
185 if (exists $SKIP{$mod}) {
188 if ($ver && $ver !~ /^v?[\d\.]+$/) {
191 my $nm = $File::Find
::name
;
192 $nm =~ s{.*(Bio.*)\.pm}{$1};
193 $nm =~ s{[\\\/]}{::}g;
194 if (!exists $dependencies{$mod} ||
195 !(grep {$_->{file
} eq $nm} @
{$dependencies{$mod}})) {
196 push @
{ $dependencies{$mod} }, {
209 dependencies.pl - check modules and scripts for dependencies not in core
213 B<dependencies.pl> [B<--dir> path ] [B<-v|--verbose>] [B<--depfile> file]
214 [B<-?|-h|--help>] [B<-p|--perl> version]
218 Recursively parses directory tree given (defaults to '../Bio') and checks files
219 for possible dependencies and versions (use/require statements). Checks that
220 modules aren't part of perl core (--version, defaults to 5.006001). Module
221 information is returned using CPANPLUS and data is output to a table using
222 Perl6::Form (yes I managed to get perl6 in here somehow).
238 Overides the default directories to check by one directory 'path' and
239 all its subdirectories.
241 =item B<--depfile> file
243 The name of the output file for the dependencies table. Default is
244 '../DEPENDENCIES.NEW'
246 =item B<-v | --verbose>
248 Show the progress through files during the checking. Not used currently.
250 =item B<-p | --perl> version
252 Perl version (in long form, i.e. 5.010, 5.006001). Used to weed out the
253 core modules that should be already present (ActiveState, we're staring at
256 =item B<-s | --skipbio>
258 Skips BioPerl-related modules in DEPENDENCIES.
260 We may add something in the future to allow other forms.
262 =item B<-? | -h | --help>
272 User feedback is an integral part of the evolution of this and other
273 Bioperl modules. Send your comments and suggestions preferably to
274 the Bioperl mailing list. Your participation is much appreciated.
276 bioperl-l@bioperl.org - General discussion
277 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
279 =head2 Reporting Bugs
281 Report bugs to the Bioperl bug tracking system to help us keep track
282 of the bugs and their resolution. Bug reports can be submitted via the
285 https://github.com/bioperl/bioperl-live/issues
287 =head1 AUTHOR - Chris Fields
289 Email cjfields-at-bioperl-dot-org