URLify
[bioperl-live.git] / Build.PL
blob71e21961968c172c993bb2e6105f1dc6760a243e
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 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
75 'Convert::Binary::C' =>
76 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
78 'DB_File' => [ 0, 'Database functionality/Bio::Assemby,Bio::DB' ],
80 'Error' => [
81 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
84 'GD' => [ 0, 'Alignment graphic output/Bio::Align::Graphics' ],
86 'Graph' => [
87 0.50,
88 'Phylogenetic Networks, ontology engine implementation, contig analysis'
89 . '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'
90 . 'Bio::Assembly::Tools::ContigSpectrum'
93 'GraphViz' => [
94 0, 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'
97 'HTML::Entities' =>
98 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
100 'HTML::HeadParser' => [
102 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
105 'HTML::TableExtract' =>
106 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
108 'HTTP::Request::Common' => [
110 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
111 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
112 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
115 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
117 'IO::Scalar' => [
118 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
121 'List::MoreUtils' => [
123 'Back- or reverse-translation of sequences/'
124 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
127 'LWP::UserAgent' => [
129 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
132 'PostScript::TextBlock' => [ 0, 'EPS output/Bio::Tree::Draw::Cladogram' ],
134 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
136 'SOAP::Lite' => [ 0, 'Bibliographic queries/Bio::DB::Biblio::soap' ],
138 'Sort::Naturally' => [
140 'Sort lexically, but sort numeral parts numerically/'
141 . 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'
144 'Spreadsheet::ParseExcel' =>
145 [ 0, 'Parsing Excel files/Bio::SeqIO::excel' ],
147 'Storable' => [
148 2.05,
149 'Storing sequence objects in local file cache/'
150 . 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'
151 . 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'
154 'SVG' => [ 2.26, 'Creating SVG images/Bio::Draw::Pictogram' ],
156 'SVG::Graph' => [ 0.01, 'Creating SVG images/Bio::TreeIO::svggraph' ],
158 'Text::ParseWords' =>
159 [ 0, 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader' ],
161 'XML::DOM' => [ 0, 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro' ],
163 'XML::DOM::XPath' => [ 0, 'Parsing XML/Bio::SeqIO::interpro' ],
165 'XML::LibXML' =>
166 [ 0, 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml' ],
168 'XML::Parser' => [ 0, 'Parsing XML/Bio::Biblio::IO::medlinexml' ],
170 'XML::Parser::PerlSAX' => [
172 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
173 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'
176 'XML::SAX' => [
177 0.15,
178 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'
181 'XML::SAX::Writer' => [ 0, 'Writing XML/Bio::SeqIO::tigrxml' ],
183 'XML::Simple' => [
185 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'
188 'XML::Twig' => [
190 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'
191 . 'Bio::DB::Biblio::eutils'
194 'XML::Writer' => [
195 0.4,
196 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
197 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
198 . 'Bio::SearchIO::Writer::BSMLResultWriter'
201 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
204 my $mysql_ok = 0;
206 my @drivers = available_drivers();
208 # Set up the Bio::Root::Build object
209 my $build = Bio::Root::Build->new(
210 module_name => 'Bio',
211 dist_name => 'BioPerl',
212 dist_version => '1.006925',
213 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
214 dist_abstract => 'Bioinformatics Toolkit',
215 license => 'perl',
216 requires => {
217 'perl' => '5.6.1',
218 'IO::String' => 0, # why is this required?
219 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
220 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
221 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
224 build_requires => {
225 'CPAN' => 1.81,
226 'Module::Build' => 0.2805,
227 'Test::Harness' => 2.62,
228 'Test::Most' => 0,
229 'URI::Escape' => 0
232 recommends => {
233 # reverted to a simple Module::Build-compatible hash, but we keep
234 # additional data in the %recommends hash above. May be converted to
235 # something simpler if there aren't complaints down the line.
236 map { $_ => $recommends{$_}[0] } sort keys %recommends
239 get_options => {
240 accept => {},
241 network => {} # say 'perl Build.PL --network' to manually request network tests
244 auto_features => {
245 'EntrezGene' => {
246 description => "Presence of Bio::ASN1::EntrezGene",
247 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
250 'DB_File Tests' => {
251 description => "BDB tests for Bio::DB::SeqFeature::Store",
252 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
255 'Bio::DB::GFF Tests' => {
256 description =>
257 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
258 requires => { 'DBI' => 0 },
261 'MySQL Tests' => {
262 description =>
263 "MySQL-related tests for Bio::DB::SeqFeature::Store",
264 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
267 'Pg Tests' => {
268 description =>
269 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
270 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
273 'SQLite Tests' => {
274 description =>
275 "SQLite-related tests for Bio::DB::SeqFeature::Store",
276 requires => { 'DBI' => 0, 'DBD::SQLite' => 0 },
279 'Network Tests' => {
280 description => "Enable tests that need an internet connection",
281 requires => { 'LWP::UserAgent' => 0 },
284 dynamic_config => 1,
285 recursive_test_files => 1,
287 # Extra files needed for BioPerl modules
288 xml_files => {
289 './Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'
292 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
293 #script_files => [] # scripts in scripts directory are installed on-demand
296 my $accept = $build->args('accept');
298 my $proceed = prompt_for_biodb($accept)
299 if $build->feature('Bio::DB::GFF')
300 || $build->feature('MySQL Tests')
301 || $build->feature('Pg Tests')
302 || $build->feature('SQLite Tests');
304 # Handle auto features
305 if ( $proceed && $build->feature('DB_File Tests') ) {
307 # will return without doing anything if user chose not to run tests during
308 make_bdb_test();
310 if ($proceed
311 && ( $build->feature('MySQL Tests')
312 || $build->feature('Pg Tests')
313 || $build->feature('SQLite Tests') )
315 make_dbi_test();
318 # Ask questions
319 $build->choose_scripts($accept);
321 if ( $build->args('network') ) {
322 if ( $build->feature('Network Tests') ) {
323 $build->notes( network => 1 );
324 $build->log_info(" - will run internet-requiring tests\n");
325 } else {
326 $build->notes( network => 0 );
327 $build->log_info(
328 " - Missing LWP::UserAgent, can't run network tests\n");
330 } else {
331 $build->prompt_for_network($accept) if $build->feature('Network Tests');
334 # Add additional files here
335 $build->add_build_element('xml');
337 # Create the build script and exit
338 $build->create_build_script;
340 exit;
342 ########################## Helper subs ##########################
344 sub make_bdb_test {
345 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
346 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
347 unlink($path) if ( -e $path );
348 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
349 print $F <<END;
350 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
352 close $F;
353 $build->add_to_cleanup($path);
355 #$build->add_to_manifest_skip($path);
358 sub available_drivers {
359 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
360 return if $@;
361 @drivers = DBI->available_drivers;
362 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
363 $mysql_ok = 0;
364 return
365 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
367 $mysql_ok = 1;
368 return @drivers;
371 sub make_dbi_test {
372 my $dsn = $build->notes('test_dsn') || return;
373 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
374 my $driver = $build->notes('dbd_driver');
375 my $path = File::Spec->catfile( 't', 'LocalDB',
376 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
377 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
378 : 'SeqFeature_Pg.t' );
379 my $test_db = $build->notes('test_db');
380 my $user = $build->notes('test_user');
381 my $pass = $build->notes('test_pass');
382 open my $F, '>', $path
383 or die "Could not write file '$path' for DBI test: $!\n";
384 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
385 $str .= " -user $user" if $user;
386 $str .= " -password $pass" if $pass;
387 print $F <<END;
388 system '$^X $str';
390 close $F;
391 $build->add_to_cleanup($path);
392 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
394 #$build->add_to_manifest_skip($path);
397 sub test_biodbgff {
398 eval { require DBI; }; # if not installed, this sub won't actually be called
399 return if $@;
400 @drivers = DBI->available_drivers;
401 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
402 return "MySQL, Pg nor Oracle DBI drivers are installed";
404 return;
407 sub prompt_for_biodb {
408 my $accept = shift;
409 my $proceed = $accept ? 0 : $build->y_n(
410 "Do you want to run the Bio::DB::GFF or "
411 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
415 if ($proceed) {
416 my @driver_choices;
417 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
418 if ( grep {/$poss/i} @drivers ) {
419 my $choice = $poss;
420 $choice =~ s/^(.)/[$1]/;
421 push( @driver_choices, $choice );
425 my $driver;
426 if ( @driver_choices > 1 ) {
427 my ($default) = $driver_choices[0] =~ /\[(.)/;
428 $driver = $build->prompt(
429 "Which database driver should be used? "
430 . join( " ", @driver_choices ),
431 $default
433 } else {
434 ($driver) = $driver_choices[0] =~ /\[(.)/;
436 if ( $driver =~ /^[mM]/ ) {
437 $driver = 'mysql';
438 } elsif ( $driver =~ /^[pP]/ ) {
439 $driver = 'Pg';
440 } elsif ( $driver =~ /^[oO]/ ) {
441 $driver = 'Oracle';
442 } elsif ( $driver =~ /^[sS]/ ) {
443 $driver = 'SQLite';
446 my $test_db = $build->prompt(
447 "Which database should I use for testing the $driver driver?\n"
448 . "This database should already be present but doesn't have to "
449 . "be preloaded for any schema",
450 'test'
452 my $test_host = $build->prompt(
453 "On which host is database '$test_db' running (hostname, ip address or host:port)",
454 'localhost'
456 my $test_user = $build->prompt(
457 "User name for connecting to database '$test_db'?", 'undef' );
458 my $test_pass = $build->prompt(
459 "Password for connecting to database '$test_db'?", 'undef' );
461 my $use_host = 1;
462 if ( $test_host eq 'undef' || $test_host eq 'localhost' ) {
463 $use_host = 0;
466 my $test_dsn;
467 if ( $driver eq 'Pg' || $driver eq 'SQLite' ) {
468 $test_dsn = "dbi:$driver:dbname=$test_db";
469 $mysql_ok = 0;
470 } else {
471 $test_dsn = "dbi:$driver:database=$test_db";
472 $mysql_ok = 0;
474 if ($use_host) {
475 $test_dsn .= ";host=$test_host";
478 $build->notes( dbd_driver => $driver );
479 $build->notes( test_db => $test_db );
480 $build->notes( test_host => $test_host );
481 $build->notes(
482 test_user => $test_user eq 'undef' ? undef : $test_user );
483 $build->notes(
484 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
485 $build->notes( test_dsn => $test_dsn );
487 $build->log_info(
488 " - will run tests with database driver '$driver' and these settings:\n",
489 " Database $test_db\n",
490 " Host $test_host\n",
491 " DSN $test_dsn\n",
492 " User $test_user\n",
493 " Password $test_pass\n"
495 $build->log_info( " - will not run the BioDBSeqFeature live "
496 . "database tests (requires MySQL or Pg driver)\n" )
497 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
498 } else {
499 $build->log_info(
500 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
504 $build->log_info("\n");
505 return $proceed;