nexml.t: Added a missing XML::Twig requirement.
[bioperl-live.git] / Build.PL
blobeb47d9e1d072e7341f779820d5c9cdb3fe8d06d4
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.006925',
195 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
196 dist_abstract => 'Bioinformatics Toolkit',
197 license => 'perl',
198 requires => {
199 'perl' => '5.6.1',
200 'IO::String' => 0, # why is this required?
201 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
202 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
203 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
206 build_requires => {
207 'CPAN' => 1.81,
208 'Module::Build' => 0.2805,
209 'Test::Harness' => 2.62,
210 'Test::Most' => 0,
211 'URI::Escape' => 0
214 recommends => {
215 # reverted to a simple Module::Build-compatible hash, but we keep
216 # additional data in the %recommends hash above. May be converted to
217 # something simpler if there aren't complaints down the line.
218 map {$_ => $recommends{$_}[0]} sort keys %recommends
221 get_options => {
222 accept => { },
223 network => { } # say 'perl Build.PL --network' to manually request network tests
226 auto_features => {
227 'EntrezGene' => {
228 description => "Presence of Bio::ASN1::EntrezGene",
229 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
232 'DB_File Tests' => {
233 description => "BDB tests for Bio::DB::SeqFeature::Store",
234 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
237 'Bio::DB::GFF Tests' => {
238 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
239 requires => { 'DBI' => 0 },
242 'MySQL Tests' => {
243 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
244 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
247 'Pg Tests' => {
248 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
249 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
252 'SQLite Tests' => {
253 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
254 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
257 'Network Tests' => {
258 description => "Enable tests that need an internet connection",
259 requires => { 'LWP::UserAgent' => 0 },
262 dynamic_config => 1,
263 recursive_test_files => 1,
265 # Extra files needed for BioPerl modules
266 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
268 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
269 #script_files => [] # scripts in scripts directory are installed on-demand
272 my $accept = $build->args('accept');
274 my $proceed = prompt_for_biodb($accept)
275 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
276 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
278 # Handle auto features
279 if ($proceed && $build->feature('DB_File Tests')) {
280 # will return without doing anything if user chose not to run tests during
281 make_bdb_test();
283 if ($proceed && ($build->feature('MySQL Tests') ||
284 $build->feature('Pg Tests') ||
285 $build->feature('SQLite Tests'))) {
286 make_dbi_test();
289 # Ask questions
290 $build->choose_scripts($accept);
292 if ($build->args('network')) {
293 if ($build->feature('Network Tests')) {
294 $build->notes(network => 1);
295 $build->log_info(" - will run internet-requiring tests\n");
297 else {
298 $build->notes(network => 0);
299 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
302 else {
303 $build->prompt_for_network($accept) if $build->feature('Network Tests');
306 # Add additional files here
307 $build->add_build_element('xml');
309 # Create the build script and exit
310 $build->create_build_script;
312 exit;
314 ########################## Helper subs ##########################
316 sub make_bdb_test {
317 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
318 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
319 unlink($path) if (-e $path);
320 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
321 print $F <<END;
322 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
324 close $F;
325 $build->add_to_cleanup($path);
326 #$build->add_to_manifest_skip($path);
329 sub available_drivers {
330 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
331 return if $@;
332 @drivers = DBI->available_drivers;
333 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
334 $mysql_ok = 0;
335 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
337 $mysql_ok = 1;
338 return @drivers;
341 sub make_dbi_test {
342 my $dsn = $build->notes('test_dsn') || return;
343 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
344 my $driver = $build->notes('dbd_driver');
345 my $path = File::Spec->catfile('t', 'LocalDB',
346 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
347 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
348 'SeqFeature_Pg.t');
349 my $test_db = $build->notes('test_db');
350 my $user = $build->notes('test_user');
351 my $pass = $build->notes('test_pass');
352 open my $F, '>', $path or die "Could not write file '$path' for DBI test: $!\n";
353 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
354 $str .= " -user $user" if $user;
355 $str .= " -password $pass" if $pass;
356 print $F <<END;
357 system '$^X $str';
359 close $F;
360 $build->add_to_cleanup($path);
361 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
362 #$build->add_to_manifest_skip($path);
365 sub test_biodbgff {
366 eval {require DBI;}; # if not installed, this sub won't actually be called
367 return if $@;
368 @drivers = DBI->available_drivers;
369 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
370 return "MySQL, Pg nor Oracle DBI drivers are installed";
372 return;
375 sub prompt_for_biodb {
376 my $accept = shift;
377 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
378 "Bio::DB::SeqFeature::Store live database tests? ".
379 "y/n", 'n');
381 if ($proceed) {
382 my @driver_choices;
383 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
384 if (grep {/$poss/i} @drivers) {
385 my $choice = $poss;
386 $choice =~ s/^(.)/[$1]/;
387 push(@driver_choices, $choice);
391 my $driver;
392 if (@driver_choices > 1) {
393 my ($default) = $driver_choices[0] =~ /\[(.)/;
394 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
396 else {
397 ($driver) = $driver_choices[0] =~ /\[(.)/;
399 if ($driver =~ /^[mM]/) {
400 $driver = 'mysql';
402 elsif ($driver =~ /^[pP]/) {
403 $driver = 'Pg';
405 elsif ($driver =~ /^[oO]/) {
406 $driver = 'Oracle';
408 elsif ($driver =~ /^[sS]/) {
409 $driver = 'SQLite';
412 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
413 "This database should already be present but doesn't have to ".
414 "be preloaded for any schema", 'test');
415 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
416 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
417 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
419 my $use_host = 1;
420 if ($test_host eq 'undef' || $test_host eq 'localhost') {
421 $use_host = 0;
424 my $test_dsn;
425 if ($driver eq 'Pg' || $driver eq 'SQLite') {
426 $test_dsn = "dbi:$driver:dbname=$test_db";
427 $mysql_ok = 0;
429 else {
430 $test_dsn = "dbi:$driver:database=$test_db";
431 $mysql_ok = 0;
433 if ($use_host) {
434 $test_dsn .= ";host=$test_host";
437 $build->notes(dbd_driver => $driver);
438 $build->notes(test_db => $test_db);
439 $build->notes(test_host => $test_host);
440 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
441 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
442 $build->notes(test_dsn => $test_dsn);
444 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
445 " Database $test_db\n",
446 " Host $test_host\n",
447 " DSN $test_dsn\n",
448 " User $test_user\n",
449 " Password $test_pass\n");
450 $build->log_info(" - will not run the BioDBSeqFeature live ".
451 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
453 else {
454 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
457 $build->log_info("\n");
458 return $proceed;