convert to markdown and add some basic installation info for cpanm/perlbrew (docker...
[bioperl-live.git] / Build.PL
blobaf3ce3c0e1d0a1fc5e044379b9e6d086239a5467
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 'CGI' => [ 0, 'CGI-y things/Bio::DB::Query::HIVQuery' ],
75 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
77 'Convert::Binary::C' =>
78 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
80 'DB_File' => [ 0, 'Database functionality/Bio::Assemby,Bio::DB' ],
82 'Error' => [
83 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
86 'GD' => [ 0, 'Alignment graphic output/Bio::Align::Graphics' ],
88 'Graph' => [
89 0.50,
90 'Phylogenetic Networks, ontology engine implementation, contig analysis'
91 . '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'
92 . 'Bio::Assembly::Tools::ContigSpectrum'
95 'GraphViz' => [
96 0, 'Phylogenetic Network Visualization/Bio::PhyloNetwork::GraphViz'
99 'HTML::Entities' =>
100 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
102 'HTML::HeadParser' => [
104 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
107 'HTML::TableExtract' =>
108 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
110 'HTTP::Request::Common' => [
112 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
113 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
114 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
117 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
119 'IO::Scalar' => [
120 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
123 'List::MoreUtils' => [
125 'Back- or reverse-translation of sequences/'
126 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
129 'LWP::UserAgent' => [
131 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
134 'PostScript::TextBlock' => [ 0, 'EPS output/Bio::Tree::Draw::Cladogram' ],
136 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
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::OntologyIO::InterProParser' ],
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'
193 'XML::Writer' => [
194 0.4,
195 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
196 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
197 . 'Bio::SearchIO::Writer::BSMLResultWriter'
200 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
203 my $mysql_ok = 0;
205 my @drivers = available_drivers();
207 # Set up the Bio::Root::Build object
208 my $build = Bio::Root::Build->new(
209 module_name => 'Bio',
210 dist_name => 'BioPerl',
211 dist_version => $Bio::Root::Version::VERSION,
212 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
213 dist_abstract => 'Bioinformatics Toolkit',
214 license => 'perl',
215 requires => {
216 'perl' => '5.6.1',
217 'IO::String' => 0, # why is this required?
218 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
219 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
220 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
223 configure_requires => {
224 'Module::Build' => 0.42,
227 build_requires => {
228 'Module::Build' => 0.42,
229 'CPAN' => 1.81,
230 'Test::Harness' => 2.62,
231 'Test::Most' => 0,
232 'URI::Escape' => 0
235 recommends => {
236 # reverted to a simple Module::Build-compatible hash, but we keep
237 # additional data in the %recommends hash above. May be converted to
238 # something simpler if there aren't complaints down the line.
239 map { $_ => $recommends{$_}[0] } sort keys %recommends
242 get_options => {
243 accept => {},
244 network => {} # say 'perl Build.PL --network' to manually request network tests
247 auto_features => {
248 'EntrezGene' => {
249 description => "Presence of Bio::ASN1::EntrezGene",
250 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
253 'DB_File Tests' => {
254 description => "BDB tests for Bio::DB::SeqFeature::Store",
255 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
258 'Bio::DB::GFF Tests' => {
259 description =>
260 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
261 requires => { 'DBI' => 0 },
264 'MySQL Tests' => {
265 description =>
266 "MySQL-related tests for Bio::DB::SeqFeature::Store",
267 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
270 'Pg Tests' => {
271 description =>
272 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
273 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
276 'SQLite Tests' => {
277 description =>
278 "SQLite-related tests for Bio::DB::SeqFeature::Store",
279 requires => { 'DBI' => 0, 'DBD::SQLite' => 0 },
282 'Network Tests' => {
283 description => "Enable tests that need an internet connection",
284 requires => { 'LWP::UserAgent' => 0 },
287 dynamic_config => 1,
288 recursive_test_files => 1,
290 # Extra files needed for BioPerl modules
291 xml_files => {
292 './Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'
295 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
296 #script_files => [] # scripts in scripts directory are installed on-demand
299 my $accept = $build->args('accept');
301 my $proceed = prompt_for_biodb($accept)
302 if $build->feature('Bio::DB::GFF')
303 || $build->feature('MySQL Tests')
304 || $build->feature('Pg Tests')
305 || $build->feature('SQLite Tests');
307 # Handle auto features
308 if ( $proceed && $build->feature('DB_File Tests') ) {
310 # will return without doing anything if user chose not to run tests during
311 make_bdb_test();
313 if ($proceed
314 && ( $build->feature('MySQL Tests')
315 || $build->feature('Pg Tests')
316 || $build->feature('SQLite Tests') )
318 make_dbi_test();
321 # Ask questions
322 $build->choose_scripts($accept);
324 if ( $build->args('network') ) {
325 if ( $build->feature('Network Tests') ) {
326 $build->notes( network => 1 );
327 $build->log_info(" - will run internet-requiring tests\n");
328 } else {
329 $build->notes( network => 0 );
330 $build->log_info(
331 " - Missing LWP::UserAgent, can't run network tests\n");
333 } else {
334 $build->prompt_for_network($accept) if $build->feature('Network Tests');
337 # Add additional files here
338 $build->add_build_element('xml');
340 # Create the build script and exit
341 $build->create_build_script;
343 exit;
345 ########################## Helper subs ##########################
347 sub make_bdb_test {
348 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
349 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
350 unlink($path) if ( -e $path );
351 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
352 print $F <<END;
353 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
355 close $F;
356 $build->add_to_cleanup($path);
358 #$build->add_to_manifest_skip($path);
361 sub available_drivers {
362 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
363 return if $@;
364 @drivers = DBI->available_drivers;
365 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
366 $mysql_ok = 0;
367 return
368 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
370 $mysql_ok = 1;
371 return @drivers;
374 sub make_dbi_test {
375 my $dsn = $build->notes('test_dsn') || return;
376 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
377 my $driver = $build->notes('dbd_driver');
378 my $path = File::Spec->catfile( 't', 'LocalDB',
379 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
380 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
381 : 'SeqFeature_Pg.t' );
382 my $test_db = $build->notes('test_db');
383 my $user = $build->notes('test_user');
384 my $pass = $build->notes('test_pass');
385 open my $F, '>', $path
386 or die "Could not write file '$path' for DBI test: $!\n";
387 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
388 $str .= " -user $user" if $user;
389 $str .= " -password $pass" if $pass;
390 print $F <<END;
391 system '$^X $str';
393 close $F;
394 $build->add_to_cleanup($path);
395 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
397 #$build->add_to_manifest_skip($path);
400 sub test_biodbgff {
401 eval { require DBI; }; # if not installed, this sub won't actually be called
402 return if $@;
403 @drivers = DBI->available_drivers;
404 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
405 return "MySQL, Pg nor Oracle DBI drivers are installed";
407 return;
410 sub prompt_for_biodb {
411 my $accept = shift;
412 my $proceed = $accept ? 0 : $build->y_n(
413 "Do you want to run the Bio::DB::GFF or "
414 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
418 if ($proceed) {
419 my @driver_choices;
420 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
421 if ( grep {/$poss/i} @drivers ) {
422 my $choice = $poss;
423 $choice =~ s/^(.)/[$1]/;
424 push( @driver_choices, $choice );
428 my $driver;
429 if ( @driver_choices > 1 ) {
430 my ($default) = $driver_choices[0] =~ /\[(.)/;
431 $driver = $build->prompt(
432 "Which database driver should be used? "
433 . join( " ", @driver_choices ),
434 $default
436 } else {
437 ($driver) = $driver_choices[0] =~ /\[(.)/;
439 if ( $driver =~ /^[mM]/ ) {
440 $driver = 'mysql';
441 } elsif ( $driver =~ /^[pP]/ ) {
442 $driver = 'Pg';
443 } elsif ( $driver =~ /^[oO]/ ) {
444 $driver = 'Oracle';
445 } elsif ( $driver =~ /^[sS]/ ) {
446 $driver = 'SQLite';
449 my $test_db = $build->prompt(
450 "Which database should I use for testing the $driver driver?\n"
451 . "This database should already be present but doesn't have to "
452 . "be preloaded for any schema",
453 'test'
455 my $test_host = $build->prompt(
456 "On which host is database '$test_db' running (hostname, ip address or host:port)",
457 'localhost'
459 my $test_user = $build->prompt(
460 "User name for connecting to database '$test_db'?", 'undef' );
461 my $test_pass = $build->prompt(
462 "Password for connecting to database '$test_db'?", 'undef' );
464 my $use_host = 1;
465 if ( $test_host eq 'undef' || $test_host eq 'localhost' ) {
466 $use_host = 0;
469 my $test_dsn;
470 if ( $driver eq 'Pg' || $driver eq 'SQLite' ) {
471 $test_dsn = "dbi:$driver:dbname=$test_db";
472 $mysql_ok = 0;
473 } else {
474 $test_dsn = "dbi:$driver:database=$test_db";
475 $mysql_ok = 0;
477 if ($use_host) {
478 $test_dsn .= ";host=$test_host";
481 $build->notes( dbd_driver => $driver );
482 $build->notes( test_db => $test_db );
483 $build->notes( test_host => $test_host );
484 $build->notes(
485 test_user => $test_user eq 'undef' ? undef : $test_user );
486 $build->notes(
487 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
488 $build->notes( test_dsn => $test_dsn );
490 $build->log_info(
491 " - will run tests with database driver '$driver' and these settings:\n",
492 " Database $test_db\n",
493 " Host $test_host\n",
494 " DSN $test_dsn\n",
495 " User $test_user\n",
496 " Password $test_pass\n"
498 $build->log_info( " - will not run the BioDBSeqFeature live "
499 . "database tests (requires MySQL or Pg driver)\n" )
500 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
501 } else {
502 $build->log_info(
503 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
507 $build->log_info("\n");
508 return $proceed;