bump version
[bioperl-live.git] / Build.PL
blob8b5007dc521a4ba119751013cb4598e096b7ada9
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
25 eval { require XML::SAX; 1; };
27 unless ($@) {
28 if ( grep { $_->{Name} =~ 'XML::SAX::RTF' } @{ XML::SAX->parsers() } )
30 warn <<WARN;
32 ############################# WARNING #############################
34 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
35 XML::SAX parser. If used as the primary parser, modules requiring
36 XML::SAX will NOT work. Please install another XML::SAX-compliant
37 module and modify your local ParserDetails.ini file per XML::SAX
38 docs to remove references to XML::SAX::RTF.
40 ############################# WARNING #############################
42 WARN
43 sleep 2;
48 my %recommends = (
50 # AcePerl support is deprecated, per LDS - cjfields - 5-5-2011
52 #'Ace' => [0,
53 # 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
55 'Algorithm::Munkres' => [ 0, 'Phylogenetic Networks/Bio::PhyloNetwork' ],
57 'Array::Compare' => [ 0, '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' => [
69 'NeXML related modules/Bio::AlignIO::nexml,Bio::Nexml::Factory,'
70 . 'Bio::SeqIO::nexml,Bio::TreeIO::nexml'
73 'CGI' => [ 0, 'CGI-y things/Bio::DB::Query::HIVQuery' ],
75 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
77 'Convert::Binary::C' =>
78 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
80 'DB_File' => [ 0, 'Database functionality/Bio::Assemby,Bio::DB' ],
82 'Error' => [
83 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
86 'GD' => [ 0, 'Alignment graphic output/Bio::Align::Graphics' ],
88 'Graph' => [
89 0.50,
90 'Phylogenetic Networks, ontology engine implementation, contig analysis'
91 . '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'
92 . 'Bio::Assembly::Tools::ContigSpectrum'
95 'GraphViz' => [
96 0, 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'
99 'HTML::Entities' =>
100 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
102 'HTML::HeadParser' => [
104 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
107 'HTML::TableExtract' =>
108 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
110 'HTTP::Request::Common' => [
112 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
113 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
114 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
117 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
119 'IO::Scalar' => [
120 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
123 'List::MoreUtils' => [
125 'Back- or reverse-translation of sequences/'
126 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
129 'LWP::UserAgent' => [
131 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
134 'PostScript::TextBlock' => [ 0, 'EPS output/Bio::Tree::Draw::Cladogram' ],
136 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
138 'SOAP::Lite' => [ 0, 'Bibliographic queries/Bio::DB::Biblio::soap' ],
140 'Sort::Naturally' => [
142 'Sort lexically, but sort numeral parts numerically/'
143 . 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'
146 'Spreadsheet::ParseExcel' =>
147 [ 0, 'Parsing Excel files/Bio::SeqIO::excel' ],
149 'Storable' => [
150 2.05,
151 'Storing sequence objects in local file cache/'
152 . 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'
153 . 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'
156 'SVG' => [ 2.26, 'Creating SVG images/Bio::Draw::Pictogram' ],
158 'SVG::Graph' => [ 0.01, 'Creating SVG images/Bio::TreeIO::svggraph' ],
160 'Text::ParseWords' =>
161 [ 0, 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader' ],
163 'XML::DOM' => [ 0, 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro' ],
165 'XML::DOM::XPath' => [ 0, 'Parsing XML/Bio::SeqIO::interpro' ],
167 'XML::LibXML' =>
168 [ 0, 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml' ],
170 'XML::Parser' => [ 0, 'Parsing XML/Bio::Biblio::IO::medlinexml' ],
172 'XML::Parser::PerlSAX' => [
174 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
175 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'
178 'XML::SAX' => [
179 0.15,
180 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'
183 'XML::SAX::Writer' => [ 0, 'Writing XML/Bio::SeqIO::tigrxml' ],
185 'XML::Simple' => [
187 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'
190 'XML::Twig' => [
192 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'
193 . 'Bio::DB::Biblio::eutils'
196 'XML::Writer' => [
197 0.4,
198 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
199 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
200 . 'Bio::SearchIO::Writer::BSMLResultWriter'
203 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
206 my $mysql_ok = 0;
208 my @drivers = available_drivers();
210 # Set up the Bio::Root::Build object
211 my $build = Bio::Root::Build->new(
212 module_name => 'Bio',
213 dist_name => 'BioPerl',
214 dist_version => $Bio::Root::Version::VERSION,
215 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
216 dist_abstract => 'Bioinformatics Toolkit',
217 license => 'perl',
218 requires => {
219 'perl' => '5.6.1',
220 'IO::String' => 0, # why is this required?
221 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
222 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
223 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
226 configure_requires => {
227 'Module::Build' => 0.42,
230 build_requires => {
231 'Module::Build' => 0.42,
232 'CPAN' => 1.81,
233 'Test::Harness' => 2.62,
234 'Test::Most' => 0,
235 'URI::Escape' => 0
238 recommends => {
239 # reverted to a simple Module::Build-compatible hash, but we keep
240 # additional data in the %recommends hash above. May be converted to
241 # something simpler if there aren't complaints down the line.
242 map { $_ => $recommends{$_}[0] } sort keys %recommends
245 get_options => {
246 accept => {},
247 network => {} # say 'perl Build.PL --network' to manually request network tests
250 auto_features => {
251 'EntrezGene' => {
252 description => "Presence of Bio::ASN1::EntrezGene",
253 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
256 'DB_File Tests' => {
257 description => "BDB tests for Bio::DB::SeqFeature::Store",
258 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
261 'Bio::DB::GFF Tests' => {
262 description =>
263 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
264 requires => { 'DBI' => 0 },
267 'MySQL Tests' => {
268 description =>
269 "MySQL-related tests for Bio::DB::SeqFeature::Store",
270 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
273 'Pg Tests' => {
274 description =>
275 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
276 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
279 'SQLite Tests' => {
280 description =>
281 "SQLite-related tests for Bio::DB::SeqFeature::Store",
282 requires => { 'DBI' => 0, 'DBD::SQLite' => 0 },
285 'Network Tests' => {
286 description => "Enable tests that need an internet connection",
287 requires => { 'LWP::UserAgent' => 0 },
290 dynamic_config => 1,
291 recursive_test_files => 1,
293 # Extra files needed for BioPerl modules
294 xml_files => {
295 './Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'
298 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
299 #script_files => [] # scripts in scripts directory are installed on-demand
302 my $accept = $build->args('accept');
304 my $proceed = prompt_for_biodb($accept)
305 if $build->feature('Bio::DB::GFF')
306 || $build->feature('MySQL Tests')
307 || $build->feature('Pg Tests')
308 || $build->feature('SQLite Tests');
310 # Handle auto features
311 if ( $proceed && $build->feature('DB_File Tests') ) {
313 # will return without doing anything if user chose not to run tests during
314 make_bdb_test();
316 if ($proceed
317 && ( $build->feature('MySQL Tests')
318 || $build->feature('Pg Tests')
319 || $build->feature('SQLite Tests') )
321 make_dbi_test();
324 # Ask questions
325 $build->choose_scripts($accept);
327 if ( $build->args('network') ) {
328 if ( $build->feature('Network Tests') ) {
329 $build->notes( network => 1 );
330 $build->log_info(" - will run internet-requiring tests\n");
331 } else {
332 $build->notes( network => 0 );
333 $build->log_info(
334 " - Missing LWP::UserAgent, can't run network tests\n");
336 } else {
337 $build->prompt_for_network($accept) if $build->feature('Network Tests');
340 # Add additional files here
341 $build->add_build_element('xml');
343 # Create the build script and exit
344 $build->create_build_script;
346 exit;
348 ########################## Helper subs ##########################
350 sub make_bdb_test {
351 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
352 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
353 unlink($path) if ( -e $path );
354 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
355 print $F <<END;
356 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
358 close $F;
359 $build->add_to_cleanup($path);
361 #$build->add_to_manifest_skip($path);
364 sub available_drivers {
365 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
366 return if $@;
367 @drivers = DBI->available_drivers;
368 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
369 $mysql_ok = 0;
370 return
371 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
373 $mysql_ok = 1;
374 return @drivers;
377 sub make_dbi_test {
378 my $dsn = $build->notes('test_dsn') || return;
379 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
380 my $driver = $build->notes('dbd_driver');
381 my $path = File::Spec->catfile( 't', 'LocalDB',
382 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
383 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
384 : 'SeqFeature_Pg.t' );
385 my $test_db = $build->notes('test_db');
386 my $user = $build->notes('test_user');
387 my $pass = $build->notes('test_pass');
388 open my $F, '>', $path
389 or die "Could not write file '$path' for DBI test: $!\n";
390 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
391 $str .= " -user $user" if $user;
392 $str .= " -password $pass" if $pass;
393 print $F <<END;
394 system '$^X $str';
396 close $F;
397 $build->add_to_cleanup($path);
398 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
400 #$build->add_to_manifest_skip($path);
403 sub test_biodbgff {
404 eval { require DBI; }; # if not installed, this sub won't actually be called
405 return if $@;
406 @drivers = DBI->available_drivers;
407 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
408 return "MySQL, Pg nor Oracle DBI drivers are installed";
410 return;
413 sub prompt_for_biodb {
414 my $accept = shift;
415 my $proceed = $accept ? 0 : $build->y_n(
416 "Do you want to run the Bio::DB::GFF or "
417 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
421 if ($proceed) {
422 my @driver_choices;
423 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
424 if ( grep {/$poss/i} @drivers ) {
425 my $choice = $poss;
426 $choice =~ s/^(.)/[$1]/;
427 push( @driver_choices, $choice );
431 my $driver;
432 if ( @driver_choices > 1 ) {
433 my ($default) = $driver_choices[0] =~ /\[(.)/;
434 $driver = $build->prompt(
435 "Which database driver should be used? "
436 . join( " ", @driver_choices ),
437 $default
439 } else {
440 ($driver) = $driver_choices[0] =~ /\[(.)/;
442 if ( $driver =~ /^[mM]/ ) {
443 $driver = 'mysql';
444 } elsif ( $driver =~ /^[pP]/ ) {
445 $driver = 'Pg';
446 } elsif ( $driver =~ /^[oO]/ ) {
447 $driver = 'Oracle';
448 } elsif ( $driver =~ /^[sS]/ ) {
449 $driver = 'SQLite';
452 my $test_db = $build->prompt(
453 "Which database should I use for testing the $driver driver?\n"
454 . "This database should already be present but doesn't have to "
455 . "be preloaded for any schema",
456 'test'
458 my $test_host = $build->prompt(
459 "On which host is database '$test_db' running (hostname, ip address or host:port)",
460 'localhost'
462 my $test_user = $build->prompt(
463 "User name for connecting to database '$test_db'?", 'undef' );
464 my $test_pass = $build->prompt(
465 "Password for connecting to database '$test_db'?", 'undef' );
467 my $use_host = 1;
468 if ( $test_host eq 'undef' || $test_host eq 'localhost' ) {
469 $use_host = 0;
472 my $test_dsn;
473 if ( $driver eq 'Pg' || $driver eq 'SQLite' ) {
474 $test_dsn = "dbi:$driver:dbname=$test_db";
475 $mysql_ok = 0;
476 } else {
477 $test_dsn = "dbi:$driver:database=$test_db";
478 $mysql_ok = 0;
480 if ($use_host) {
481 $test_dsn .= ";host=$test_host";
484 $build->notes( dbd_driver => $driver );
485 $build->notes( test_db => $test_db );
486 $build->notes( test_host => $test_host );
487 $build->notes(
488 test_user => $test_user eq 'undef' ? undef : $test_user );
489 $build->notes(
490 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
491 $build->notes( test_dsn => $test_dsn );
493 $build->log_info(
494 " - will run tests with database driver '$driver' and these settings:\n",
495 " Database $test_db\n",
496 " Host $test_host\n",
497 " DSN $test_dsn\n",
498 " User $test_user\n",
499 " Password $test_pass\n"
501 $build->log_info( " - will not run the BioDBSeqFeature live "
502 . "database tests (requires MySQL or Pg driver)\n" )
503 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
504 } else {
505 $build->log_info(
506 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
510 $build->log_info("\n");
511 return $proceed;