bug 2462
[bioperl-live.git] / Build.PL
blob01b2a3b281a1e68fec4dec9f274f53dba6722166
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 ModuleBuildBioperl that
7 # doesn't get installed
9 # In the future developers may need to alter the requires and recommends and
10 # possibly Network sections of ModuleBuildBioperl->new() below, but otherwise
11 # nothing else here is likely to need changing.
13 use strict;
14 use ModuleBuildBioperl;
16 our @drivers;
18 my $mysql_ok = 0;
20 # Set up the ModuleBuildBioperl object
21 my $build = ModuleBuildBioperl->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 'Scalar::Util' => 0 # not in Perl 5.6.1, arrived in core in 5.7.3
34 build_requires => {
35 'Test::More' => 0,
36 'Module::Build' => 0.2805,
37 'Test::Harness' => 2.62,
38 'CPAN' => 1.81
40 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
41 'Ace' => '0/access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace',
42 # this won't actually install due to circular dep, but we have no way of doing a post-install
43 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene',
44 # we actually need 1.01 of Class::AutoClass, but unfortunately it is versioned as 1.0
45 'Class::AutoClass' => '1/creating objects/Bio::Graph::SimpleGraph,Bio::Graph::SimpleGraph::Traversal,Bio::Graph::ProteinGraph',
46 'Clone' => '0/cloning objects/Bio::Graph::ProteinGraph,Bio::Tools::Primer3',
47 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
48 'Data::Stag::XMLWriter' => '0/writing choas xml files/Bio::SeqIO::chaosxml',
49 'GD' => '1.3/rendering Sequences and Features/Bio::Graphics::Glyph*',
50 'GD::SVG' => '0/creating SVG images/Bio::Graphics::Panel',
51 # we specifically want Graph::Directed, but that has no VERSION
52 'Graph' => '0/ontology engine implementation for the GO parser/Bio::Ontology::SimpleGOEngine::GraphAdaptor,Bio::PhyloNetwork',
53 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
54 'HTML::Parser' => '3/screen scraping www.gdb.org/Bio::DB::GDB',
55 '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*',
56 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::Tools::WebBlat,Bio::WebAgent,Bio::Graphics::Glyph::image',
57 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
58 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
59 'SOAP::Lite' => '0/XEMBL Services and Bibliographic queries/Bio::DB::XEMBLService,Bio::DB::Biblio::soap',
60 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel',
61 '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',
62 'SVG' => '2.26/SVG output/Bio::Graphics::Pictogram',
63 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
64 'Text::Shellwords' => '0/test scripts/Bio::Graphics',
65 'URI::Escape' => '0/dealing with web resources/Bio::Tools::WebBlat,Bio::FeatureIO::gff,Bio::FeatureIO::interpro,Bio::DB::Biblio::eutils,Bio::DB::EUtilities::Cookie,Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated',
66 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
67 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
68 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
69 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
70 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
71 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils,Bio::Graph::IO::psi_xml',
72 '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',
73 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
74 'Algorithm::Munkres' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
75 'Array::Compare' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
76 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
78 get_options => {
79 network => { } # say 'perl Build.PL --network' to manually request network tests
81 auto_features => {
82 BioDBSeqFeature_BDB => {
83 description => "BDB tests for Bio::DB::SeqFeature::Store",
84 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, execpt that it doesn't trigger installation
86 BioDBGFF => {
87 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
88 feature_requires => { 'DBI' => 0 },
89 excludes_os => ['mswin'],
90 test => \&test_biodbgff # ModuleBuildBioperl unique requirement that after everything else succeeds, supplied code ref must also return undef
92 BioDBSeqFeature_mysql => {
93 description => "MySQL tests for Bio::DB::SeqFeature::Store",
94 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
95 test => \&test_db_sf
97 Network => {
98 description => "Enable tests that need an internet connection",
99 requires => { 'LWP::UserAgent' => 0 },
100 test => \&ModuleBuildBioperl::test_internet
103 dynamic_config => 1,
104 create_makefile_pl => 'passthrough'
106 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
107 #script_files => [] # scripts in scripts directory are installed on-demand
110 prompt_for_biodb() if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
112 # Handle auto features
113 if ($build->feature('BioDBSeqFeature_BDB')) {
114 make_bdb_test();
116 if ($build->feature('BioDBSeqFeature_mysql') && $mysql_ok) {
117 # will return without doing anything if user chose not to run tests during
118 # prompt_for_biodb() above
119 make_dbi_test();
122 # Ask questions
123 $build->choose_scripts;
125 if ($build->args('network')) {
126 if ($build->feature('Network')) {
127 $build->notes(network => 1);
128 $build->log_info(" - will run internet-requiring tests\n");
130 else {
131 $build->notes(network => 0);
132 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
135 else {
136 prompt_for_network() if $build->feature('Network');
138 # then in test script:
139 # use Module::Build;
140 # my $build = Module::Build->current;
141 # my $do_network_tests = $build->notes('network');
144 # Request that some scripts run post-installation
145 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
147 # Add extra things to MANIFEST.SKIP
148 $build->add_to_manifest_skip('bioperl.lisp', 'Bio/Tools/WebBlat.pm');
150 # Create the build script and exit
151 $build->create_build_script;
153 exit;
155 sub make_bdb_test {
156 my $path0 = File::Spec->catfile('t', 'BioDBSeqFeature.t');
157 my $path = File::Spec->catfile('t', 'BioDBSeqFeature_BDB.t');
158 unlink($path) if (-e $path);
159 open(my $F, ">", $path) || die "Can't create test file\n";
160 print $F <<END;
161 system 'perl $path0 -adaptor berkeleydb -create 1 -temp 1';
163 close $F;
164 $build->add_to_cleanup($path);
165 $build->add_to_manifest_skip($path);
168 sub test_db_sf {
169 eval {require DBI;}; # if not installed, this sub won't actually be called
170 @drivers = DBI->available_drivers;
171 unless (grep {/mysql/i} @drivers) {
172 $mysql_ok = 0;
173 return "Only MySQL DBI driver supported for BioDBSeqFeature_mysql tests";
175 $mysql_ok = 1;
176 return;
179 sub make_dbi_test {
180 my $dsn = $build->notes('test_dsn') || return;
181 my $path0 = File::Spec->catfile('t', 'BioDBSeqFeature.t');
182 my $path = File::Spec->catfile('t', 'BioDBSeqFeature_mysql.t');
183 my $test_db = $build->notes('test_db');
184 my $user = $build->notes('test_user');
185 my $pass = $build->notes('test_pass');
186 open my $F,">$path";
187 my $str = "$path0 -adaptor DBI::mysql -create 1 -temp 1 -dsn $dsn";
188 $str .= " -user $user" if $user;
189 $str .= " -password $pass" if $pass;
190 print $F <<END;
191 system 'perl $str';
193 close $F;
194 $build->add_to_cleanup($path);
195 $build->add_to_manifest_skip($path);
198 sub test_biodbgff {
199 eval {require DBI;}; # if not installed, this sub won't actually be called
200 @drivers = DBI->available_drivers;
201 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
202 return "MySQL, Pg nor Oracle DBI drivers are installed";
204 return;
207 sub prompt_for_biodb {
208 my $proceed = $build->y_n("Do you want to run the BioDBGFF or ".
209 "BioDBSeqFeature_mysql live database tests? ".
210 "y/n", 'n');
212 if ($proceed) {
213 my @driver_choices;
214 foreach my $poss ('mysql', 'Pg', 'Oracle') {
215 if (grep {/$poss/i} @drivers) {
216 my $choice = $poss;
217 $choice =~ s/^(.)/[$1]/;
218 push(@driver_choices, $choice);
222 my $driver;
223 if (@driver_choices > 1) {
224 my ($default) = $driver_choices[0] =~ /\[(.)/;
225 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
227 else {
228 ($driver) = $driver_choices[0] =~ /\[(.)/;
230 if ($driver =~ /^[mM]/) {
231 $driver = 'mysql';
233 elsif ($driver =~ /^[pP]/) {
234 $mysql_ok = 0;
235 $driver = 'Pg';
237 elsif ($driver =~ /^[oO]/) {
238 $mysql_ok = 0;
239 $driver = 'Oracle';
242 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?", 'test');
243 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
244 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
245 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
247 my $use_host = 1;
248 if ($test_host eq 'undef' || $test_host eq 'localhost') {
249 $use_host = 0;
252 my $test_dsn;
253 if ($driver eq 'Pg') {
254 $test_dsn = "dbi:$driver:dbname=$test_db";
256 else {
257 $test_dsn = "dbi:$driver:database=$test_db";
259 if ($use_host) {
260 $test_dsn .= ";host=$test_host";
263 $build->notes(dbd_driver => $driver);
264 $build->notes(test_db => $test_db);
265 $build->notes(test_host => $test_host);
266 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
267 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
268 $build->notes(test_dsn => $test_dsn);
270 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
271 " Database $test_db\n",
272 " Host $test_host\n",
273 " DSN $test_dsn\n",
274 " User $test_user\n",
275 " Password $test_pass\n");
276 $build->log_info(" - will not run the BioDBSeqFeature_mysql live ".
277 "database tests (requires MySQL driver)\n") unless $mysql_ok;
279 else {
280 $build->log_info(" - will not run the BioDBGFF live database tests\n");
283 $build->log_info("\n");
286 sub prompt_for_network {
287 my $proceed = $build->y_n("Do you want to run tests that require connection to servers across the internet\n(likely to cause some failures)? y/n", 'n');
289 if ($proceed) {
290 $build->notes(network => 1);
291 $build->log_info(" - will run internet-requiring tests\n");
293 else {
294 $build->notes(network => 0);
295 $build->log_info(" - will not run internet-requiring tests\n");