comment out overzealous error checking, which caused some EMBL files to not parse...
[bioperl-live.git] / Build.PL
blob6533b512bf8d164db7e75f86437be1403142a408
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
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 'YAML' => '0/GenBank->GFF3/bp_genbank2gff3.pl',
82 # this won't actually install due to circular dep, but we have no way of doing a post-install
83 # the [circular dependency!] specifies it is only installed on explicit request for this specific module,
84 # not when simply choosing to install 'all' modules
85 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]',
86 'Clone' => '0/cloning objects/Bio::Tools::Primer3',
87 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
88 'Error' => '0/OO-based exception handling (very optional)/Bio::Root::Exception',
89 'Graph' => '0/Phylogenetic Networks, ontology engine implementation, contig analysis/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,Bio::Assembly::Tools::ContigSpectrum',
90 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
91 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
92 'HTML::HeadParser' => '3/parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder',
93 '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*',
94 'List::MoreUtils' => '0/Back- or reverse-translation of sequences/Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate',
95 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent',
96 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
97 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
98 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
99 'SOAP::Lite' => '0/Bibliographic queries/Bio::DB::Biblio::soap',
100 'Sort::Naturally' => '0/sort lexically, but sort numeral parts numerically/Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr',
101 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel',
102 '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',
103 'SVG' => '2.26/creating SVG images/Bio::Draw::Pictogram',
104 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
105 'Text::ParseWords' => '0/test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader',
106 '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',
107 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
108 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
109 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
110 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
111 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
112 'XML::Simple' => '0/reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery',
113 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils',
114 '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',
116 get_options => {
117 accept => { },
118 network => { } # say 'perl Build.PL --network' to manually request network tests
120 auto_features => {
121 BioDBSeqFeature_BDB => {
122 description => "BDB tests for Bio::DB::SeqFeature::Store",
123 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
125 BioDBGFF => {
126 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
127 feature_requires => { 'DBI' => 0 },
128 excludes_os => ['mswin'],
129 test => \&test_biodbgff # Bio::Root::Build unique requirement that after everything else succeeds, supplied code ref must also return undef
131 BioDBSeqFeature_mysql => {
132 description => "MySQL tests for Bio::DB::SeqFeature::Store",
133 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
134 test => \&test_db_sf
136 BioDBSeqFeature_Pg => {
137 description => "Postgres tests for Bio::DB::SeqFeature::Store",
138 feature_requires => { 'DBI' => 0, 'DBD::Pg' => 0},
139 test => \&test_db_sf
141 BioDBSeqFeature_SQLite => {
142 description => "SQLite tests for Bio::DB::SeqFeature::Store",
143 feature_requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
144 test => \&test_db_sf
146 Network => {
147 description => "Enable tests that need an internet connection",
148 feature_requires => { 'LWP::UserAgent' => 0 },
149 test => \&Bio::Root::Build::test_internet
152 dynamic_config => 1,
153 create_makefile_pl => 'passthrough',
154 recursive_test_files => 1,
155 # Extra files needed for BioPerl modules
156 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
158 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
159 #script_files => [] # scripts in scripts directory are installed on-demand
162 my $accept = $build->args->{accept};
164 my $proceed = prompt_for_biodb($accept) if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
166 # Handle auto features
167 if ($proceed && $build->feature('BioDBSeqFeature_BDB')) {
168 # will return without doing anything if user chose not to run tests during
169 # prompt_for_biodb() above
170 make_bdb_test();
172 if ($proceed && ($build->feature('BioDBSeqFeature_mysql') or $build->feature('BioDBSeqFeature_Pg'))) {
173 make_dbi_test();
176 # Ask questions
177 $build->choose_scripts($accept);
178 #prompt_for_biodbgff($accept) if $build->feature('BioDBGFF');
180 if ($build->args('network')) {
181 if ($build->feature('Network')) {
182 $build->notes(network => 1);
183 $build->log_info(" - will run internet-requiring tests\n");
185 else {
186 $build->notes(network => 0);
187 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
190 else {
191 $build->prompt_for_network($accept) if $build->feature('Network');
193 # then in test script:
194 # use Bio::Root::Build;
195 # my $build = Module::Build->current;
196 # my $do_network_tests = $build->notes('network');
199 # Request that some scripts run post-installation
200 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
202 # Add extra things to MANIFEST.SKIP
203 $build->add_to_manifest_skip('bioperl.lisp');
205 # Add additional files here
206 $build->add_build_element('xml');
208 # Create the build script and exit
209 $build->create_build_script;
211 exit;
213 sub make_bdb_test {
214 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
215 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
216 unlink($path) if (-e $path);
217 open(my $F, ">", $path) || die "Can't create test file\n";
218 print $F <<END;
219 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
221 close $F;
222 $build->add_to_cleanup($path);
223 $build->add_to_manifest_skip($path);
226 sub test_db_sf {
227 eval {require DBI;}; # if not installed, this sub won't actually be called
228 @drivers = DBI->available_drivers;
229 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
230 $mysql_ok = 0;
231 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
233 $mysql_ok = 1;
234 return;
237 sub make_dbi_test {
238 my $dsn = $build->notes('test_dsn') || return;
239 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
240 my $driver = $build->notes('dbd_driver');
241 my $path = File::Spec->catfile('t', 'LocalDB',
242 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
243 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
244 'SeqFeature_Pg.t');
245 my $test_db = $build->notes('test_db');
246 my $user = $build->notes('test_user');
247 my $pass = $build->notes('test_pass');
248 open my $F,">$path";
249 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn \"$dsn\"";
250 $str .= " -user $user" if $user;
251 $str .= " -password $pass" if $pass;
252 print $F <<END;
253 system '$^X $str';
255 close $F;
256 $build->add_to_cleanup($path);
257 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
258 $build->add_to_manifest_skip($path);
261 sub test_biodbgff {
262 eval {require DBI;}; # if not installed, this sub won't actually be called
263 @drivers = DBI->available_drivers;
264 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
265 return "MySQL, Pg nor Oracle DBI drivers are installed";
267 return;
270 sub prompt_for_biodb {
271 my $accept = shift;
272 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
273 "Bio::DB::SeqFeature::Store live database tests? ".
274 "y/n", 'n');
276 if ($proceed) {
277 my @driver_choices;
278 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
279 if (grep {/$poss/i} @drivers) {
280 my $choice = $poss;
281 $choice =~ s/^(.)/[$1]/;
282 push(@driver_choices, $choice);
286 my $driver;
287 if (@driver_choices > 1) {
288 my ($default) = $driver_choices[0] =~ /\[(.)/;
289 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
291 else {
292 ($driver) = $driver_choices[0] =~ /\[(.)/;
294 if ($driver =~ /^[mM]/) {
295 $driver = 'mysql';
297 elsif ($driver =~ /^[pP]/) {
298 $driver = 'Pg';
300 elsif ($driver =~ /^[oO]/) {
301 $driver = 'Oracle';
303 elsif ($driver =~ /^[sS]/) {
304 $driver = 'SQLite';
307 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
308 "This database should already be present but doesn't have to ".
309 "be preloaded for any schema", 'test');
310 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
311 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
312 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
314 my $use_host = 1;
315 if ($test_host eq 'undef' || $test_host eq 'localhost') {
316 $use_host = 0;
319 my $test_dsn;
320 if ($driver eq 'Pg' || $driver eq 'SQLite') {
321 $test_dsn = "dbi:$driver:dbname=$test_db";
322 $mysql_ok = 0;
324 else {
325 $test_dsn = "dbi:$driver:database=$test_db";
326 $mysql_ok = 0;
328 if ($use_host) {
329 $test_dsn .= ";host=$test_host";
332 $build->notes(dbd_driver => $driver);
333 $build->notes(test_db => $test_db);
334 $build->notes(test_host => $test_host);
335 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
336 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
337 $build->notes(test_dsn => $test_dsn);
339 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
340 " Database $test_db\n",
341 " Host $test_host\n",
342 " DSN $test_dsn\n",
343 " User $test_user\n",
344 " Password $test_pass\n");
345 $build->log_info(" - will not run the BioDBSeqFeature live ".
346 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
348 else {
349 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
352 $build->log_info("\n");
353 return $proceed;