sync with trunk to r15684
[bioperl-live.git] / Build.PL
blob2d1c9f4271ed41bb42fefd9904fb7f15da966577
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 our @drivers;
18 my $mysql_ok = 0;
20 # Set up the Bio::Root::Build object
21 my $build = Bio::Root::Build->new(
22 module_name => 'Bio',
23 dist_name => 'BioPerl',
24 dist_version_from => 'Bio/Root/Version.pm',
25 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
26 dist_abstract => 'Bioinformatics Toolkit',
27 license => 'perl',
28 requires => {
29 'perl' => '5.6.1',
30 'IO::String' => 0,
31 'DB_File' => 0,
32 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
33 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
34 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
36 build_requires => {
37 'Test::More' => 0,
38 'Module::Build' => 0.2805,
39 'Test::Harness' => 2.62,
40 'CPAN' => 1.81
42 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
43 'Ace' => '0/access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace',
44 'Algorithm::Munkres' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
45 'Array::Compare' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
46 # this won't actually install due to circular dep, but we have no way of doing a post-install
47 # the [circular dependency!] specifies it is only installed on explicit request for this specific module,
48 # not when simply choosing to install 'all' modules
49 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]',
50 # we actually need 1.01 of Class::AutoClass, but unfortunately it is versioned as 1.0
51 'Clone' => '0/cloning objects/Bio::Tools::Primer3',
52 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
53 # we specifically want Graph::Directed, but that has no VERSION
54 'Graph' => '0/ontology engine implementation for the GO parser/Bio::PhyloNetwork',
55 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
56 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
57 'HTML::HeadParser' => '3/parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder',
58 '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*',
59 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent',
60 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
61 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
62 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
63 'SOAP::Lite' => '0/Bibliographic queries/Bio::DB::Biblio::soap',
64 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel,Bio::Microarray::Tools::ReseqChip',
65 'Spreadsheet::WriteExcel' => '0/writing Excel files/Bio::Microarray::Tools::ReseqChip',
66 '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',
67 'SVG' => '2.26/creating SVG images/Bio::Draw::Pictogram',
68 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
69 'Text::ParseWords' => '0/test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader',
70 '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',
71 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
72 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
73 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
74 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
75 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
76 'XML::Simple' => '0/reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery',
77 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils',
78 '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',
80 get_options => {
81 network => { } # say 'perl Build.PL --network' to manually request network tests
83 auto_features => {
84 BioDBSeqFeature_BDB => {
85 description => "BDB tests for Bio::DB::SeqFeature::Store",
86 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
88 BioDBGFF => {
89 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
90 feature_requires => { 'DBI' => 0 },
91 excludes_os => ['mswin'],
92 test => \&test_biodbgff # Bio::Root::Build unique requirement that after everything else succeeds, supplied code ref must also return undef
94 BioDBSeqFeature_mysql => {
95 description => "MySQL tests for Bio::DB::SeqFeature::Store",
96 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
97 test => \&test_db_sf
99 BioDBSeqFeature_Pg => {
100 description => "Postgres tests for Bio::DB::SeqFeature::Store",
101 feature_requires => { 'DBI' => 0, 'DBD::Pg' => 0},
102 test => \&test_db_sf
104 Network => {
105 description => "Enable tests that need an internet connection",
106 requires => { 'LWP::UserAgent' => 0 },
107 test => \&Bio::Root::Build::test_internet
110 dynamic_config => 1,
111 create_makefile_pl => 'passthrough',
112 recursive_test_files => 1,
113 # Extra files needed for BioPerl modules
114 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
116 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
117 #script_files => [] # scripts in scripts directory are installed on-demand
120 my $accept = $build->args->{accept};
122 my $proceed = prompt_for_biodb($accept) if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
124 # Handle auto features
125 if ($proceed && $build->feature('BioDBSeqFeature_BDB')) {
126 # will return without doing anything if user chose not to run tests during
127 # prompt_for_biodb() above
128 make_bdb_test();
130 if ($proceed && ($build->feature('BioDBSeqFeature_mysql') or $build->feature('BioDBSeqFeature_Pg'))) {
131 make_dbi_test();
134 # Ask questions
135 $build->choose_scripts($accept);
136 #prompt_for_biodbgff($accept) if $build->feature('BioDBGFF');
138 if ($build->args('network')) {
139 if ($build->feature('Network')) {
140 $build->notes(network => 1);
141 $build->log_info(" - will run internet-requiring tests\n");
143 else {
144 $build->notes(network => 0);
145 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
148 else {
149 $build->prompt_for_network($accept) if $build->feature('Network');
151 # then in test script:
152 # use Bio::Root::Build;
153 # my $build = Module::Build->current;
154 # my $do_network_tests = $build->notes('network');
157 # Request that some scripts run post-installation
158 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
160 # Add extra things to MANIFEST.SKIP
161 $build->add_to_manifest_skip('bioperl.lisp');
163 # Add additional files here
164 $build->add_build_element('xml');
166 # Create the build script and exit
167 $build->create_build_script;
169 exit;
171 sub make_bdb_test {
172 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
173 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
174 unlink($path) if (-e $path);
175 open(my $F, ">", $path) || die "Can't create test file\n";
176 print $F <<END;
177 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
179 close $F;
180 $build->add_to_cleanup($path);
181 $build->add_to_manifest_skip($path);
184 sub test_db_sf {
185 eval {require DBI;}; # if not installed, this sub won't actually be called
186 @drivers = DBI->available_drivers;
187 unless (grep {/mysql|Pg/i} @drivers) {
188 $mysql_ok = 0;
189 return "Only MySQL and Postgres DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
191 $mysql_ok = 1;
192 return;
195 sub make_dbi_test {
196 my $dsn = $build->notes('test_dsn') || return;
197 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
198 my $driver = $build->notes('dbd_driver');
199 my $path = File::Spec->catfile('t', 'LocalDB', ($driver eq 'mysql')
200 ? 'SeqFeature_mysql.t'
201 : 'SeqFeature_Pg.t');
202 my $test_db = $build->notes('test_db');
203 my $user = $build->notes('test_user');
204 my $pass = $build->notes('test_pass');
205 open my $F,">$path";
206 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn $dsn";
207 $str .= " -user $user" if $user;
208 $str .= " -password $pass" if $pass;
209 print $F <<END;
210 system '$^X $str';
212 close $F;
213 $build->add_to_cleanup($path);
214 $build->add_to_manifest_skip($path);
217 sub test_biodbgff {
218 eval {require DBI;}; # if not installed, this sub won't actually be called
219 @drivers = DBI->available_drivers;
220 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
221 return "MySQL, Pg nor Oracle DBI drivers are installed";
223 return;
226 sub prompt_for_biodb {
227 my $accept = shift;
228 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
229 "Bio::DB::SeqFeature::Store live database tests? ".
230 "y/n", 'n');
232 if ($proceed) {
233 my @driver_choices;
234 foreach my $poss ('mysql', 'Pg', 'Oracle') {
235 if (grep {/$poss/i} @drivers) {
236 my $choice = $poss;
237 $choice =~ s/^(.)/[$1]/;
238 push(@driver_choices, $choice);
242 my $driver;
243 if (@driver_choices > 1) {
244 my ($default) = $driver_choices[0] =~ /\[(.)/;
245 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
247 else {
248 ($driver) = $driver_choices[0] =~ /\[(.)/;
250 if ($driver =~ /^[mM]/) {
251 $driver = 'mysql';
253 elsif ($driver =~ /^[pP]/) {
254 $driver = 'Pg';
256 elsif ($driver =~ /^[oO]/) {
257 $driver = 'Oracle';
260 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
261 "This database should already be present but doesn't have to ".
262 "be preloaded for any schema", 'test');
263 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
264 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
265 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
267 my $use_host = 1;
268 if ($test_host eq 'undef' || $test_host eq 'localhost') {
269 $use_host = 0;
272 my $test_dsn;
273 if ($driver eq 'Pg') {
274 $test_dsn = "dbi:$driver:dbname=$test_db";
275 $mysql_ok = 0;
277 else {
278 $test_dsn = "dbi:$driver:database=$test_db";
279 $mysql_ok = 0;
281 if ($use_host) {
282 $test_dsn .= ";host=$test_host";
285 $build->notes(dbd_driver => $driver);
286 $build->notes(test_db => $test_db);
287 $build->notes(test_host => $test_host);
288 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
289 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
290 $build->notes(test_dsn => $test_dsn);
292 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
293 " Database $test_db\n",
294 " Host $test_host\n",
295 " DSN $test_dsn\n",
296 " User $test_user\n",
297 " Password $test_pass\n");
298 $build->log_info(" - will not run the BioDBSeqFeature live ".
299 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
301 else {
302 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
305 $build->log_info("\n");
306 return $proceed;