see if we can make PAUSE skip indexing these modules
[bioperl-live.git] / Build.PL
blobc5e97f307388b174085c0d7e9714a1f37a7777bc
1 #!/usr/bin/perl
3 # This is a Module::Build script for Bioperl installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
6 # Uses a custom subclass of Module::Build called Bio::Root::Build
8 # In the future developers may need to alter the requires and recommends
9 # sections of Bio::Root::Build->new() below, but otherwise nothing else here is
10 # likely to need changing.
12 use strict;
13 use lib '.';
14 use Bio::Root::Build;
16 # XML::SAX::RTF doesn't work with BioPerl, at all, nada, zilch.
18 # Since we're running into this now on CPAN Testers, catch it up front and
19 # deal with it.
21 # See: https://rt.cpan.org/Ticket/Display.html?id=5943
22 # https://redmine.open-bio.org/issues/2975
24 { eval { require XML::SAX; 1; };
26 unless ($@) {
27 if (grep {$_->{Name} =~ 'XML::SAX::RTF'} @{XML::SAX->parsers()}) {
28 warn <<WARN;
30 ############################# WARNING #############################
32 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
33 XML::SAX parser. If used as the primary parser, modules requiring
34 XML::SAX will NOT work. Please install another XML::SAX-compliant
35 module and modify your local ParserDetails.ini file per XML::SAX
36 docs to remove references to XML::SAX::RTF.
38 ############################# WARNING #############################
40 WARN
41 sleep 2;
47 my %recommends = (
48 'Ace' => [0,
49 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
51 'Algorithm::Munkres' => [0,
52 'Phylogenetic Networks/Bio::PhyloNetwork'],
54 'Array::Compare' => [0,
55 'Phylogenetic Networks/Bio::PhyloNetwork'],
57 'YAML' => [0,
58 'GenBank->GFF3/bp_genbank2gff3.pl'],
60 # this won't actually install due to circular dep, but we have no way of
61 # doing a post-install the [circular dependency!] specifies it is only
62 # installed on explicit request for this specific module, not when simply
63 # choosing to install 'all' modules
65 #'Bio::ASN1::EntrezGene' => [0,
66 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
68 'Clone' => [0,
69 'Cloning objects/Bio::Tools::Primer3'],
71 'Convert::Binary::C' => [0,
72 'Strider functionality/Bio::SeqIO::strider'],
74 'Error' => [0,
75 'OO-based exception handling (very optional)/Bio::Root::Exception'],
77 'GD' => [0,
78 'Alignment graphic output/Bio::Align::Graphics'],
80 'Graph' => [0,
81 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
82 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
83 'Bio::Assembly::Tools::ContigSpectrum'],
85 'GraphViz' => [0,
86 'Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz'],
88 'HTML::Entities' => [0,
89 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
91 'HTML::HeadParser' => [3,
92 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
94 'HTTP::Request::Common' => [0,
95 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
96 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
97 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
99 'List::MoreUtils' => [0,
100 'Back- or reverse-translation of sequences/'.
101 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
103 'LWP::UserAgent' => [0,
104 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
106 'Math::Random' => [0,
107 'Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory'],
109 'PostScript::TextBlock' => [0,
110 'EPS output/Bio::Tree::Draw::Cladogram'],
112 'Set::Scalar' => [0,
113 'Proper operation/Bio::Tree::Compatible'],
115 'SOAP::Lite' => [0,
116 'Bibliographic queries/Bio::DB::Biblio::soap'],
118 'Sort::Naturally' => [0,
119 'Sort lexically, but sort numeral parts numerically/'.
120 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
122 'Spreadsheet::ParseExcel' => [0,
123 'Parsing Excel files/Bio::SeqIO::excel'],
125 'Storable' => [2.05,
126 'Storing sequence objects in local file cache/'.
127 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
128 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb'],
130 'SVG' => [2.26,
131 'Creating SVG images/Bio::Draw::Pictogram'],
133 'SVG::Graph' => [0.01,
134 'Creating SVG images/Bio::TreeIO::svggraph'],
136 'Text::ParseWords' => [0,
137 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
139 'URI::Escape' => [0,
140 'Dealing with web resources/Bio::FeatureIO::gff,Bio::FeatureIO::interpro,'.
141 'Bio::DB::Biblio::eutils,Bio::DB::EUtilParameters,'.
142 'Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated'],
144 'XML::DOM::XPath' => [0.13,
145 'parsing interpro features/Bio::FeatureIO::interpro'],
147 'XML::Parser' => [0,
148 'parsing xml/Bio::Biblio::IO::medlinexml'],
150 'XML::Parser::PerlSAX' => [0,
151 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
152 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
154 'XML::SAX' => [0.15,
155 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
157 'XML::SAX::Writer' => [0,
158 'Writing XML/Bio::SeqIO::tigrxml'],
160 'XML::Simple' => [0,
161 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
163 'XML::Twig' => [0,
164 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
165 'Bio::DB::Biblio::eutils'],
167 'XML::Writer' => [0.4,
168 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
169 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
170 'Bio::SearchIO::Writer::BSMLResultWriter'],
173 my $mysql_ok = 0;
175 my @drivers = available_drivers();
177 # Set up the Bio::Root::Build object
178 my $build = Bio::Root::Build->new(
179 module_name => 'Bio',
180 dist_name => 'BioPerl',
181 dist_version_from => 'Bio/Root/Version.pm',
182 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
183 dist_abstract => 'Bioinformatics Toolkit',
184 license => 'perl',
185 no_index => {'dir' => [qw(examples/root/lib)]},
186 requires => {
187 'perl' => '5.6.1',
188 'IO::String' => 0, # why is this required?
189 'DB_File' => 0, # why is this required?
190 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
191 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
192 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
195 build_requires => {
196 'Test::More' => 0,
197 'Module::Build' => 0.2805,
198 'Test::Harness' => 2.62,
199 'CPAN' => 1.81
202 recommends => {
203 # reverted to a simple Module::Build-compatible hash, but we keep
204 # additional data in the %recommends hash above. May be converted to
205 # something simpler if there aren't complaints down the line.
206 map {$_ => $recommends{$_}[0]} sort keys %recommends
209 get_options => {
210 accept => { },
211 network => { } # say 'perl Build.PL --network' to manually request network tests
214 auto_features => {
215 'EntrezGene' => {
216 description => "Presence of Bio::ASN1::EntrezGene",
217 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
220 'DB_File Tests' => {
221 description => "BDB tests for Bio::DB::SeqFeature::Store",
222 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
225 'Bio::DB::GFF Tests' => {
226 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
227 requires => { 'DBI' => 0 },
230 'MySQL Tests' => {
231 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
232 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
235 'Pg Tests' => {
236 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
237 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
240 'SQLite Tests' => {
241 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
242 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
245 'Network Tests' => {
246 description => "Enable tests that need an internet connection",
247 requires => { 'LWP::UserAgent' => 0 },
250 dynamic_config => 1,
251 #create_makefile_pl => 'passthrough',
252 recursive_test_files => 1,
254 # Extra files needed for BioPerl modules
255 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
257 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
258 #script_files => [] # scripts in scripts directory are installed on-demand
261 my $accept = $build->args('accept');
263 # how much do I hate this? Let me count the ways.....
264 if (!$build->feature('EntrezGene')) {
265 warn <<WARN;
266 ############################# WARNING #############################
268 Bio::ASN1::EntrezGene not found. This is an *optional* module;
269 however, because it has a circular dependency with BioPerl we do not
270 include it on our list of recommended modules.
272 If you require EntrezGene functionality, you can install
273 Bio::ASN1::EntrezGene after BioPerl has finished installing.
275 ############################# WARNING #############################
277 WARN
278 sleep 3;
281 my $proceed = prompt_for_biodb($accept) if $build->feature('Bio::DB::GFF')
282 || $build->feature('MySQL Tests') || $build->feature('MySQL Tests');
284 # Handle auto features
285 if ($proceed && $build->feature('DB_File Tests')) {
286 # will return without doing anything if user chose not to run tests during
287 make_bdb_test();
289 if ($proceed && ($build->feature('MySQL Tests') ||
290 $build->feature('Pg Tests') ||
291 $build->feature('SQLite Tests'))) {
292 make_dbi_test();
295 # Ask questions
296 $build->choose_scripts($accept);
298 if ($build->args('network')) {
299 if ($build->feature('Network Tests')) {
300 $build->notes(network => 1);
301 $build->log_info(" - will run internet-requiring tests\n");
303 else {
304 $build->notes(network => 0);
305 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
308 else {
309 $build->prompt_for_network($accept) if $build->feature('Network Tests');
312 # Add additional files here
313 $build->add_build_element('xml');
315 # Create the build script and exit
316 $build->create_build_script;
318 exit;
320 ########################## Helper subs ##########################
322 sub make_bdb_test {
323 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
324 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
325 unlink($path) if (-e $path);
326 open(my $F, ">", $path) || die "Can't create test file\n";
327 print $F <<END;
328 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
330 close $F;
331 $build->add_to_cleanup($path);
332 #$build->add_to_manifest_skip($path);
335 sub available_drivers {
336 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
337 return if $@;
338 @drivers = DBI->available_drivers;
339 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
340 $mysql_ok = 0;
341 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
343 $mysql_ok = 1;
344 return @drivers;
347 sub make_dbi_test {
348 my $dsn = $build->notes('test_dsn') || return;
349 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
350 my $driver = $build->notes('dbd_driver');
351 my $path = File::Spec->catfile('t', 'LocalDB',
352 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
353 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
354 'SeqFeature_Pg.t');
355 my $test_db = $build->notes('test_db');
356 my $user = $build->notes('test_user');
357 my $pass = $build->notes('test_pass');
358 open my $F,">$path";
359 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
360 $str .= " -user $user" if $user;
361 $str .= " -password $pass" if $pass;
362 print $F <<END;
363 system '$^X $str';
365 close $F;
366 $build->add_to_cleanup($path);
367 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
368 #$build->add_to_manifest_skip($path);
371 sub test_biodbgff {
372 eval {require DBI;}; # if not installed, this sub won't actually be called
373 return if $@;
374 @drivers = DBI->available_drivers;
375 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
376 return "MySQL, Pg nor Oracle DBI drivers are installed";
378 return;
381 sub prompt_for_biodb {
382 my $accept = shift;
383 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
384 "Bio::DB::SeqFeature::Store live database tests? ".
385 "y/n", 'n');
387 if ($proceed) {
388 my @driver_choices;
389 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
390 if (grep {/$poss/i} @drivers) {
391 my $choice = $poss;
392 $choice =~ s/^(.)/[$1]/;
393 push(@driver_choices, $choice);
397 my $driver;
398 if (@driver_choices > 1) {
399 my ($default) = $driver_choices[0] =~ /\[(.)/;
400 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
402 else {
403 ($driver) = $driver_choices[0] =~ /\[(.)/;
405 if ($driver =~ /^[mM]/) {
406 $driver = 'mysql';
408 elsif ($driver =~ /^[pP]/) {
409 $driver = 'Pg';
411 elsif ($driver =~ /^[oO]/) {
412 $driver = 'Oracle';
414 elsif ($driver =~ /^[sS]/) {
415 $driver = 'SQLite';
418 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
419 "This database should already be present but doesn't have to ".
420 "be preloaded for any schema", 'test');
421 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
422 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
423 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
425 my $use_host = 1;
426 if ($test_host eq 'undef' || $test_host eq 'localhost') {
427 $use_host = 0;
430 my $test_dsn;
431 if ($driver eq 'Pg' || $driver eq 'SQLite') {
432 $test_dsn = "dbi:$driver:dbname=$test_db";
433 $mysql_ok = 0;
435 else {
436 $test_dsn = "dbi:$driver:database=$test_db";
437 $mysql_ok = 0;
439 if ($use_host) {
440 $test_dsn .= ";host=$test_host";
443 $build->notes(dbd_driver => $driver);
444 $build->notes(test_db => $test_db);
445 $build->notes(test_host => $test_host);
446 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
447 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
448 $build->notes(test_dsn => $test_dsn);
450 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
451 " Database $test_db\n",
452 " Host $test_host\n",
453 " DSN $test_dsn\n",
454 " User $test_user\n",
455 " Password $test_pass\n");
456 $build->log_info(" - will not run the BioDBSeqFeature live ".
457 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
459 else {
460 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
463 $build->log_info("\n");
464 return $proceed;