ad more updates
[bioperl-live.git] / Build.PL
blob2eed3961e72c661ac4bb82d7f8122227207d66a2
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 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 #create_makefile_pl => 'passthrough',
264 recursive_test_files => 1,
266 # Extra files needed for BioPerl modules
267 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
269 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
270 #script_files => [] # scripts in scripts directory are installed on-demand
273 my $accept = $build->args('accept');
275 # how much do I hate this? Let me count the ways.....
276 #if (!$build->feature('EntrezGene')) {
277 # warn <<WARN;
278 ############################## WARNING #############################
280 #Bio::ASN1::EntrezGene not found. This is an *optional* module;
281 #however, because it has a circular dependency with BioPerl we do not
282 #include it on our list of recommended modules.
284 #If you require EntrezGene functionality, you can install
285 #Bio::ASN1::EntrezGene after BioPerl has finished installing.
287 ############################## WARNING #############################
289 #WARN
290 # sleep 3;
293 my $proceed = prompt_for_biodb($accept)
294 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
295 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
297 # Handle auto features
298 if ($proceed && $build->feature('DB_File Tests')) {
299 # will return without doing anything if user chose not to run tests during
300 make_bdb_test();
302 if ($proceed && ($build->feature('MySQL Tests') ||
303 $build->feature('Pg Tests') ||
304 $build->feature('SQLite Tests'))) {
305 make_dbi_test();
308 # Ask questions
309 $build->choose_scripts($accept);
311 if ($build->args('network')) {
312 if ($build->feature('Network Tests')) {
313 $build->notes(network => 1);
314 $build->log_info(" - will run internet-requiring tests\n");
316 else {
317 $build->notes(network => 0);
318 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
321 else {
322 $build->prompt_for_network($accept) if $build->feature('Network Tests');
325 # Add additional files here
326 $build->add_build_element('xml');
328 # Create the build script and exit
329 $build->create_build_script;
331 exit;
333 ########################## Helper subs ##########################
335 sub make_bdb_test {
336 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
337 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
338 unlink($path) if (-e $path);
339 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
340 print $F <<END;
341 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
343 close $F;
344 $build->add_to_cleanup($path);
345 #$build->add_to_manifest_skip($path);
348 sub available_drivers {
349 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
350 return if $@;
351 @drivers = DBI->available_drivers;
352 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
353 $mysql_ok = 0;
354 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
356 $mysql_ok = 1;
357 return @drivers;
360 sub make_dbi_test {
361 my $dsn = $build->notes('test_dsn') || return;
362 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
363 my $driver = $build->notes('dbd_driver');
364 my $path = File::Spec->catfile('t', 'LocalDB',
365 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
366 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
367 'SeqFeature_Pg.t');
368 my $test_db = $build->notes('test_db');
369 my $user = $build->notes('test_user');
370 my $pass = $build->notes('test_pass');
371 open my $F, '>', $path or die "Could not write file '$path' for DBI test: $!\n";
372 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
373 $str .= " -user $user" if $user;
374 $str .= " -password $pass" if $pass;
375 print $F <<END;
376 system '$^X $str';
378 close $F;
379 $build->add_to_cleanup($path);
380 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
381 #$build->add_to_manifest_skip($path);
384 sub test_biodbgff {
385 eval {require DBI;}; # if not installed, this sub won't actually be called
386 return if $@;
387 @drivers = DBI->available_drivers;
388 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
389 return "MySQL, Pg nor Oracle DBI drivers are installed";
391 return;
394 sub prompt_for_biodb {
395 my $accept = shift;
396 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
397 "Bio::DB::SeqFeature::Store live database tests? ".
398 "y/n", 'n');
400 if ($proceed) {
401 my @driver_choices;
402 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
403 if (grep {/$poss/i} @drivers) {
404 my $choice = $poss;
405 $choice =~ s/^(.)/[$1]/;
406 push(@driver_choices, $choice);
410 my $driver;
411 if (@driver_choices > 1) {
412 my ($default) = $driver_choices[0] =~ /\[(.)/;
413 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
415 else {
416 ($driver) = $driver_choices[0] =~ /\[(.)/;
418 if ($driver =~ /^[mM]/) {
419 $driver = 'mysql';
421 elsif ($driver =~ /^[pP]/) {
422 $driver = 'Pg';
424 elsif ($driver =~ /^[oO]/) {
425 $driver = 'Oracle';
427 elsif ($driver =~ /^[sS]/) {
428 $driver = 'SQLite';
431 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
432 "This database should already be present but doesn't have to ".
433 "be preloaded for any schema", 'test');
434 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
435 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
436 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
438 my $use_host = 1;
439 if ($test_host eq 'undef' || $test_host eq 'localhost') {
440 $use_host = 0;
443 my $test_dsn;
444 if ($driver eq 'Pg' || $driver eq 'SQLite') {
445 $test_dsn = "dbi:$driver:dbname=$test_db";
446 $mysql_ok = 0;
448 else {
449 $test_dsn = "dbi:$driver:database=$test_db";
450 $mysql_ok = 0;
452 if ($use_host) {
453 $test_dsn .= ";host=$test_host";
456 $build->notes(dbd_driver => $driver);
457 $build->notes(test_db => $test_db);
458 $build->notes(test_host => $test_host);
459 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
460 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
461 $build->notes(test_dsn => $test_dsn);
463 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
464 " Database $test_db\n",
465 " Host $test_host\n",
466 " DSN $test_dsn\n",
467 " User $test_user\n",
468 " Password $test_pass\n");
469 $build->log_info(" - will not run the BioDBSeqFeature live ".
470 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
472 else {
473 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
476 $build->log_info("\n");
477 return $proceed;