Revert "remove MANIFEST/MANIFEST.SKIP (only need for dist release)"
[bioperl-live.git] / Build.PL
blob50848e752b0c25ce104729c03c8ea4e648e8c9eb
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;
29 ############################# WARNING #############################
31 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
32 XML::SAX parser. If used as the primary parser, modules requiring
33 XML::SAX will NOT work. Please install another XML::SAX-compliant
34 module and modify your local ParserDetails.ini file per XML::SAX
35 docs to remove references to XML::SAX::RTF.
37 ############################# WARNING #############################
38 WARN
39 sleep 2;
45 my %recommends = (
46 'Ace' => [0,
47 'Access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace'],
49 'Algorithm::Munkres' => [0,
50 'Phylogenetic Networks/Bio::PhyloNetwork'],
52 'Array::Compare' => [0,
53 'Phylogenetic Networks/Bio::PhyloNetwork'],
55 'YAML' => [0,
56 'GenBank->GFF3/bp_genbank2gff3.pl'],
58 # this won't actually install due to circular dep, but we have no way of
59 # doing a post-install the [circular dependency!] specifies it is only
60 # installed on explicit request for this specific module, not when simply
61 # choosing to install 'all' modules
63 #'Bio::ASN1::EntrezGene' => [0,
64 # 'Parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]'],
66 'Clone' => [0,
67 'Cloning objects/Bio::Tools::Primer3'],
69 'Convert::Binary::C' => [0,
70 'Strider functionality/Bio::SeqIO::strider'],
72 'Error' => [0,
73 'OO-based exception handling (very optional)/Bio::Root::Exception'],
75 'Graph' => [0,
76 'Phylogenetic Networks, ontology engine implementation, contig analysis'.
77 '/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,'.
78 'Bio::Assembly::Tools::ContigSpectrum'],
80 'GraphViz' => [0,
81 'Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz'],
83 'HTML::Entities' => [0,
84 'Remote analysis POST submissions/Bio::SearchIO::blastxml'],
86 'HTML::HeadParser' => [3,
87 'Parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder'],
89 'HTTP::Request::Common' => [0,
90 'GenBank+GenPept sequence retrieval, remote http Blast jobs'.
91 '/Bio::DB::*,Bio::Tools::Run::RemoteBlast,'.
92 'Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*'],
94 'List::MoreUtils' => [0,
95 'Back- or reverse-translation of sequences/'.
96 'Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate'],
98 'LWP::UserAgent' => [0,
99 'Remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent'],
101 'Math::Random' => [0,
102 'Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory'],
104 'PostScript::TextBlock' => [0,
105 'EPS output/Bio::Tree::Draw::Cladogram'],
107 'Set::Scalar' => [0,
108 'Proper operation/Bio::Tree::Compatible'],
110 'SOAP::Lite' => [0,
111 'Bibliographic queries/Bio::DB::Biblio::soap'],
113 'Sort::Naturally' => [0,
114 'Sort lexically, but sort numeral parts numerically/'.
115 'Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr'],
117 'Spreadsheet::ParseExcel' => [0,
118 'Parsing Excel files/Bio::SeqIO::excel'],
120 'Storable' => [2.05,
121 'Storing sequence objects in local file cache/'.
122 'Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,'.
123 'Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb'],
125 'SVG' => [2.26,
126 'Creating SVG images/Bio::Draw::Pictogram'],
128 'SVG::Graph' => [0.01,
129 'Creating SVG images/Bio::TreeIO::svggraph'],
131 'Text::ParseWords' => [0,
132 'Test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader'],
134 'URI::Escape' => [0,
135 'Dealing with web resources/Bio::FeatureIO::gff,Bio::FeatureIO::interpro,'.
136 'Bio::DB::Biblio::eutils,Bio::DB::EUtilParameters,'.
137 'Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated'],
139 'XML::DOM::XPath' => [0.13,
140 'parsing interpro features/Bio::FeatureIO::interpro'],
142 'XML::Parser' => [0,
143 'parsing xml/Bio::Biblio::IO::medlinexml'],
145 'XML::Parser::PerlSAX' => [0,
146 'Parsing XML/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,',
147 'Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp'],
149 'XML::SAX' => [0.15,
150 'Parsing XML/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax'],
152 'XML::SAX::Writer' => [0,
153 'Writing XML/Bio::SeqIO::tigrxml'],
155 'XML::Simple' => [0,
156 'Reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery'],
158 'XML::Twig' => [0,
159 'Parsing XML/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,'.
160 'Bio::DB::Biblio::eutils'],
162 'XML::Writer' => [0.4,
163 'Parsing and writing XML/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,'.
164 'Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,'.
165 'Bio::SearchIO::Writer::BSMLResultWriter'],
168 my $mysql_ok = 0;
170 my @drivers = available_drivers();
172 # Set up the Bio::Root::Build object
173 my $build = Bio::Root::Build->new(
174 module_name => 'Bio',
175 dist_name => 'BioPerl',
176 dist_version_from => 'Bio/Root/Version.pm',
177 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
178 dist_abstract => 'Bioinformatics Toolkit',
179 license => 'perl',
180 no_index => {'dir' => [qw(examples/root/lib)]},
181 requires => {
182 'perl' => '5.6.1',
183 'IO::String' => 0,
184 'DB_File' => 0,
185 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
186 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
187 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
190 build_requires => {
191 'Test::More' => 0,
192 'Module::Build' => 0.2805,
193 'Test::Harness' => 2.62,
194 'CPAN' => 1.81
197 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
198 map {$_ => $recommends{$_}[0]} sort keys %recommends
201 get_options => {
202 accept => { },
203 network => { } # say 'perl Build.PL --network' to manually request network tests
206 auto_features => {
207 'EntrezGene' => {
208 description => "Presence of Bio::ASN1::EntrezGene",
209 requires => { 'Bio::ASN1::EntrezGene' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
212 'DB_File Tests' => {
213 description => "BDB tests for Bio::DB::SeqFeature::Store",
214 requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
217 'Bio::DB::GFF Tests' => {
218 description => "Bio::DB::GFF database tests (will need to answer questions before really enabling)",
219 requires => { 'DBI' => 0 },
222 'MySQL Tests' => {
223 description => "MySQL-related tests for Bio::DB::SeqFeature::Store",
224 requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
227 'Pg Tests' => {
228 description => "PostgreSQL-related tests for Bio::DB::SeqFeature::Store",
229 requires => { 'DBI' => 0, 'DBD::Pg' => 0},
232 'SQLite Tests' => {
233 description => "SQLite-related tests for Bio::DB::SeqFeature::Store",
234 requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
237 'Network Tests' => {
238 description => "Enable tests that need an internet connection",
239 requires => { 'LWP::UserAgent' => 0 },
242 dynamic_config => 1,
243 create_makefile_pl => 'passthrough',
244 recursive_test_files => 1,
246 # Extra files needed for BioPerl modules
247 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
249 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
250 #script_files => [] # scripts in scripts directory are installed on-demand
253 my $accept = $build->args('accept');
255 my $proceed = prompt_for_biodb($accept) if $build->feature('Bio::DB::GFF')
256 || $build->feature('MySQL Tests') || $build->feature('MySQL Tests');
258 # Handle auto features
259 if ($proceed && $build->feature('DB_File Tests')) {
260 # will return without doing anything if user chose not to run tests during
261 make_bdb_test();
263 if ($proceed && ($build->feature('MySQL Tests') ||
264 $build->feature('Pg Tests') ||
265 $build->feature('SQLite Tests'))) {
266 make_dbi_test();
269 # Ask questions
270 $build->choose_scripts($accept);
272 if ($build->args('network')) {
273 if ($build->feature('Network Tests')) {
274 $build->notes(network => 1);
275 $build->log_info(" - will run internet-requiring tests\n");
277 else {
278 $build->notes(network => 0);
279 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
282 else {
283 $build->prompt_for_network($accept) if $build->feature('Network Tests');
286 # Request that some scripts run post-installation
287 #$build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
289 # Add extra things to MANIFEST.SKIP
290 #$build->add_to_manifest_skip('bioperl.lisp');
292 # Add additional files here
293 $build->add_build_element('xml');
295 # Create the build script and exit
296 $build->create_build_script;
298 exit;
300 ########################## Helper subs ##########################
302 sub make_bdb_test {
303 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
304 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
305 unlink($path) if (-e $path);
306 open(my $F, ">", $path) || die "Can't create test file\n";
307 print $F <<END;
308 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
310 close $F;
311 $build->add_to_cleanup($path);
312 #$build->add_to_manifest_skip($path);
315 sub available_drivers {
316 eval {require DBI; 1;}; # if not installed, this sub won't actually be called
317 @drivers = DBI->available_drivers;
318 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
319 $mysql_ok = 0;
320 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
322 $mysql_ok = 1;
323 return @drivers;
326 sub make_dbi_test {
327 my $dsn = $build->notes('test_dsn') || return;
328 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
329 my $driver = $build->notes('dbd_driver');
330 my $path = File::Spec->catfile('t', 'LocalDB',
331 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
332 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
333 'SeqFeature_Pg.t');
334 my $test_db = $build->notes('test_db');
335 my $user = $build->notes('test_user');
336 my $pass = $build->notes('test_pass');
337 open my $F,">$path";
338 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
339 $str .= " -user $user" if $user;
340 $str .= " -password $pass" if $pass;
341 print $F <<END;
342 system '$^X $str';
344 close $F;
345 $build->add_to_cleanup($path);
346 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
347 #$build->add_to_manifest_skip($path);
350 sub test_biodbgff {
351 eval {require DBI;}; # if not installed, this sub won't actually be called
352 @drivers = DBI->available_drivers;
353 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
354 return "MySQL, Pg nor Oracle DBI drivers are installed";
356 return;
359 sub prompt_for_biodb {
360 my $accept = shift;
361 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
362 "Bio::DB::SeqFeature::Store live database tests? ".
363 "y/n", 'n');
365 if ($proceed) {
366 my @driver_choices;
367 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
368 if (grep {/$poss/i} @drivers) {
369 my $choice = $poss;
370 $choice =~ s/^(.)/[$1]/;
371 push(@driver_choices, $choice);
375 my $driver;
376 if (@driver_choices > 1) {
377 my ($default) = $driver_choices[0] =~ /\[(.)/;
378 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
380 else {
381 ($driver) = $driver_choices[0] =~ /\[(.)/;
383 if ($driver =~ /^[mM]/) {
384 $driver = 'mysql';
386 elsif ($driver =~ /^[pP]/) {
387 $driver = 'Pg';
389 elsif ($driver =~ /^[oO]/) {
390 $driver = 'Oracle';
392 elsif ($driver =~ /^[sS]/) {
393 $driver = 'SQLite';
396 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
397 "This database should already be present but doesn't have to ".
398 "be preloaded for any schema", 'test');
399 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
400 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
401 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
403 my $use_host = 1;
404 if ($test_host eq 'undef' || $test_host eq 'localhost') {
405 $use_host = 0;
408 my $test_dsn;
409 if ($driver eq 'Pg' || $driver eq 'SQLite') {
410 $test_dsn = "dbi:$driver:dbname=$test_db";
411 $mysql_ok = 0;
413 else {
414 $test_dsn = "dbi:$driver:database=$test_db";
415 $mysql_ok = 0;
417 if ($use_host) {
418 $test_dsn .= ";host=$test_host";
421 $build->notes(dbd_driver => $driver);
422 $build->notes(test_db => $test_db);
423 $build->notes(test_host => $test_host);
424 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
425 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
426 $build->notes(test_dsn => $test_dsn);
428 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
429 " Database $test_db\n",
430 " Host $test_host\n",
431 " DSN $test_dsn\n",
432 " User $test_user\n",
433 " Password $test_pass\n");
434 $build->log_info(" - will not run the BioDBSeqFeature live ".
435 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
437 else {
438 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
441 $build->log_info("\n");
442 return $proceed;