Clarify warnings when defaulting the value of end()
[bioperl-live.git] / Build.PL
blobebc6d43304ede182c901df52e8365f2b612933ef
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 # http://bugzilla.open-bio.org/show_bug.cgi?id=2975
26 eval {
27 require XML::SAX;
31 unless ($@) {
32 if (grep {$_->{Name} =~ 'XML::SAX::RTF'} @{XML::SAX->parsers()}) {
33 warn <<WARN;
34 ############################# WARNING #############################
36 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
37 XML::SAX parser. If used as the primary parser, modules requiring
38 XML::SAX will NOT work. Please install another XML::SAX-compliant
39 module and modify your local ParserDetails.ini file per XML::SAX docs
40 to remove references to XML::SAX::RTF.
42 ############################# WARNING #############################
43 WARN
44 sleep 3;
50 our @drivers;
52 my $mysql_ok = 0;
54 # Set up the Bio::Root::Build object
55 my $build = Bio::Root::Build->new(
56 module_name => 'Bio',
57 dist_name => 'BioPerl',
58 dist_version_from => 'Bio/Root/Version.pm',
59 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
60 dist_abstract => 'Bioinformatics Toolkit',
61 license => 'perl',
62 no_index => {'dir' => [qw(examples/root/lib)]},
63 requires => {
64 'perl' => '5.6.1',
65 'IO::String' => 0,
66 'DB_File' => 0,
67 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
68 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
69 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
71 build_requires => {
72 'Test::More' => 0,
73 'Module::Build' => 0.2805,
74 'Test::Harness' => 2.62,
75 'CPAN' => 1.81
77 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
78 'Ace' => '0/access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace',
79 'Algorithm::Munkres' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
80 'Array::Compare' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
81 # this won't actually install due to circular dep, but we have no way of doing a post-install
82 # the [circular dependency!] specifies it is only installed on explicit request for this specific module,
83 # not when simply choosing to install 'all' modules
84 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]',
85 'Clone' => '0/cloning objects/Bio::Tools::Primer3',
86 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
87 'Graph' => '0/Phylogenetic Networks, ontology engine implementation, contig analysis/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,Bio::Assembly::Tools::ContigSpectrum',
88 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
89 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
90 'HTML::HeadParser' => '3/parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder',
91 'HTTP::Request::Common' => '0/GenBank+GenPept sequence retrieval, remote http Blast jobs/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*',
92 'List::MoreUtils' => '0/Back- or reverse-translation of sequences/Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate',
93 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent',
94 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
95 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
96 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
97 'SOAP::Lite' => '0/Bibliographic queries/Bio::DB::Biblio::soap',
98 'Sort::Naturally' => '0/sort lexically, but sort numeral parts numerically/Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr',
99 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel',
100 'Storable' => '2.05/storing sequence objects in local file cache/Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb',
101 'SVG' => '2.26/creating SVG images/Bio::Draw::Pictogram',
102 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
103 'Text::ParseWords' => '0/test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader',
104 'URI::Escape' => '0/dealing with web resources/Bio::FeatureIO::gff,Bio::FeatureIO::interpro,Bio::DB::Biblio::eutils,Bio::DB::EUtilParameters,Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated',
105 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
106 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
107 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
108 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
109 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
110 'XML::Simple' => '0/reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery',
111 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils',
112 'XML::Writer' => '0.4/parsing and writing xml/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,Bio::SearchIO::Writer::BSMLResultWriter',
114 get_options => {
115 accept => { },
116 network => { } # say 'perl Build.PL --network' to manually request network tests
118 auto_features => {
119 BioDBSeqFeature_BDB => {
120 description => "BDB tests for Bio::DB::SeqFeature::Store",
121 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
123 BioDBGFF => {
124 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
125 feature_requires => { 'DBI' => 0 },
126 excludes_os => ['mswin'],
127 test => \&test_biodbgff # Bio::Root::Build unique requirement that after everything else succeeds, supplied code ref must also return undef
129 BioDBSeqFeature_mysql => {
130 description => "MySQL tests for Bio::DB::SeqFeature::Store",
131 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
132 test => \&test_db_sf
134 BioDBSeqFeature_Pg => {
135 description => "Postgres tests for Bio::DB::SeqFeature::Store",
136 feature_requires => { 'DBI' => 0, 'DBD::Pg' => 0},
137 test => \&test_db_sf
139 BioDBSeqFeature_SQLite => {
140 description => "SQLite tests for Bio::DB::SeqFeature::Store",
141 feature_requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
142 test => \&test_db_sf
144 Network => {
145 description => "Enable tests that need an internet connection",
146 feature_requires => { 'LWP::UserAgent' => 0 },
147 test => \&Bio::Root::Build::test_internet
150 dynamic_config => 1,
151 create_makefile_pl => 'passthrough',
152 recursive_test_files => 1,
153 # Extra files needed for BioPerl modules
154 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
156 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
157 #script_files => [] # scripts in scripts directory are installed on-demand
160 my $accept = $build->args->{accept};
162 my $proceed = prompt_for_biodb($accept) if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
164 # Handle auto features
165 if ($proceed && $build->feature('BioDBSeqFeature_BDB')) {
166 # will return without doing anything if user chose not to run tests during
167 # prompt_for_biodb() above
168 make_bdb_test();
170 if ($proceed && ($build->feature('BioDBSeqFeature_mysql') or $build->feature('BioDBSeqFeature_Pg'))) {
171 make_dbi_test();
174 # Ask questions
175 $build->choose_scripts($accept);
176 #prompt_for_biodbgff($accept) if $build->feature('BioDBGFF');
178 if ($build->args('network')) {
179 if ($build->feature('Network')) {
180 $build->notes(network => 1);
181 $build->log_info(" - will run internet-requiring tests\n");
183 else {
184 $build->notes(network => 0);
185 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
188 else {
189 $build->prompt_for_network($accept) if $build->feature('Network');
191 # then in test script:
192 # use Bio::Root::Build;
193 # my $build = Module::Build->current;
194 # my $do_network_tests = $build->notes('network');
197 # Request that some scripts run post-installation
198 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
200 # Add extra things to MANIFEST.SKIP
201 $build->add_to_manifest_skip('bioperl.lisp');
203 # Add additional files here
204 $build->add_build_element('xml');
206 # Create the build script and exit
207 $build->create_build_script;
209 exit;
211 sub make_bdb_test {
212 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
213 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
214 unlink($path) if (-e $path);
215 open(my $F, ">", $path) || die "Can't create test file\n";
216 print $F <<END;
217 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
219 close $F;
220 $build->add_to_cleanup($path);
221 $build->add_to_manifest_skip($path);
224 sub test_db_sf {
225 eval {require DBI;}; # if not installed, this sub won't actually be called
226 @drivers = DBI->available_drivers;
227 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
228 $mysql_ok = 0;
229 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
231 $mysql_ok = 1;
232 return;
235 sub make_dbi_test {
236 my $dsn = $build->notes('test_dsn') || return;
237 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
238 my $driver = $build->notes('dbd_driver');
239 my $path = File::Spec->catfile('t', 'LocalDB',
240 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
241 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
242 'SeqFeature_Pg.t');
243 my $test_db = $build->notes('test_db');
244 my $user = $build->notes('test_user');
245 my $pass = $build->notes('test_pass');
246 open my $F,">$path";
247 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn $dsn";
248 $str .= " -user $user" if $user;
249 $str .= " -password $pass" if $pass;
250 print $F <<END;
251 system '$^X $str';
253 close $F;
254 $build->add_to_cleanup($path);
255 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
256 $build->add_to_manifest_skip($path);
259 sub test_biodbgff {
260 eval {require DBI;}; # if not installed, this sub won't actually be called
261 @drivers = DBI->available_drivers;
262 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
263 return "MySQL, Pg nor Oracle DBI drivers are installed";
265 return;
268 sub prompt_for_biodb {
269 my $accept = shift;
270 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
271 "Bio::DB::SeqFeature::Store live database tests? ".
272 "y/n", 'n');
274 if ($proceed) {
275 my @driver_choices;
276 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
277 if (grep {/$poss/i} @drivers) {
278 my $choice = $poss;
279 $choice =~ s/^(.)/[$1]/;
280 push(@driver_choices, $choice);
284 my $driver;
285 if (@driver_choices > 1) {
286 my ($default) = $driver_choices[0] =~ /\[(.)/;
287 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
289 else {
290 ($driver) = $driver_choices[0] =~ /\[(.)/;
292 if ($driver =~ /^[mM]/) {
293 $driver = 'mysql';
295 elsif ($driver =~ /^[pP]/) {
296 $driver = 'Pg';
298 elsif ($driver =~ /^[oO]/) {
299 $driver = 'Oracle';
301 elsif ($driver =~ /^[sS]/) {
302 $driver = 'SQLite';
305 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
306 "This database should already be present but doesn't have to ".
307 "be preloaded for any schema", 'test');
308 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
309 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
310 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
312 my $use_host = 1;
313 if ($test_host eq 'undef' || $test_host eq 'localhost') {
314 $use_host = 0;
317 my $test_dsn;
318 if ($driver eq 'Pg' || $driver eq 'SQLite') {
319 $test_dsn = "dbi:$driver:dbname=$test_db";
320 $mysql_ok = 0;
322 else {
323 $test_dsn = "dbi:$driver:database=$test_db";
324 $mysql_ok = 0;
326 if ($use_host) {
327 $test_dsn .= ";host=$test_host";
330 $build->notes(dbd_driver => $driver);
331 $build->notes(test_db => $test_db);
332 $build->notes(test_host => $test_host);
333 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
334 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
335 $build->notes(test_dsn => $test_dsn);
337 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
338 " Database $test_db\n",
339 " Host $test_host\n",
340 " DSN $test_dsn\n",
341 " User $test_user\n",
342 " Password $test_pass\n");
343 $build->log_info(" - will not run the BioDBSeqFeature live ".
344 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
346 else {
347 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
350 $build->log_info("\n");
351 return $proceed;