[skip ci] add some changes
[bioperl-live.git] / Build.PL
blob715fd0b2d4a38087d7de56ea81073b329d6f01c6
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 'PostScript::TextBlock' => [0,
109 'EPS output/Bio::Tree::Draw::Cladogram'],
111 'Set::Scalar' => [0,
112 'Proper operation/Bio::Tree::Compatible'],
114 'SOAP::Lite' => [0,
115 'Bibliographic queries/Bio::DB::Biblio::soap'],
117 'Sort::Naturally' => [0,
118 'Sort lexically, but sort numeral parts numerically/'.
119 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
121 'Spreadsheet::ParseExcel' => [0,
122 'Parsing Excel files/Bio::SeqIO::excel'],
124 'Storable' => [2.05,
125 'Storing sequence objects in local file cache/'.
126 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
127 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'],
129 'SVG' => [2.26,
130 'Creating SVG images/Bio::Draw::Pictogram'],
132 'SVG::Graph' => [0.01,
133 'Creating SVG images/Bio::TreeIO::svggraph'],
135 'Text::ParseWords' => [0,
136 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
138 'XML::Parser' => [0,
139 'parsing xml/Bio::Biblio::IO::medlinexml'],
141 'XML::Parser::PerlSAX' => [0,
142 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
143 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
145 'XML::SAX' => [0.15,
146 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
148 'XML::SAX::Writer' => [0,
149 'Writing XML/Bio::SeqIO::tigrxml'],
151 'XML::Simple' => [0,
152 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
154 'XML::Twig' => [0,
155 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
156 'Bio::DB::Biblio::eutils'],
158 'XML::Writer' => [0.4,
159 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
160 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
161 'Bio::SearchIO::Writer::BSMLResultWriter'],
163 'YAML' => [0,
164 'GenBank->GFF3/bp_genbank2gff3.pl'],
167 my $mysql_ok = 0;
169 my @drivers = available_drivers();
171 # Set up the Bio::Root::Build object
172 my $build = Bio::Root::Build->new(
173 module_name => 'Bio',
174 dist_name => 'BioPerl',
175 dist_version => '1.006902',
176 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
177 dist_abstract => 'Bioinformatics Toolkit',
178 license => 'perl',
179 no_index => {'x_dir' => [qw(examples/root/lib)]},
180 requires => {
181 'perl' => '5.6.1',
182 'IO::String' => 0, # why is this required?
183 'DB_File' => 0, # why is this required?
184 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
185 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
186 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
189 build_requires => {
190 'CPAN' => 1.81,
191 'Module::Build' => 0.2805,
192 'Test::Harness' => 2.62,
193 'Test::Most' => 0,
194 'URI::Escape' => 0
197 recommends => {
198 # reverted to a simple Module::Build-compatible hash, but we keep
199 # additional data in the %recommends hash above. May be converted to
200 # something simpler if there aren't complaints down the line.
201 map {$_ => $recommends{$_}[0]} sort keys %recommends
204 get_options => {
205 accept => { },
206 network => { } # say 'perl Build.PL --network' to manually request network tests
209 auto_features => {
210 'EntrezGene' => {
211 description => "Presence of Bio::ASN1::EntrezGene",
212 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
215 'DB_File Tests' => {
216 description => "BDB tests for Bio::DB::SeqFeature::Store",
217 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
220 'Bio::DB::GFF Tests' => {
221 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
222 requires => { 'DBI' => 0 },
225 'MySQL Tests' => {
226 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
227 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
230 'Pg Tests' => {
231 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
232 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
235 'SQLite Tests' => {
236 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
237 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
240 'Network Tests' => {
241 description => "Enable tests that need an internet connection",
242 requires => { 'LWP::UserAgent' => 0 },
245 dynamic_config => 1,
246 #create_makefile_pl => 'passthrough',
247 recursive_test_files => 1,
249 # Extra files needed for BioPerl modules
250 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
252 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
253 #script_files => [] # scripts in scripts directory are installed on-demand
256 my $accept = $build->args('accept');
258 # how much do I hate this? Let me count the ways.....
259 if (!$build->feature('EntrezGene')) {
260 warn <<WARN;
261 ############################# WARNING #############################
263 Bio::ASN1::EntrezGene not found. This is an *optional* module;
264 however, because it has a circular dependency with BioPerl we do not
265 include it on our list of recommended modules.
267 If you require EntrezGene functionality, you can install
268 Bio::ASN1::EntrezGene after BioPerl has finished installing.
270 ############################# WARNING #############################
272 WARN
273 sleep 3;
276 my $proceed = prompt_for_biodb($accept)
277 if $build->feature('Bio::DB::GFF') || $build->feature('MySQL Tests') ||
278 $build->feature('Pg Tests') || $build->feature('SQLite Tests');
280 # Handle auto features
281 if ($proceed && $build->feature('DB_File Tests')) {
282 # will return without doing anything if user chose not to run tests during
283 make_bdb_test();
285 if ($proceed && ($build->feature('MySQL Tests') ||
286 $build->feature('Pg Tests') ||
287 $build->feature('SQLite Tests'))) {
288 make_dbi_test();
291 # Ask questions
292 $build->choose_scripts($accept);
294 if ($build->args('network')) {
295 if ($build->feature('Network Tests')) {
296 $build->notes(network => 1);
297 $build->log_info(" - will run internet-requiring tests\n");
299 else {
300 $build->notes(network => 0);
301 $build->log_info(" - Missing LWP::UserAgent, can't run network tests\n");
304 else {
305 $build->prompt_for_network($accept) if $build->feature('Network Tests');
308 # Add additional files here
309 $build->add_build_element('xml');
311 # Create the build script and exit
312 $build->create_build_script;
314 exit;
316 ########################## Helper subs ##########################
318 sub make_bdb_test {
319 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
320 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
321 unlink($path) if (-e $path);
322 open(my $F, ">", $path) || die "Can't create test file\n";
323 print $F <<END;
324 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
326 close $F;
327 $build->add_to_cleanup($path);
328 #$build->add_to_manifest_skip($path);
331 sub available_drivers {
332 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
333 return if $@;
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 return if $@;
370 @drivers = DBI->available_drivers;
371 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
372 return "MySQL, Pg nor Oracle DBI drivers are installed";
374 return;
377 sub prompt_for_biodb {
378 my $accept = shift;
379 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
380 "Bio::DB::SeqFeature::Store live database tests? ".
381 "y/n", 'n');
383 if ($proceed) {
384 my @driver_choices;
385 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
386 if (grep {/$poss/i} @drivers) {
387 my $choice = $poss;
388 $choice =~ s/^(.)/[$1]/;
389 push(@driver_choices, $choice);
393 my $driver;
394 if (@driver_choices > 1) {
395 my ($default) = $driver_choices[0] =~ /\[(.)/;
396 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
398 else {
399 ($driver) = $driver_choices[0] =~ /\[(.)/;
401 if ($driver =~ /^[mM]/) {
402 $driver = 'mysql';
404 elsif ($driver =~ /^[pP]/) {
405 $driver = 'Pg';
407 elsif ($driver =~ /^[oO]/) {
408 $driver = 'Oracle';
410 elsif ($driver =~ /^[sS]/) {
411 $driver = 'SQLite';
414 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
415 "This database should already be present but doesn't have to ".
416 "be preloaded for any schema", 'test');
417 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
418 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
419 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
421 my $use_host = 1;
422 if ($test_host eq 'undef' || $test_host eq 'localhost') {
423 $use_host = 0;
426 my $test_dsn;
427 if ($driver eq 'Pg' || $driver eq 'SQLite') {
428 $test_dsn = "dbi:$driver:dbname=$test_db";
429 $mysql_ok = 0;
431 else {
432 $test_dsn = "dbi:$driver:database=$test_db";
433 $mysql_ok = 0;
435 if ($use_host) {
436 $test_dsn .= ";host=$test_host";
439 $build->notes(dbd_driver => $driver);
440 $build->notes(test_db => $test_db);
441 $build->notes(test_host => $test_host);
442 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
443 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
444 $build->notes(test_dsn => $test_dsn);
446 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
447 " Database $test_db\n",
448 " Host $test_host\n",
449 " DSN $test_dsn\n",
450 " User $test_user\n",
451 " Password $test_pass\n");
452 $build->log_info(" - will not run the BioDBSeqFeature live ".
453 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
455 else {
456 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
459 $build->log_info("\n");
460 return $proceed;