Add tests for memory leaks and weaken for Issue #81
[bioperl-live.git] / Build.PL
blob22786b5453140b2bc82eb6729fd0530a6da374bb
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 # AcePerl support is deprecated, per LDS - cjfields - 5-5-2011
50 #'Ace' => [0,
51 # 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
53 'Algorithm::Munkres' => [0,
54 'Phylogenetic Networks/Bio::PhyloNetwork'],
56 'Array::Compare' => [0,
57 'Phylogenetic Networks/Bio::PhyloNetwork'],
59 # this won't actually install due to circular dep, but we have no way of
60 # doing a post-install the [circular dependency!] specifies it is only
61 # installed on explicit request for this specific module, not when simply
62 # choosing to install 'all' modules
64 #'Bio::ASN1::EntrezGene' => [0,
65 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
67 'Bio::Phylo' => [0,
68 'NeXML related modules/Bio::AlignIO::nexml,Bio::Nexml::Factory,'.
69 'Bio::SeqIO::nexml,Bio::TreeIO::nexml'],
71 'Clone' => [0,
72 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3'],
74 'Convert::Binary::C' => [0,
75 'Strider functionality/Bio::SeqIO::strider'],
77 'DB_File' => [0,
78 'Database functionality/Bio::Assemby,Bio::DB'],
80 'Error' => [0,
81 'OO-based exception handling (very optional)/Bio::Root::Exception'],
83 'GD' => [0,
84 'Alignment graphic output/Bio::Align::Graphics'],
86 'Graph' => [0.50,
87 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
88 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
89 'Bio::Assembly::Tools::ContigSpectrum'],
91 'GraphViz' => [0,
92 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'],
94 'HTML::Entities' => [0,
95 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
97 'HTML::HeadParser' => [3,
98 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
100 'HTML::TableExtract' => [0,
101 'Parsing HTML tables/Bio::DB::SeqVersion::gi'],
103 'HTTP::Request::Common' => [0,
104 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
105 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
106 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
108 'IO::Scalar' => [0,
109 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'],
111 'List::MoreUtils' => [0,
112 'Back- or reverse-translation of sequences/'.
113 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
115 'LWP::UserAgent' => [0,
116 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
118 'PostScript::TextBlock' => [0,
119 'EPS output/Bio::Tree::Draw::Cladogram'],
121 'Set::Scalar' => [0,
122 'Proper operation/Bio::Tree::Compatible'],
124 'SOAP::Lite' => [0,
125 'Bibliographic queries/Bio::DB::Biblio::soap'],
127 'Sort::Naturally' => [0,
128 'Sort lexically, but sort numeral parts numerically/'.
129 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
131 'Spreadsheet::ParseExcel' => [0,
132 'Parsing Excel files/Bio::SeqIO::excel'],
134 'Storable' => [2.05,
135 'Storing sequence objects in local file cache/'.
136 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
137 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'],
139 'SVG' => [2.26,
140 'Creating SVG images/Bio::Draw::Pictogram'],
142 'SVG::Graph' => [0.01,
143 'Creating SVG images/Bio::TreeIO::svggraph'],
145 'Text::ParseWords' => [0,
146 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
148 'XML::DOM' => [0,
149 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro'],
151 'XML::DOM::XPath' => [0,
152 'Parsing XML/Bio::SeqIO::interpro'],
154 'XML::LibXML' => [0,
155 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml'],
157 'XML::Parser' => [0,
158 'Parsing XML/Bio::Biblio::IO::medlinexml'],
160 'XML::Parser::PerlSAX' => [0,
161 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
162 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
164 'XML::SAX' => [0.15,
165 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
167 'XML::SAX::Writer' => [0,
168 'Writing XML/Bio::SeqIO::tigrxml'],
170 'XML::Simple' => [0,
171 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
173 'XML::Twig' => [0,
174 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
175 'Bio::DB::Biblio::eutils'],
177 'XML::Writer' => [0.4,
178 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
179 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
180 'Bio::SearchIO::Writer::BSMLResultWriter'],
182 'YAML' => [0,
183 'GenBank->GFF3/bp_genbank2gff3.pl'],
186 my $mysql_ok = 0;
188 my @drivers = available_drivers();
190 # Set up the Bio::Root::Build object
191 my $build = Bio::Root::Build->new(
192 module_name => 'Bio',
193 dist_name => 'BioPerl',
194 dist_version => '1.006924',
195 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
196 dist_abstract => 'Bioinformatics Toolkit',
197 license => 'perl',
198 no_index => {'x_dir' => [qw(examples/root/lib)]},
199 requires => {
200 'perl' => '5.6.1',
201 'IO::String' => 0, # why is this required?
202 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
203 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
204 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
207 build_requires => {
208 'CPAN' => 1.81,
209 'Module::Build' => 0.2805,
210 'Test::Harness' => 2.62,
211 'Test::Most' => 0,
212 'URI::Escape' => 0
215 recommends => {
216 # reverted to a simple Module::Build-compatible hash, but we keep
217 # additional data in the %recommends hash above. May be converted to
218 # something simpler if there aren't complaints down the line.
219 map {$_ => $recommends{$_}[0]} sort keys %recommends
222 get_options => {
223 accept => { },
224 network => { } # say 'perl Build.PL --network' to manually request network tests
227 auto_features => {
228 'EntrezGene' => {
229 description => "Presence of Bio::ASN1::EntrezGene",
230 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
233 'DB_File Tests' => {
234 description => "BDB tests for Bio::DB::SeqFeature::Store",
235 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
238 'Bio::DB::GFF Tests' => {
239 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
240 requires => { 'DBI' => 0 },
243 'MySQL Tests' => {
244 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
245 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
248 'Pg Tests' => {
249 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
250 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
253 'SQLite Tests' => {
254 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
255 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
258 'Network Tests' => {
259 description => "Enable tests that need an internet connection",
260 requires => { 'LWP::UserAgent' => 0 },
263 dynamic_config => 1,
264 #create_makefile_pl => 'passthrough',
265 recursive_test_files => 1,
267 # Extra files needed for BioPerl modules
268 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
270 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
271 #script_files => [] # scripts in scripts directory are installed on-demand
274 my $accept = $build->args('accept');
276 # how much do I hate this? Let me count the ways.....
277 #if (!$build->feature('EntrezGene')) {
278 # warn <<WARN;
279 ############################## WARNING #############################
281 #Bio::ASN1::EntrezGene not found. This is an *optional* module;
282 #however, because it has a circular dependency with BioPerl we do not
283 #include it on our list of recommended modules.
285 #If you require EntrezGene functionality, you can install
286 #Bio::ASN1::EntrezGene after BioPerl has finished installing.
288 ############################## WARNING #############################
290 #WARN
291 # sleep 3;
294 my $proceed = prompt_for_biodb($accept)
295 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
296 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
298 # Handle auto features
299 if ($proceed && $build->feature('DB_File Tests')) {
300 # will return without doing anything if user chose not to run tests during
301 make_bdb_test();
303 if ($proceed && ($build->feature('MySQL Tests') ||
304 $build->feature('Pg Tests') ||
305 $build->feature('SQLite Tests'))) {
306 make_dbi_test();
309 # Ask questions
310 $build->choose_scripts($accept);
312 if ($build->args('network')) {
313 if ($build->feature('Network Tests')) {
314 $build->notes(network => 1);
315 $build->log_info(" - will run internet-requiring tests\n");
317 else {
318 $build->notes(network => 0);
319 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
322 else {
323 $build->prompt_for_network($accept) if $build->feature('Network Tests');
326 # Add additional files here
327 $build->add_build_element('xml');
329 # Create the build script and exit
330 $build->create_build_script;
332 exit;
334 ########################## Helper subs ##########################
336 sub make_bdb_test {
337 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
338 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
339 unlink($path) if (-e $path);
340 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
341 print $F <<END;
342 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
344 close $F;
345 $build->add_to_cleanup($path);
346 #$build->add_to_manifest_skip($path);
349 sub available_drivers {
350 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
351 return if $@;
352 @drivers = DBI->available_drivers;
353 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
354 $mysql_ok = 0;
355 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
357 $mysql_ok = 1;
358 return @drivers;
361 sub make_dbi_test {
362 my $dsn = $build->notes('test_dsn') || return;
363 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
364 my $driver = $build->notes('dbd_driver');
365 my $path = File::Spec->catfile('t', 'LocalDB',
366 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
367 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
368 'SeqFeature_Pg.t');
369 my $test_db = $build->notes('test_db');
370 my $user = $build->notes('test_user');
371 my $pass = $build->notes('test_pass');
372 open my $F, '>', $path or die "Could not write file '$path' for DBI test: $!\n";
373 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
374 $str .= " -user $user" if $user;
375 $str .= " -password $pass" if $pass;
376 print $F <<END;
377 system '$^X $str';
379 close $F;
380 $build->add_to_cleanup($path);
381 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
382 #$build->add_to_manifest_skip($path);
385 sub test_biodbgff {
386 eval {require DBI;}; # if not installed, this sub won't actually be called
387 return if $@;
388 @drivers = DBI->available_drivers;
389 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
390 return "MySQL, Pg nor Oracle DBI drivers are installed";
392 return;
395 sub prompt_for_biodb {
396 my $accept = shift;
397 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
398 "Bio::DB::SeqFeature::Store live database tests? ".
399 "y/n", 'n');
401 if ($proceed) {
402 my @driver_choices;
403 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
404 if (grep {/$poss/i} @drivers) {
405 my $choice = $poss;
406 $choice =~ s/^(.)/[$1]/;
407 push(@driver_choices, $choice);
411 my $driver;
412 if (@driver_choices > 1) {
413 my ($default) = $driver_choices[0] =~ /\[(.)/;
414 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
416 else {
417 ($driver) = $driver_choices[0] =~ /\[(.)/;
419 if ($driver =~ /^[mM]/) {
420 $driver = 'mysql';
422 elsif ($driver =~ /^[pP]/) {
423 $driver = 'Pg';
425 elsif ($driver =~ /^[oO]/) {
426 $driver = 'Oracle';
428 elsif ($driver =~ /^[sS]/) {
429 $driver = 'SQLite';
432 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
433 "This database should already be present but doesn't have to ".
434 "be preloaded for any schema", 'test');
435 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
436 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
437 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
439 my $use_host = 1;
440 if ($test_host eq 'undef' || $test_host eq 'localhost') {
441 $use_host = 0;
444 my $test_dsn;
445 if ($driver eq 'Pg' || $driver eq 'SQLite') {
446 $test_dsn = "dbi:$driver:dbname=$test_db";
447 $mysql_ok = 0;
449 else {
450 $test_dsn = "dbi:$driver:database=$test_db";
451 $mysql_ok = 0;
453 if ($use_host) {
454 $test_dsn .= ";host=$test_host";
457 $build->notes(dbd_driver => $driver);
458 $build->notes(test_db => $test_db);
459 $build->notes(test_host => $test_host);
460 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
461 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
462 $build->notes(test_dsn => $test_dsn);
464 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
465 " Database $test_db\n",
466 " Host $test_host\n",
467 " DSN $test_dsn\n",
468 " User $test_user\n",
469 " Password $test_pass\n");
470 $build->log_info(" - will not run the BioDBSeqFeature live ".
471 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
473 else {
474 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
477 $build->log_info("\n");
478 return $proceed;