t/Annotation/Annotation.t: remove test for Bio::SeqFeature::Annotated
[bioperl-live.git] / Build.PL
blob93ee6fc99c5bf054c34f3e43869b2bd37a9c66b9
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 # this won't actually install due to circular dep, but we have no way of
51 # doing a post-install the [circular dependency!] specifies it is only
52 # installed on explicit request for this specific module, not when simply
53 # choosing to install 'all' modules
55 #'Bio::ASN1::EntrezGene' => [0,
56 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
58 'Clone' => [ 0, 'Cloning objects/Bio::Root::Root,Bio::Tools::Primer3' ],
60 'Convert::Binary::C' =>
61 [ 0, 'Strider functionality/Bio::SeqIO::strider' ],
63 'DB_File' => [ 0, 'Database functionality/Bio::DB' ],
65 'Error' => [
66 0, 'OO-based exception handling (very optional)/Bio::Root::Exception'
69 'Graph' => [
70 0.50,
71 'Phylogenetic Networks, ontology engine implementation, contig analysis'
72 . '/Bio::Ontology::SimpleGOEngine::GraphAdaptor'
75 'HTML::Entities' =>
76 [ 0, 'Remote analysis POST submissions/Bio::SearchIO::blastxml' ],
78 'HTML::HeadParser' => [
80 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'
83 'HTML::TableExtract' =>
84 [ 0, 'Parsing HTML tables/Bio::DB::SeqVersion::gi' ],
86 'HTTP::Request::Common' => [
88 'GenBank+GenPept sequence retrieval, remote http Blast jobs'
89 . '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'
90 . 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'
93 'Inline::C' => [ 0.67, 'Speeding up code like Fasta Bio::DB::Fasta' ],
95 'IO::Scalar' => [
96 0, 'Deal with non-seekable filehandles/Bio::Tools::GuessSeqFormat'
99 'List::MoreUtils' => [
101 'Back- or reverse-translation of sequences/'
102 . 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'
105 'LWP::UserAgent' => [
107 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'
110 'Set::Scalar' => [ 0, 'Proper operation/Bio::Tree::Compatible' ],
112 'Spreadsheet::ParseExcel' =>
113 [ 0, 'Parsing Excel files/Bio::SeqIO::excel' ],
115 'Storable' => [
116 2.05,
117 'Storing sequence objects in local file cache/'
118 . 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'
119 . 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb,Bio::Root::Root'
122 'SVG::Graph' => [ 0.01, 'Creating SVG images/Bio::TreeIO::svggraph' ],
124 'Text::ParseWords' =>
125 [ 0, 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader' ],
127 'XML::DOM' => [ 0, 'Parsing XML/Bio::SeqIO::bsml,Bio::SeqIO::interpro' ],
129 'XML::DOM::XPath' => [ 0, 'Parsing XML/Bio::SeqIO::interpro' ],
131 'XML::LibXML' =>
132 [ 0, 'Parsing XML/Bio::SeqIO::seqxml,Bio::TreeIO::phyloxml' ],
134 'XML::Parser' => [ 0, 'Parsing XML/Bio::OntologyIO::InterProParser' ],
136 'XML::Parser::PerlSAX' => [
138 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
139 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'
142 'XML::SAX' => [
143 0.15,
144 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'
147 'XML::SAX::Writer' => [ 0, 'Writing XML/Bio::SeqIO::tigrxml' ],
149 'XML::Twig' => [
151 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez'
154 'XML::Writer' => [
155 0.4,
156 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'
157 . 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'
158 . 'Bio::SearchIO::Writer::BSMLResultWriter'
161 'YAML' => [ 0, 'GenBank->GFF3/bp_genbank2gff3.pl' ],
164 my $mysql_ok = 0;
166 my @drivers = available_drivers();
168 # Set up the Bio::Root::Build object
169 my $build = Bio::Root::Build->new(
170 module_name => 'Bio',
171 dist_name => 'BioPerl',
172 dist_version => $Bio::Root::Version::VERSION,
173 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
174 dist_abstract => 'Bioinformatics Toolkit',
175 license => 'perl',
176 requires => {
177 'perl' => '5.6.1',
178 'IO::String' => 0, # why is this required?
179 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
180 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
181 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
184 configure_requires => {
185 'Module::Build' => 0.42,
188 build_requires => {
189 'Module::Build' => 0.42,
190 'CPAN' => 1.81,
191 'Test::Harness' => 2.62,
192 'Test::Most' => 0,
193 'URI::Escape' => 0
196 recommends => {
197 # reverted to a simple Module::Build-compatible hash, but we keep
198 # additional data in the %recommends hash above. May be converted to
199 # something simpler if there aren't complaints down the line.
200 map { $_ => $recommends{$_}[0] } sort keys %recommends
203 get_options => {
204 accept => {},
205 network => {} # say 'perl Build.PL --network' to manually request network tests
208 auto_features => {
209 'EntrezGene' => {
210 description => "Presence of Bio::ASN1::EntrezGene",
211 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
214 'DB_File Tests' => {
215 description => "BDB tests for Bio::DB::SeqFeature::Store",
216 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
219 'Bio::DB::GFF Tests' => {
220 description =>
221 "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
222 requires => { 'DBI' => 0 },
225 'MySQL Tests' => {
226 description =>
227 "MySQL-related tests for Bio::DB::SeqFeature::Store",
228 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
231 'Pg Tests' => {
232 description =>
233 "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
234 requires => { 'DBI' => 0, 'DBD::Pg' => 0 },
237 'SQLite Tests' => {
238 description =>
239 "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 recursive_test_files => 1,
251 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
252 #script_files => [] # scripts in scripts directory are installed on-demand
255 my $accept = $build->args('accept');
257 my $proceed = prompt_for_biodb($accept)
258 if $build->feature('Bio::DB::GFF')
259 || $build->feature('MySQL Tests')
260 || $build->feature('Pg Tests')
261 || $build->feature('SQLite Tests');
263 # Handle auto features
264 if ( $proceed && $build->feature('DB_File Tests') ) {
266 # will return without doing anything if user chose not to run tests during
267 make_bdb_test();
269 if ($proceed
270 && ( $build->feature('MySQL Tests')
271 || $build->feature('Pg Tests')
272 || $build->feature('SQLite Tests') )
274 make_dbi_test();
277 # Ask questions
278 $build->choose_scripts($accept);
280 if ( $build->args('network') ) {
281 if ( $build->feature('Network Tests') ) {
282 $build->notes( network => 1 );
283 $build->log_info(" - will run internet-requiring tests\n");
284 } else {
285 $build->notes( network => 0 );
286 $build->log_info(
287 " - Missing LWP::UserAgent, can't run network tests\n");
289 } else {
290 $build->prompt_for_network($accept) if $build->feature('Network Tests');
293 # Add additional files here
294 $build->add_build_element('xml');
296 if ( ! -e 'MANIFEST' ) {
297 $build->ACTION_manifest();
300 # Create the build script and exit
301 $build->create_build_script();
303 exit;
305 ########################## Helper subs ##########################
307 sub make_bdb_test {
308 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
309 my $path = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature_BDB.t' );
310 unlink($path) if ( -e $path );
311 open my $F, '>', $path or die "Could not write test file '$path': $!\n";
312 print $F <<END;
313 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
315 close $F;
316 $build->add_to_cleanup($path);
318 #$build->add_to_manifest_skip($path);
321 sub available_drivers {
322 eval { require DBI; 1; }; # if not installed, this sub won't actually be called
323 return if $@;
324 @drivers = DBI->available_drivers;
325 unless ( grep {/mysql|Pg|SQLite/i} @drivers ) {
326 $mysql_ok = 0;
327 return
328 "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
330 $mysql_ok = 1;
331 return @drivers;
334 sub make_dbi_test {
335 my $dsn = $build->notes('test_dsn') || return;
336 my $path0 = File::Spec->catfile( 't', 'LocalDB', 'SeqFeature.t' );
337 my $driver = $build->notes('dbd_driver');
338 my $path = File::Spec->catfile( 't', 'LocalDB',
339 ( $driver eq 'mysql' ) ? 'SeqFeature_mysql.t'
340 : ( $driver eq 'SQLite' ) ? 'SeqFeature_SQLite.t'
341 : 'SeqFeature_Pg.t' );
342 my $test_db = $build->notes('test_db');
343 my $user = $build->notes('test_user');
344 my $pass = $build->notes('test_pass');
345 open my $F, '>', $path
346 or die "Could not write file '$path' for DBI test: $!\n";
347 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
348 $str .= " -user $user" if $user;
349 $str .= " -password $pass" if $pass;
350 print $F <<END;
351 system '$^X $str';
353 close $F;
354 $build->add_to_cleanup($path);
355 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
357 #$build->add_to_manifest_skip($path);
360 sub test_biodbgff {
361 eval { require DBI; }; # if not installed, this sub won't actually be called
362 return if $@;
363 @drivers = DBI->available_drivers;
364 unless ( grep {/mysql|Pg|Oracle/i} @drivers ) {
365 return "MySQL, Pg nor Oracle DBI drivers are installed";
367 return;
370 sub prompt_for_biodb {
371 my $accept = shift;
372 my $proceed = $accept ? 0 : $build->y_n(
373 "Do you want to run the Bio::DB::GFF or "
374 . "Bio::DB::SeqFeature::Store live database tests? " . "y/n",
378 if ($proceed) {
379 my @driver_choices;
380 foreach my $poss ( 'SQLite', 'mysql', 'Pg', 'Oracle' ) {
381 if ( grep {/$poss/i} @drivers ) {
382 my $choice = $poss;
383 $choice =~ s/^(.)/[$1]/;
384 push( @driver_choices, $choice );
388 my $driver;
389 if ( @driver_choices > 1 ) {
390 my ($default) = $driver_choices[0] =~ /\[(.)/;
391 $driver = $build->prompt(
392 "Which database driver should be used? "
393 . join( " ", @driver_choices ),
394 $default
396 } else {
397 ($driver) = $driver_choices[0] =~ /\[(.)/;
399 if ( $driver =~ /^[mM]/ ) {
400 $driver = 'mysql';
401 } elsif ( $driver =~ /^[pP]/ ) {
402 $driver = 'Pg';
403 } elsif ( $driver =~ /^[oO]/ ) {
404 $driver = 'Oracle';
405 } elsif ( $driver =~ /^[sS]/ ) {
406 $driver = 'SQLite';
409 my $test_db = $build->prompt(
410 "Which database should I use for testing the $driver driver?\n"
411 . "This database should already be present but doesn't have to "
412 . "be preloaded for any schema",
413 'test'
415 my $test_host = $build->prompt(
416 "On which host is database '$test_db' running (hostname, ip address or host:port)",
417 'localhost'
419 my $test_user = $build->prompt(
420 "User name for connecting to database '$test_db'?", 'undef' );
421 my $test_pass = $build->prompt(
422 "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;
433 } else {
434 $test_dsn = "dbi:$driver:database=$test_db";
435 $mysql_ok = 0;
437 if ($use_host) {
438 $test_dsn .= ";host=$test_host";
441 $build->notes( dbd_driver => $driver );
442 $build->notes( test_db => $test_db );
443 $build->notes( test_host => $test_host );
444 $build->notes(
445 test_user => $test_user eq 'undef' ? undef : $test_user );
446 $build->notes(
447 test_pass => $test_pass eq 'undef' ? undef : $test_pass );
448 $build->notes( test_dsn => $test_dsn );
450 $build->log_info(
451 " - will run tests with database driver '$driver' and these settings:\n",
452 " Database $test_db\n",
453 " Host $test_host\n",
454 " DSN $test_dsn\n",
455 " User $test_user\n",
456 " Password $test_pass\n"
458 $build->log_info( " - will not run the BioDBSeqFeature live "
459 . "database tests (requires MySQL or Pg driver)\n" )
460 unless ( $driver eq 'mysql' or $driver eq 'Pg' );
461 } else {
462 $build->log_info(
463 " - will not run the BioDBGFF or BioDBSeqFeature live database tests\n"
467 $build->log_info("\n");
468 return $proceed;