no need to print these out to a file, we just store these in the repo
[bioperl-live.git] / Build.PL
blob571e11a1c206a3f6c7204804bf65a97317360470
1 #!/usr/bin/perl -w
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 'Ace' => [0,
49 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
51 'Algorithm::Munkres' => [0,
52 'Phylogenetic Networks/Bio::PhyloNetwork'],
54 'Array::Compare' => [0,
55 'Phylogenetic Networks/Bio::PhyloNetwork'],
57 'YAML' => [0,
58 'GenBank->GFF3/bp_genbank2gff3.pl'],
60 # this won't actually install due to circular dep, but we have no way of
61 # doing a post-install the [circular dependency!] specifies it is only
62 # installed on explicit request for this specific module, not when simply
63 # choosing to install 'all' modules
65 #'Bio::ASN1::EntrezGene' => [0,
66 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
68 'Clone' => [0,
69 'Cloning objects/Bio::Tools::Primer3'],
71 'Convert::Binary::C' => [0,
72 'Strider functionality/Bio::SeqIO::strider'],
74 'Error' => [0,
75 'OO-based exception handling (very optional)/Bio::Root::Exception'],
77 'GD' => [0,
78 'Alignment graphic output/Bio::Align::Graphics'],
80 'Graph' => [0,
81 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
82 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
83 'Bio::Assembly::Tools::ContigSpectrum'],
85 'GraphViz' => [0,
86 'Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz'],
88 'HTML::Entities' => [0,
89 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
91 'HTML::HeadParser' => [3,
92 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
94 'HTTP::Request::Common' => [0,
95 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
96 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
97 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
99 'List::MoreUtils' => [0,
100 'Back- or reverse-translation of sequences/'.
101 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
103 'LWP::UserAgent' => [0,
104 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
106 'Math::Random' => [0,
107 'Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory'],
109 'PostScript::TextBlock' => [0,
110 'EPS output/Bio::Tree::Draw::Cladogram'],
112 'Set::Scalar' => [0,
113 'Proper operation/Bio::Tree::Compatible'],
115 'SOAP::Lite' => [0,
116 'Bibliographic queries/Bio::DB::Biblio::soap'],
118 'Sort::Naturally' => [0,
119 'Sort lexically, but sort numeral parts numerically/'.
120 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
122 'Spreadsheet::ParseExcel' => [0,
123 'Parsing Excel files/Bio::SeqIO::excel'],
125 'Storable' => [2.05,
126 'Storing sequence objects in local file cache/'.
127 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
128 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb'],
130 'SVG' => [2.26,
131 'Creating SVG images/Bio::Draw::Pictogram'],
133 'SVG::Graph' => [0.01,
134 'Creating SVG images/Bio::TreeIO::svggraph'],
136 'Text::ParseWords' => [0,
137 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
139 'URI::Escape' => [0,
140 'Dealing with web resources/Bio::FeatureIO::gff,Bio::FeatureIO::interpro,'.
141 'Bio::DB::Biblio::eutils,Bio::DB::EUtilParameters,'.
142 'Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated'],
144 'XML::DOM::XPath' => [0.13,
145 'parsing interpro features/Bio::FeatureIO::interpro'],
147 'XML::Parser' => [0,
148 'parsing xml/Bio::Biblio::IO::medlinexml'],
150 'XML::Parser::PerlSAX' => [0,
151 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
152 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
154 'XML::SAX' => [0.15,
155 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
157 'XML::SAX::Writer' => [0,
158 'Writing XML/Bio::SeqIO::tigrxml'],
160 'XML::Simple' => [0,
161 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
163 'XML::Twig' => [0,
164 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
165 'Bio::DB::Biblio::eutils'],
167 'XML::Writer' => [0.4,
168 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
169 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
170 'Bio::SearchIO::Writer::BSMLResultWriter'],
173 my $mysql_ok = 0;
175 my @drivers = available_drivers();
177 # Set up the Bio::Root::Build object
178 my $build = Bio::Root::Build->new(
179 module_name => 'Bio',
180 dist_name => 'BioPerl',
181 dist_version_from => 'Bio/Root/Version.pm',
182 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
183 dist_abstract => 'Bioinformatics Toolkit',
184 license => 'perl',
185 no_index => {'dir' => [qw(examples/root/lib)]},
186 requires => {
187 'perl' => '5.6.1',
188 'IO::String' => 0,
189 'DB_File' => 0,
190 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
191 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
192 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
195 build_requires => {
196 'Test::More' => 0,
197 'Module::Build' => 0.2805,
198 'Test::Harness' => 2.62,
199 'CPAN' => 1.81
202 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
203 map {$_ => $recommends{$_}[0]} sort keys %recommends
206 get_options => {
207 accept => { },
208 network => { } # say 'perl Build.PL --network' to manually request network tests
211 auto_features => {
212 'EntrezGene' => {
213 description => "Presence of Bio::ASN1::EntrezGene",
214 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
217 'DB_File Tests' => {
218 description => "BDB tests for Bio::DB::SeqFeature::Store",
219 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
222 'Bio::DB::GFF Tests' => {
223 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
224 requires => { 'DBI' => 0 },
227 'MySQL Tests' => {
228 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
229 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
232 'Pg Tests' => {
233 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
234 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
237 'SQLite Tests' => {
238 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
239 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
242 'Network Tests' => {
243 description => "Enable tests that need an internet connection",
244 requires => { 'LWP::UserAgent' => 0 },
247 dynamic_config => 1,
248 create_makefile_pl => 'passthrough',
249 recursive_test_files => 1,
251 # Extra files needed for BioPerl modules
252 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
254 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
255 #script_files => [] # scripts in scripts directory are installed on-demand
258 my $accept = $build->args('accept');
260 # how much do I hate this? Let me count the ways.....
261 if (!$build->feature('EntrezGene')) {
262 warn <<WARN;
263 ############################# WARNING #############################
265 Bio::ASN1::EntrezGene not found. This is an *optional* module;
266 however, because it has a circular dependency with BioPerl we do not
267 include it on our list of recommended modules.
269 If you require EntrezGene functionality, you can install
270 Bio::ASN1::EntrezGene after BioPerl has finished installing.
272 ############################# WARNING #############################
274 WARN
275 sleep 3;
278 my $proceed = prompt_for_biodb($accept) if $build->feature('Bio::DB::GFF')
279 || $build->feature('MySQL Tests') || $build->feature('MySQL Tests');
281 # Handle auto features
282 if ($proceed && $build->feature('DB_File Tests')) {
283 # will return without doing anything if user chose not to run tests during
284 make_bdb_test();
286 if ($proceed && ($build->feature('MySQL Tests') ||
287 $build->feature('Pg Tests') ||
288 $build->feature('SQLite Tests'))) {
289 make_dbi_test();
292 # Ask questions
293 $build->choose_scripts($accept);
295 if ($build->args('network')) {
296 if ($build->feature('Network Tests')) {
297 $build->notes(network => 1);
298 $build->log_info(" - will run internet-requiring tests\n");
300 else {
301 $build->notes(network => 0);
302 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
305 else {
306 $build->prompt_for_network($accept) if $build->feature('Network Tests');
309 # Add additional files here
310 $build->add_build_element('xml');
312 # Create the build script and exit
313 $build->create_build_script;
315 exit;
317 ########################## Helper subs ##########################
319 sub make_bdb_test {
320 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
321 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
322 unlink($path) if (-e $path);
323 open(my $F, ">", $path) || die "Can't create test file\n";
324 print $F <<END;
325 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
327 close $F;
328 $build->add_to_cleanup($path);
329 #$build->add_to_manifest_skip($path);
332 sub available_drivers {
333 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
334 @drivers = DBI->available_drivers;
335 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
336 $mysql_ok = 0;
337 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
339 $mysql_ok = 1;
340 return @drivers;
343 sub make_dbi_test {
344 my $dsn = $build->notes('test_dsn') || return;
345 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
346 my $driver = $build->notes('dbd_driver');
347 my $path = File::Spec->catfile('t', 'LocalDB',
348 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
349 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
350 'SeqFeature_Pg.t');
351 my $test_db = $build->notes('test_db');
352 my $user = $build->notes('test_user');
353 my $pass = $build->notes('test_pass');
354 open my $F,">$path";
355 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
356 $str .= " -user $user" if $user;
357 $str .= " -password $pass" if $pass;
358 print $F <<END;
359 system '$^X $str';
361 close $F;
362 $build->add_to_cleanup($path);
363 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
364 #$build->add_to_manifest_skip($path);
367 sub test_biodbgff {
368 eval {require DBI;}; # if not installed, this sub won't actually be called
369 @drivers = DBI->available_drivers;
370 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
371 return "MySQL, Pg nor Oracle DBI drivers are installed";
373 return;
376 sub prompt_for_biodb {
377 my $accept = shift;
378 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
379 "Bio::DB::SeqFeature::Store live database tests? ".
380 "y/n", 'n');
382 if ($proceed) {
383 my @driver_choices;
384 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
385 if (grep {/$poss/i} @drivers) {
386 my $choice = $poss;
387 $choice =~ s/^(.)/[$1]/;
388 push(@driver_choices, $choice);
392 my $driver;
393 if (@driver_choices > 1) {
394 my ($default) = $driver_choices[0] =~ /\[(.)/;
395 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
397 else {
398 ($driver) = $driver_choices[0] =~ /\[(.)/;
400 if ($driver =~ /^[mM]/) {
401 $driver = 'mysql';
403 elsif ($driver =~ /^[pP]/) {
404 $driver = 'Pg';
406 elsif ($driver =~ /^[oO]/) {
407 $driver = 'Oracle';
409 elsif ($driver =~ /^[sS]/) {
410 $driver = 'SQLite';
413 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
414 "This database should already be present but doesn't have to ".
415 "be preloaded for any schema", 'test');
416 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
417 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
418 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
420 my $use_host = 1;
421 if ($test_host eq 'undef' || $test_host eq 'localhost') {
422 $use_host = 0;
425 my $test_dsn;
426 if ($driver eq 'Pg' || $driver eq 'SQLite') {
427 $test_dsn = "dbi:$driver:dbname=$test_db";
428 $mysql_ok = 0;
430 else {
431 $test_dsn = "dbi:$driver:database=$test_db";
432 $mysql_ok = 0;
434 if ($use_host) {
435 $test_dsn .= ";host=$test_host";
438 $build->notes(dbd_driver => $driver);
439 $build->notes(test_db => $test_db);
440 $build->notes(test_host => $test_host);
441 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
442 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
443 $build->notes(test_dsn => $test_dsn);
445 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
446 " Database $test_db\n",
447 " Host $test_host\n",
448 " DSN $test_dsn\n",
449 " User $test_user\n",
450 " Password $test_pass\n");
451 $build->log_info(" - will not run the BioDBSeqFeature live ".
452 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
454 else {
455 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
458 $build->log_info("\n");
459 return $proceed;