Back this out, related tests are failing
[bioperl-live.git] / Build.PL
blob5fc7ac7e15c5d38be9bec60d22d61919bc6fe385
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 'Clone' => [0,
68 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3'],
70 'Convert::Binary::C' => [0,
71 'Strider functionality/Bio::SeqIO::strider'],
73 'Error' => [0,
74 'OO-based exception handling (very optional)/Bio::Root::Exception'],
76 'GD' => [0,
77 'Alignment graphic output/Bio::Align::Graphics'],
79 'Graph' => [0.50,
80 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
81 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
82 'Bio::Assembly::Tools::ContigSpectrum'],
84 'GraphViz' => [0,
85 'Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz'],
87 'HTML::Entities' => [0,
88 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
90 'HTML::HeadParser' => [3,
91 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
93 'HTML::TableExtract' => [0,
94 'Parsing HTML tables/Bio::DB::SeqVersion::gi'],
96 'HTTP::Request::Common' => [0,
97 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
98 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
99 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
101 'List::MoreUtils' => [0,
102 'Back- or reverse-translation of sequences/'.
103 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
105 'LWP::UserAgent' => [0,
106 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
108 'Math::Random' => [0,
109 'Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory'],
111 'PostScript::TextBlock' => [0,
112 'EPS output/Bio::Tree::Draw::Cladogram'],
114 'Set::Scalar' => [0,
115 'Proper operation/Bio::Tree::Compatible'],
117 'SOAP::Lite' => [0,
118 'Bibliographic queries/Bio::DB::Biblio::soap'],
120 'Sort::Naturally' => [0,
121 'Sort lexically, but sort numeral parts numerically/'.
122 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
124 'Spreadsheet::ParseExcel' => [0,
125 'Parsing Excel files/Bio::SeqIO::excel'],
127 'Storable' => [2.05,
128 'Storing sequence objects in local file cache/'.
129 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
130 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'],
132 'SVG' => [2.26,
133 'Creating SVG images/Bio::Draw::Pictogram'],
135 'SVG::Graph' => [0.01,
136 'Creating SVG images/Bio::TreeIO::svggraph'],
138 'Text::ParseWords' => [0,
139 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
141 'XML::Parser' => [0,
142 'parsing xml/Bio::Biblio::IO::medlinexml'],
144 'XML::Parser::PerlSAX' => [0,
145 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
146 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
148 'XML::SAX' => [0.15,
149 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
151 'XML::SAX::Writer' => [0,
152 'Writing XML/Bio::SeqIO::tigrxml'],
154 'XML::Simple' => [0,
155 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
157 'XML::Twig' => [0,
158 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
159 'Bio::DB::Biblio::eutils'],
161 'XML::Writer' => [0.4,
162 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
163 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
164 'Bio::SearchIO::Writer::BSMLResultWriter'],
166 'YAML' => [0,
167 'GenBank->GFF3/bp_genbank2gff3.pl'],
170 my $mysql_ok = 0;
172 my @drivers = available_drivers();
174 # Set up the Bio::Root::Build object
175 my $build = Bio::Root::Build->new(
176 module_name => 'Bio',
177 dist_name => 'BioPerl',
178 dist_version => '1.006902',
179 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
180 dist_abstract => 'Bioinformatics Toolkit',
181 license => 'perl',
182 no_index => {'dir' => [qw(examples/root/lib)]},
183 requires => {
184 'perl' => '5.6.1',
185 'IO::String' => 0, # why is this required?
186 'DB_File' => 0, # why is this required?
187 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
188 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
189 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
192 build_requires => {
193 'CPAN' => 1.81,
194 'Module::Build' => 0.2805,
195 'Test::Harness' => 2.62,
196 'Test::Most' => 0,
197 'URI::Escape' => 0
200 recommends => {
201 # reverted to a simple Module::Build-compatible hash, but we keep
202 # additional data in the %recommends hash above. May be converted to
203 # something simpler if there aren't complaints down the line.
204 map {$_ => $recommends{$_}[0]} sort keys %recommends
207 get_options => {
208 accept => { },
209 network => { } # say 'perl Build.PL --network' to manually request network tests
212 auto_features => {
213 'EntrezGene' => {
214 description => "Presence of Bio::ASN1::EntrezGene",
215 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
218 'DB_File Tests' => {
219 description => "BDB tests for Bio::DB::SeqFeature::Store",
220 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
223 'Bio::DB::GFF Tests' => {
224 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
225 requires => { 'DBI' => 0 },
228 'MySQL Tests' => {
229 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
230 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
233 'Pg Tests' => {
234 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
235 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
238 'SQLite Tests' => {
239 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
240 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
243 'Network Tests' => {
244 description => "Enable tests that need an internet connection",
245 requires => { 'LWP::UserAgent' => 0 },
248 dynamic_config => 1,
249 #create_makefile_pl => 'passthrough',
250 recursive_test_files => 1,
252 # Extra files needed for BioPerl modules
253 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
255 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
256 #script_files => [] # scripts in scripts directory are installed on-demand
259 my $accept = $build->args('accept');
261 # how much do I hate this? Let me count the ways.....
262 if (!$build->feature('EntrezGene')) {
263 warn <<WARN;
264 ############################# WARNING #############################
266 Bio::ASN1::EntrezGene not found. This is an *optional* module;
267 however, because it has a circular dependency with BioPerl we do not
268 include it on our list of recommended modules.
270 If you require EntrezGene functionality, you can install
271 Bio::ASN1::EntrezGene after BioPerl has finished installing.
273 ############################# WARNING #############################
275 WARN
276 sleep 3;
279 my $proceed = prompt_for_biodb($accept)
280 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
281 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
283 # Handle auto features
284 if ($proceed && $build->feature('DB_File Tests')) {
285 # will return without doing anything if user chose not to run tests during
286 make_bdb_test();
288 if ($proceed && ($build->feature('MySQL Tests') ||
289 $build->feature('Pg Tests') ||
290 $build->feature('SQLite Tests'))) {
291 make_dbi_test();
294 # Ask questions
295 $build->choose_scripts($accept);
297 if ($build->args('network')) {
298 if ($build->feature('Network Tests')) {
299 $build->notes(network => 1);
300 $build->log_info(" - will run internet-requiring tests\n");
302 else {
303 $build->notes(network => 0);
304 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
307 else {
308 $build->prompt_for_network($accept) if $build->feature('Network Tests');
311 # Add additional files here
312 $build->add_build_element('xml');
314 # Create the build script and exit
315 $build->create_build_script;
317 exit;
319 ########################## Helper subs ##########################
321 sub make_bdb_test {
322 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
323 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
324 unlink($path) if (-e $path);
325 open(my $F, ">", $path) || die "Can't create test file\n";
326 print $F <<END;
327 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
329 close $F;
330 $build->add_to_cleanup($path);
331 #$build->add_to_manifest_skip($path);
334 sub available_drivers {
335 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
336 return if $@;
337 @drivers = DBI->available_drivers;
338 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
339 $mysql_ok = 0;
340 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
342 $mysql_ok = 1;
343 return @drivers;
346 sub make_dbi_test {
347 my $dsn = $build->notes('test_dsn') || return;
348 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
349 my $driver = $build->notes('dbd_driver');
350 my $path = File::Spec->catfile('t', 'LocalDB',
351 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
352 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
353 'SeqFeature_Pg.t');
354 my $test_db = $build->notes('test_db');
355 my $user = $build->notes('test_user');
356 my $pass = $build->notes('test_pass');
357 open my $F,">$path";
358 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
359 $str .= " -user $user" if $user;
360 $str .= " -password $pass" if $pass;
361 print $F <<END;
362 system '$^X $str';
364 close $F;
365 $build->add_to_cleanup($path);
366 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
367 #$build->add_to_manifest_skip($path);
370 sub test_biodbgff {
371 eval {require DBI;}; # if not installed, this sub won't actually be called
372 return if $@;
373 @drivers = DBI->available_drivers;
374 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
375 return "MySQL, Pg nor Oracle DBI drivers are installed";
377 return;
380 sub prompt_for_biodb {
381 my $accept = shift;
382 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
383 "Bio::DB::SeqFeature::Store live database tests? ".
384 "y/n", 'n');
386 if ($proceed) {
387 my @driver_choices;
388 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
389 if (grep {/$poss/i} @drivers) {
390 my $choice = $poss;
391 $choice =~ s/^(.)/[$1]/;
392 push(@driver_choices, $choice);
396 my $driver;
397 if (@driver_choices > 1) {
398 my ($default) = $driver_choices[0] =~ /\[(.)/;
399 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
401 else {
402 ($driver) = $driver_choices[0] =~ /\[(.)/;
404 if ($driver =~ /^[mM]/) {
405 $driver = 'mysql';
407 elsif ($driver =~ /^[pP]/) {
408 $driver = 'Pg';
410 elsif ($driver =~ /^[oO]/) {
411 $driver = 'Oracle';
413 elsif ($driver =~ /^[sS]/) {
414 $driver = 'SQLite';
417 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
418 "This database should already be present but doesn't have to ".
419 "be preloaded for any schema", 'test');
420 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
421 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
422 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
424 my $use_host = 1;
425 if ($test_host eq 'undef' || $test_host eq 'localhost') {
426 $use_host = 0;
429 my $test_dsn;
430 if ($driver eq 'Pg' || $driver eq 'SQLite') {
431 $test_dsn = "dbi:$driver:dbname=$test_db";
432 $mysql_ok = 0;
434 else {
435 $test_dsn = "dbi:$driver:database=$test_db";
436 $mysql_ok = 0;
438 if ($use_host) {
439 $test_dsn .= ";host=$test_host";
442 $build->notes(dbd_driver => $driver);
443 $build->notes(test_db => $test_db);
444 $build->notes(test_host => $test_host);
445 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
446 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
447 $build->notes(test_dsn => $test_dsn);
449 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
450 " Database $test_db\n",
451 " Host $test_host\n",
452 " DSN $test_dsn\n",
453 " User $test_user\n",
454 " Password $test_pass\n");
455 $build->log_info(" - will not run the BioDBSeqFeature live ".
456 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
458 else {
459 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
462 $build->log_info("\n");
463 return $proceed;