Remove (merge didn't remove this for some reason)
[bioperl-live.git] / Build.PL
blob02895b7750fa70e7baf6c1584ffacdd27ae58e16
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.10, # 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
35 build_requires => {
36 'Test::More' => 0,
37 'Module::Build' => 0.2805,
38 'Test::Harness' => 2.62,
39 'CPAN' => 1.81
41 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
42 'Ace' => '0/access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace',
43 'Algorithm::Munkres' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
44 'Array::Compare' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
45 # this won't actually install due to circular dep, but we have no way of doing a post-install
46 # the [circular dependency!] specifies it is only installed on explicit request for this specific module,
47 # not when simply choosing to install 'all' modules
48 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]',
49 # we actually need 1.01 of Class::AutoClass, but unfortunately it is versioned as 1.0
50 'Clone' => '0/cloning objects/Bio::Tools::Primer3',
51 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
52 # we specifically want Graph::Directed, but that has no VERSION
53 'Graph' => '0/ontology engine implementation for the GO parser/Bio::PhyloNetwork',
54 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
55 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
56 'HTML::Parser' => '3/screen scraping www.gdb.org/Bio::DB::GDB',
57 '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*',
58 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent',
59 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
60 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
61 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
62 'SOAP::Lite' => '0/Bibliographic queries/Bio::DB::Biblio::soap',
63 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel,Bio::Microarray::Tools::ReseqChip',
64 'Spreadsheet::WriteExcel' => '0/writing Excel files/Bio::Microarray::Tools::ReseqChip',
65 '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',
66 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
67 'Text::ParseWords' => '0/test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader',
68 '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',
69 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
70 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
71 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
72 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
73 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
74 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils',
75 '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',
77 get_options => {
78 network => { } # say 'perl Build.PL --network' to manually request network tests
80 auto_features => {
81 BioDBSeqFeature_BDB => {
82 description => "BDB tests for Bio::DB::SeqFeature::Store",
83 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, execpt that it doesn't trigger installation
85 BioDBGFF => {
86 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
87 feature_requires => { 'DBI' => 0 },
88 excludes_os => ['mswin'],
89 test => \&test_biodbgff # Bio::Root::Build unique requirement that after everything else succeeds, supplied code ref must also return undef
91 BioDBSeqFeature_mysql => {
92 description => "MySQL tests for Bio::DB::SeqFeature::Store",
93 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
94 test => \&test_db_sf
96 BioDBSeqFeature_Pg => {
97 description => "Postgres tests for Bio::DB::SeqFeature::Store",
98 feature_requires => { 'DBI' => 0, 'DBD::Pg' => 0},
99 test => \&test_db_sf
101 Network => {
102 description => "Enable tests that need an internet connection",
103 requires => { 'LWP::UserAgent' => 0 },
104 test => \&Bio::Root::Build::test_internet
107 dynamic_config => 1,
108 create_makefile_pl => 'passthrough',
109 recursive_test_files => 1,
110 # Extra files needed for BioPerl modules
111 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
113 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
114 #script_files => [] # scripts in scripts directory are installed on-demand
117 my $accept = $build->args->{accept};
119 prompt_for_biodb($accept) if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
121 # Handle auto features
122 if ($build->feature('BioDBSeqFeature_BDB')) {
123 # will return without doing anything if user chose not to run tests during
124 # prompt_for_biodb() above
125 make_bdb_test();
127 if ($build->feature('BioDBSeqFeature_mysql') or $build->feature('BioDBSeqFeature_Pg')) {
128 make_dbi_test();
131 # Ask questions
132 $build->choose_scripts($accept);
133 #prompt_for_biodbgff($accept) if $build->feature('BioDBGFF');
135 if ($build->args('network')) {
136 if ($build->feature('Network')) {
137 $build->notes(network => 1);
138 $build->log_info(" - will run internet-requiring tests\n");
140 else {
141 $build->notes(network => 0);
142 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
145 else {
146 $build->prompt_for_network($accept) if $build->feature('Network');
148 # then in test script:
149 # use Bio::Root::Build;
150 # my $build = Module::Build->current;
151 # my $do_network_tests = $build->notes('network');
154 # Request that some scripts run post-installation
155 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
157 # Add extra things to MANIFEST.SKIP
158 $build->add_to_manifest_skip('bioperl.lisp');
160 # Add additional files here
161 $build->add_build_element('xml');
163 # Create the build script and exit
164 $build->create_build_script;
166 exit;
168 sub make_bdb_test {
169 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
170 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
171 unlink($path) if (-e $path);
172 open(my $F, ">", $path) || die "Can't create test file\n";
173 print $F <<END;
174 system 'perl $path0 -adaptor berkeleydb -create 1 -temp 1';
176 close $F;
177 $build->add_to_cleanup($path);
178 $build->add_to_manifest_skip($path);
181 sub test_db_sf {
182 eval {require DBI;}; # if not installed, this sub won't actually be called
183 @drivers = DBI->available_drivers;
184 unless (grep {/mysql|Pg/i} @drivers) {
185 $mysql_ok = 0;
186 return "Only MySQL and Postgres DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
188 $mysql_ok = 1;
189 return;
192 sub make_dbi_test {
193 my $dsn = $build->notes('test_dsn') || return;
194 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
195 my $driver = $build->notes('dbd_driver');
196 my $path = File::Spec->catfile('t', 'LocalDB', ($driver eq 'mysql')
197 ? 'SeqFeature_mysql.t'
198 : 'SeqFeature_Pg.t');
199 my $test_db = $build->notes('test_db');
200 my $user = $build->notes('test_user');
201 my $pass = $build->notes('test_pass');
202 open my $F,">$path";
203 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn $dsn";
204 $str .= " -user $user" if $user;
205 $str .= " -password $pass" if $pass;
206 print $F <<END;
207 system 'perl $str';
209 close $F;
210 $build->add_to_cleanup($path);
211 $build->add_to_manifest_skip($path);
214 sub test_biodbgff {
215 eval {require DBI;}; # if not installed, this sub won't actually be called
216 @drivers = DBI->available_drivers;
217 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
218 return "MySQL, Pg nor Oracle DBI drivers are installed";
220 return;
223 sub prompt_for_biodb {
224 my $accept = shift;
225 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
226 "Bio::DB::SeqFeature::Store live database tests? ".
227 "y/n", 'n');
229 if ($proceed) {
230 my @driver_choices;
231 foreach my $poss ('mysql', 'Pg', 'Oracle') {
232 if (grep {/$poss/i} @drivers) {
233 my $choice = $poss;
234 $choice =~ s/^(.)/[$1]/;
235 push(@driver_choices, $choice);
239 my $driver;
240 if (@driver_choices > 1) {
241 my ($default) = $driver_choices[0] =~ /\[(.)/;
242 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
244 else {
245 ($driver) = $driver_choices[0] =~ /\[(.)/;
247 if ($driver =~ /^[mM]/) {
248 $driver = 'mysql';
250 elsif ($driver =~ /^[pP]/) {
251 $driver = 'Pg';
253 elsif ($driver =~ /^[oO]/) {
254 $driver = 'Oracle';
257 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
258 "This database should already be present but doesn't have to ".
259 "be preloaded for any schema", 'test');
260 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
261 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
262 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
264 my $use_host = 1;
265 if ($test_host eq 'undef' || $test_host eq 'localhost') {
266 $use_host = 0;
269 my $test_dsn;
270 if ($driver eq 'Pg') {
271 $test_dsn = "dbi:$driver:dbname=$test_db";
272 $mysql_ok = 0;
274 else {
275 $test_dsn = "dbi:$driver:database=$test_db";
276 $mysql_ok = 0;
278 if ($use_host) {
279 $test_dsn .= ";host=$test_host";
282 $build->notes(dbd_driver => $driver);
283 $build->notes(test_db => $test_db);
284 $build->notes(test_host => $test_host);
285 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
286 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
287 $build->notes(test_dsn => $test_dsn);
289 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
290 " Database $test_db\n",
291 " Host $test_host\n",
292 " DSN $test_dsn\n",
293 " User $test_user\n",
294 " Password $test_pass\n");
295 $build->log_info(" - will not run the BioDBSeqFeature live ".
296 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
298 else {
299 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
302 $build->log_info("\n");