Adjust dependencies - most of them pull in bugfixes
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.79;
2 use strict;
3 use warnings;
4 use POSIX ();
5
6 use 5.006001; # delete this line if you want to send patches for earlier.
7
8 name     'DBIx-Class';
9 perl_version '5.006001';
10 all_from 'lib/DBIx/Class.pm';
11
12 # configure_requires so _check_sqlite() below can run
13 # remove once test deprecated
14 configure_requires 'DBD::SQLite';
15
16 requires 'DBD::SQLite'              => 1.25;
17 requires 'Data::Page'               => 2.00;
18 requires 'SQL::Abstract'            => 1.55;
19 requires 'SQL::Abstract::Limit'     => 0.13;
20 requires 'Class::C3::Componentised' => 1.0005;
21 requires 'Carp::Clan'               => 6.0;
22 requires 'DBI'                      => 1.605;
23 requires 'Module::Find'             => 0.06;
24 requires 'Class::Inspector'         => 1.24;
25 requires 'Class::Accessor::Grouped' => 0.08003;
26 requires 'JSON::Any'                => 1.18;
27 requires 'Scope::Guard'             => 0.03;
28 requires 'Path::Class'              => 0.16;
29 requires 'Sub::Name'                => 0.04;
30 requires 'MRO::Compat'              => 0.09;
31
32 # Core
33 requires 'List::Util'               => 0;
34 requires 'Scalar::Util'             => 0;
35 requires 'Storable'                 => 0;
36
37 # Perl 5.8.0 doesn't have utf8::is_utf8()
38 requires 'Encode'                   => 0 if ($] <= 5.008000);
39
40 test_requires 'Test::More'          => 0.82;
41 test_requires 'Test::Builder'       => 0.33;
42 test_requires 'Test::Warn'          => 0.11;
43 test_requires 'Test::Exception'     => 0;
44 test_requires 'Test::Deep'          => 0;
45
46 recommends 'SQL::Translator'        => 0.09004;
47
48 install_script (qw|
49     script/dbicadmin
50 |);
51
52 tests_recursive (qw|
53     t
54 |);
55
56 # re-build README and require extra modules for testing if we're in a checkout
57
58 my %force_requires_if_author = (
59   'Test::Pod::Coverage'       => 1.04,
60   'SQL::Translator'           => 0.09004,
61
62   # CDBI-compat related
63   'DBIx::ContextualFetch'     => 0,
64   'Class::DBI::Plugin::DeepAbstractSearch' => 0,
65   'Class::Trigger'            => 0,
66   'Time::Piece::MySQL'        => 0,
67   'Clone'                     => 0,
68   'Date::Simple'              => 0,
69
70   # t/52cycle.t
71   'Test::Memory::Cycle'       => 0,
72
73   # t/60core.t
74   'DateTime::Format::MySQL'   => 0,
75
76   # t/72pg.t
77   $ENV{DBICTEST_PG_DSN}
78     ? ('Sys::SigAction'=> 0)
79     : ()
80   ,
81
82   # t/93storage_replication.t
83   'Moose',                        => 0.77,
84   'MooseX::AttributeHelpers'      => 0.12,
85   'MooseX::Types',                => 0.10,
86   'namespace::clean'              => 0.11,
87   'Hash::Merge',                  => 0.11,
88
89   # t/96_is_deteministic_value.t
90   'DateTime::Format::Strptime' => 0,
91 );
92
93 if ($Module::Install::AUTHOR) {
94
95   foreach my $module (keys %force_requires_if_author) {
96     build_requires ($module => $force_requires_if_author{$module});
97   }
98
99   system('pod2text lib/DBIx/Class.pm > README');
100 }
101
102 auto_provides;
103
104 if ($Module::Install::AUTHOR) {
105   warn <<'EOW';
106 ******************************************************************************
107 ******************************************************************************
108 ***                                                                        ***
109 *** AUTHOR MODE: all optional test dependencies converted to hard requires ***
110 ***                                                                        ***
111 ******************************************************************************
112 ******************************************************************************
113
114 EOW
115 }
116 auto_install;
117
118 # Have all prerequisites, check DBD::SQLite sanity
119 _check_sqlite() if (! $ENV{DBICTEST_NO_SQLITE_CHECK} );
120
121 WriteAll();
122
123 if ($Module::Install::AUTHOR) {
124   # Need to do this _after_ WriteAll else it loses track of them
125   Meta->{values}{build_requires} = [ grep {
126     my $ok = 1;
127     foreach my $module (keys %force_requires_if_author) {
128       if ($_->[0] =~ /$module/) {
129         $ok = 0;
130         last;
131       }
132     }
133     $ok;
134   } @{Meta->{values}{build_requires}} ];
135
136   Meta->{values}{resources} = [ 
137     [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
138     [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
139     [ 'license', 'http://dev.perl.org/licenses/' ],
140     [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
141   ];
142   Meta->write;
143 }
144
145
146 # This is legacy code. Latest DBD::SQLite developments fixed all known bugs
147 # in this area. Remove before some arbitrary next version
148 sub _check_sqlite {
149
150   # Win32 does not have real fork()s so a segfault will bring
151   # everything down. Warn about it below, and don't try fork()
152   if ($^O ne 'MSWin32') {
153
154     my $pid = fork();
155     if (not defined $pid) {
156         die "Unable to fork(): $!";
157     }
158     elsif (! $pid) {
159       _torture_sqlite();
160       exit 0;
161     }
162     else {
163       eval {
164           local $SIG{ALRM} = sub { die "timeout\n" };
165           alarm 5;
166           wait();
167           alarm 0;
168       };
169       my $exception = $@;
170
171       my $sig = $? & 127;
172
173       # make sure process actually dies
174       $exception && kill POSIX::SIGKILL(), $pid;
175
176       if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT()
177         || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case
178           warn (<<EOE);
179
180 ############################### WARNING #################################
181 #                                                                       #
182 # You are running a buggy version of DBD::SQLite known to randomly      #
183 # segfault on errors.  Even if you have the latest CPAN module version, #
184 # the sqlite3 dynamic library on this system might have been compiled   #
185 # against an older buggy sqlite3 dev library (oddly DBD::SQLite will    #
186 # prefer the system library against the one bundled with it). You are   #
187 # strongly advised to resolve this issue before proceeding.             #
188 #                                                                       #
189 #########################################################################
190
191 EOE
192           my $ans = prompt (
193             "The test suite of this module is almost certain to fail.\n"
194             . 'Do you really want to continue?',
195             'no',
196           );
197
198           exit 0 unless ($ans =~ /^y(es)?$/i);
199       }
200     }
201   }
202
203   else {  # the win32 version
204
205     print <<'EOW';
206 ######################################################################
207 #                                                                    #
208 # A short stress-testing of DBD::SQLite will follow. If you have a   #
209 # buggy library this might very well be the last text you will see   #
210 # before the installation silently terminates. If this happens it    #
211 # would mean that you are running a buggy version of DBD::SQLite     #
212 # known to randomly segfault on errors. Even if you have the latest  #
213 # CPAN module version, the system sqlite3 dynamic library might have #
214 # been compiled against an older buggy sqlite3 dev library (oddly    #
215 # DBD::SQLite will prefer the system library against the one bundled #
216 # with it). You are strongly advised to resolve this issue before    #
217 # proceeding.                                                        #
218 #                                                                    #
219 # If this happens to you (this text is the last thing you see), and  #
220 # you just want to install this module without worrying about the    #
221 # tests (which will almost certainly fail) - set the environment     #
222 # variable DBICTEST_NO_SQLITE_CHECK to a true value and try again.   #
223 #                                                                    #
224 ######################################################################
225
226 EOW
227
228     _torture_sqlite();
229   }
230 }
231
232 sub _torture_sqlite {
233   require DBI;
234
235   for (1 .. 100) {
236     my $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
237       AutoCommit => 1,
238       RaiseError => 0,
239       PrintError => 0,
240     }) or die "Unable to connect to database: $@";
241
242     $dbh->do ('CREATE TABLE name_with_no_columns');   # a subtle syntax error
243     $dbh->do ('COMMIT');                              # followed by commit
244     $dbh->disconnect;
245   }
246 }