1 package DBIx::Class::Optional::Dependencies;
8 # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G)
9 # This module is to be loaded by Makefile.PM on a pristine system
11 # POD is generated automatically by calling _gen_pod from the
12 # Makefile.PL in $AUTHOR mode
14 # NOTE: the rationale for 2 JSON::Any versions is that
15 # we need the newer only to work around JSON::XS, which
16 # itself is an optional dep
18 'JSON::Any' => '1.23',
20 my $test_and_dist_json_any = {
21 'JSON::Any' => '1.31',
26 'MooseX::Types' => '0.21',
27 'MooseX::Types::LoadableClass' => '0.011',
37 'MooseX::Types::Path::Class' => '0.05',
38 'MooseX::Types::JSON' => '0.02',
44 'Getopt::Long::Descriptive' => '0.081',
45 'Text::CSV' => '1.16',
48 my $datetime_basic = {
50 'DateTime::Format::Strptime' => '1.2',
55 'Math::BigInt' => '1.80',
56 'Math::Base36' => '0.07',
65 my $rdbms_mssql_odbc = {
68 my $rdbms_mssql_sybase = {
71 my $rdbms_mssql_ado = {
74 my $rdbms_msaccess_odbc = {
77 my $rdbms_msaccess_ado = {
96 my $rdbms_informix = {
97 'DBD::Informix' => '0',
99 my $rdbms_sqlanywhere = {
100 'DBD::SQLAnywhere' => '0',
102 my $rdbms_sqlanywhere_odbc = {
105 my $rdbms_firebird = {
106 'DBD::Firebird' => '0',
108 my $rdbms_firebird_interbase = {
109 'DBD::InterBase' => '0',
111 my $rdbms_firebird_odbc = {
119 title => 'Storage::Replicated',
120 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
127 'Test::Moose' => '0',
137 title => 'DBIx::Class::Admin',
138 desc => 'Modules required for the DBIx::Class administrative library',
147 title => 'dbicadmin',
148 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
154 'SQL::Translator' => '0.11018',
157 title => 'Storage::DBI::deploy()',
158 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deployment_statements> and L<DBIx::Class::Schema/deploy>',
163 req => $id_shortener,
166 test_component_accessor => {
168 'Class::Unload' => '0.07',
174 'Test::Pod' => '1.42',
178 test_podcoverage => {
180 'Test::Pod::Coverage' => '1.08',
181 'Pod::Coverage' => '0.20',
187 'Test::EOL' => '1.0',
188 'Test::NoTabs' => '0.9',
194 'Test::Strict' => '0.20',
198 test_prettydebug => {
199 req => $min_json_any,
202 test_admin_script => {
205 %$test_and_dist_json_any,
208 'Cpanel::JSON::XS' => 0,
211 # for t/admin/10script.t
212 ? ('Win32::ShellQuote' => 0)
213 # DWIW does not compile (./configure even) on win32
214 : ('JSON::DWIW' => 0 )
219 test_leaks_heavy => {
221 'Class::MethodCache' => '0.02',
222 'PadWalker' => '1.06',
227 req => $datetime_basic,
235 'DateTime::Format::SQLite' => '0',
242 # t/inflate/datetime_mysql.t
243 # (doesn't need Mysql itself)
244 'DateTime::Format::MySQL' => '0',
251 # t/inflate/datetime_pg.t
252 # (doesn't need PG itself)
253 'DateTime::Format::Pg' => '0.16004',
259 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
261 'Time::Piece::MySQL' => '0',
262 'Date::Simple' => '3.03',
266 # this is just for completeness as SQLite
267 # is a core dep of DBIC for testing
273 title => 'SQLite support',
274 desc => 'Modules required to connect to SQLite',
280 # when changing this list make sure to adjust xt/optional_deps.t
284 title => 'PostgreSQL support',
285 desc => 'Modules required to connect to PostgreSQL',
289 rdbms_mssql_odbc => {
294 title => 'MSSQL support via DBD::ODBC',
295 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
299 rdbms_mssql_sybase => {
301 %$rdbms_mssql_sybase,
304 title => 'MSSQL support via DBD::Sybase',
305 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
314 title => 'MSSQL support via DBD::ADO (Windows only)',
315 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
319 rdbms_msaccess_odbc => {
321 %$rdbms_msaccess_odbc,
324 title => 'MS Access support via DBD::ODBC',
325 desc => 'Modules required to connect to MS Access via DBD::ODBC',
329 rdbms_msaccess_ado => {
331 %$rdbms_msaccess_ado,
334 title => 'MS Access support via DBD::ADO (Windows only)',
335 desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
344 title => 'MySQL support',
345 desc => 'Modules required to connect to MySQL',
354 title => 'Oracle support',
355 desc => 'Modules required to connect to Oracle',
364 title => 'Sybase ASE support',
365 desc => 'Modules required to connect to Sybase ASE',
374 title => 'DB2 support',
375 desc => 'Modules required to connect to DB2',
384 title => 'DB2 on AS/400 support',
385 desc => 'Modules required to connect to DB2 on AS/400',
394 title => 'Informix support',
395 desc => 'Modules required to connect to Informix',
399 rdbms_sqlanywhere => {
404 title => 'SQLAnywhere support',
405 desc => 'Modules required to connect to SQLAnywhere',
409 rdbms_sqlanywhere_odbc => {
411 %$rdbms_sqlanywhere_odbc,
414 title => 'SQLAnywhere support via DBD::ODBC',
415 desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
424 title => 'Firebird support',
425 desc => 'Modules required to connect to Firebird',
429 rdbms_firebird_interbase => {
431 %$rdbms_firebird_interbase,
434 title => 'Firebird support via DBD::InterBase',
435 desc => 'Modules required to connect to Firebird via DBD::InterBase',
439 rdbms_firebird_odbc => {
441 %$rdbms_firebird_odbc,
444 title => 'Firebird support via DBD::ODBC',
445 desc => 'Modules required to connect to Firebird via DBD::ODBC',
449 # the order does matter because the rdbms support group might require
450 # a different version that the test group
453 $ENV{DBICTEST_PG_DSN}
455 # when changing this list make sure to adjust xt/optional_deps.t
457 'DBD::Pg' => '2.009002',
462 test_rdbms_mssql_odbc => {
464 $ENV{DBICTEST_MSSQL_ODBC_DSN}
471 test_rdbms_mssql_ado => {
473 $ENV{DBICTEST_MSSQL_ADO_DSN}
480 test_rdbms_mssql_sybase => {
482 $ENV{DBICTEST_MSSQL_DSN}
484 %$rdbms_mssql_sybase,
489 test_rdbms_msaccess_odbc => {
491 $ENV{DBICTEST_MSACCESS_ODBC_DSN}
493 %$rdbms_msaccess_odbc,
500 test_rdbms_msaccess_ado => {
502 $ENV{DBICTEST_MSACCESS_ADO_DSN}
504 %$rdbms_msaccess_ado,
511 test_rdbms_mysql => {
513 $ENV{DBICTEST_MYSQL_DSN}
520 test_rdbms_oracle => {
522 $ENV{DBICTEST_ORA_DSN}
525 'DateTime::Format::Oracle' => '0',
526 'DBD::Oracle' => '1.24',
533 $ENV{DBICTEST_SYBASE_DSN}
542 $ENV{DBICTEST_DB2_DSN}
549 test_rdbms_db2_400 => {
551 $ENV{DBICTEST_DB2_400_DSN}
558 test_rdbms_informix => {
560 $ENV{DBICTEST_INFORMIX_DSN}
567 test_rdbms_sqlanywhere => {
569 $ENV{DBICTEST_SQLANYWHERE_DSN}
576 test_rdbms_sqlanywhere_odbc => {
578 $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
580 %$rdbms_sqlanywhere_odbc,
585 test_rdbms_firebird => {
587 $ENV{DBICTEST_FIREBIRD_DSN}
594 test_rdbms_firebird_interbase => {
596 $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN}
598 %$rdbms_firebird_interbase,
603 test_rdbms_firebird_odbc => {
605 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
607 %$rdbms_firebird_odbc,
614 $ENV{DBICTEST_MEMCACHED}
616 'Cache::Memcached' => 0,
623 %$test_and_dist_json_any,
624 'ExtUtils::MakeMaker' => '6.64',
625 'Pod::Inherit' => '0.91',
631 'CPAN::Uploader' => '0.103001',
641 # OO for (mistakenly considered) ease of extensibility, not due to any need to
642 # carry state of any sort. This API is currently used outside, so leave as-is.
643 # FIXME - make sure to not propagate this further if module is extracted as a
644 # standalone library - keep the stupidity to a DBIC-secific shim!
647 my ($class, $group) = @_;
649 croak "req_list_for() expects a requirement group name"
652 my $deps = $reqs->{$group}{req}
653 or croak "Requirement group '$group' does not exist";
659 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
662 sub req_errorlist_for {
663 my ($class, $group) = @_;
665 croak "req_errorlist_for() expects a requirement group name"
668 return $class->_check_deps($group)->{errorlist};
672 my ($class, $group) = @_;
674 croak "req_ok_for() expects a requirement group name"
677 return $class->_check_deps($group)->{status};
680 sub req_missing_for {
681 my ($class, $group) = @_;
683 croak "req_missing_for() expects a requirement group name"
686 return $class->_check_deps($group)->{missing};
689 sub die_unless_req_ok_for {
690 my ($class, $group) = @_;
692 croak "die_unless_req_ok_for() expects a requirement group name"
695 $class->_check_deps($group)->{status}
696 or die sprintf( "Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{missing} );
703 our %req_availability_cache;
705 my ($class, $group) = @_;
707 return $req_availability_cache{$group} ||= do {
709 my $deps = $class->req_list_for ($group);
712 for my $mod (keys %$deps) {
713 my $req_line = "require $mod;";
714 if (my $ver = $deps->{$mod}) {
715 $req_line .= "$mod->VERSION($ver);";
720 $errors{$mod} = $@ if $@;
726 my $missing = join (', ', map { $deps->{$_} ? qq("${_}~>=$deps->{$_}") : $_ } (sort keys %errors) );
727 $missing .= " (see $class documentation for details)" if $reqs->{$group}{pod};
730 errorlist => \%errors,
746 # This is to be called by the author only (automatically in Makefile.PL)
748 my ($class, $distver, $pod_dir) = @_;
750 die "No POD root dir supplied" unless $pod_dir;
753 eval { require DBIx::Class; DBIx::Class->VERSION; }
756 "\n\n---------------------------------------------------------------------\n" .
757 'Unable to load core DBIx::Class module to determine current version, '.
758 'possibly due to missing dependencies. Author-mode autodocumentation ' .
760 "\n\n---------------------------------------------------------------------\n"
763 # do not ask for a recent version, use 1.x API calls
764 # this *may* execute on a smoker with old perl or whatnot
767 (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
769 (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
770 (my $dir = $podfn) =~ s|/[^/]+$||;
772 File::Path::mkpath([$dir]);
774 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
775 or die "Hrmm? No sqlt dep?";
785 #########################################################################
786 ##################### A U T O G E N E R A T E D ########################
787 #########################################################################
789 # The contents of this POD file are auto-generated. Any changes you make
790 # will be lost. If you need to change the generated text edit _gen_pod()
791 # at the end of $modfn
795 "$class - Optional module dependency specifications (for module authors)",
805 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
809 configure_requires 'DBIx::Class' => '$distver';
813 my \$deploy_deps = $class->req_list_for('deploy');
815 for (keys %\$deploy_deps) {
816 requires \$_ => \$deploy_deps->{\$_};
821 Note that there are some caveats regarding C<configure_requires()>, more info
822 can be found at L<Module::Install/configure_requires>
828 #@@ DESCRIPTION HEADING
831 '=head1 DESCRIPTION',
833 Some of the less-frequently used features of L<DBIx::Class> have external
834 module dependencies on their own. In order not to burden the average user
835 with modules he will never use, these optional dependencies are not included
836 in the base Makefile.PL. Instead an exception with a descriptive message is
837 thrown when a specific feature is missing one or several modules required for
838 its operation. This module is the central holding place for the current list
839 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
846 #@@ REQUIREMENT GROUPLIST HEADING
849 '=head1 CURRENT REQUIREMENT GROUPS',
851 Dependencies are organized in C<groups> and each group can list one or more
852 required modules, with an optional minimum version (or 0 for any version).
853 The group name can be used in the
857 for my $group (sort keys %$reqs) {
858 my $p = $reqs->{$group}{pod}
861 my $modlist = $reqs->{$group}{req}
864 next unless keys %$modlist;
867 "=head2 $p->{title}",
870 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
872 "Requirement group: B<$group>",
878 #@@ API DOCUMENTATION HEADING
882 '=head2 req_group_list',
884 '=item Arguments: none',
885 '=item Return Value: \%list_of_requirement_groups',
888 This method should be used by DBIx::Class packagers, to get a hashref of all
889 dependencies keyed by dependency group. Each key (group name) can be supplied
890 to one of the group-specific methods below.
893 '=head2 req_list_for',
895 '=item Arguments: $group_name',
896 '=item Return Value: \%list_of_module_version_pairs',
899 This method should be used by DBIx::Class extension authors, to determine the
900 version of modules a specific feature requires in the B<current> version of
901 DBIx::Class. See the L</SYNOPSIS> for a real-world
907 '=item Arguments: $group_name',
908 '=item Return Value: 1|0',
911 Returns true or false depending on whether all modules required by
912 C<$group_name> are present on the system and loadable.
915 '=head2 req_missing_for',
917 '=item Arguments: $group_name',
918 '=item Return Value: $error_message_string',
921 Returns a single line string suitable for inclusion in larger error messages.
922 This method would normally be used by DBIx::Class core-module author, to
923 indicate to the user that he needs to install specific modules before he will
924 be able to use a specific feature.
926 For example if some of the requirements for C<deploy> are not available,
927 the returned string could look like:
929 "SQL::Translator~>=$sqltver" (see $class documentation for details)
931 The author is expected to prepend the necessary text to this message before
932 returning the actual error seen by the user.
935 '=head2 die_unless_req_ok_for',
937 '=item Arguments: $group_name',
940 Checks if L</req_ok_for> passes for the supplied C<$group_name>, and
941 in case of failure throws an exception including the information
942 from L</req_missing_for>.
945 '=head2 req_errorlist_for',
947 '=item Arguments: $group_name',
948 '=item Return Value: \%list_of_loaderrors_per_module',
951 Returns a hashref containing the actual errors that occurred while attempting
952 to load each module in the requirement group.
961 '=head1 FURTHER QUESTIONS?',
962 'Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.',
963 '=head1 COPYRIGHT AND LICENSE',
965 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
966 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
967 redistribute it and/or modify it under the same terms as the
968 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
975 open (my $fh, '>', $podfn) or die;
976 print $fh join ("\n\n", @chunks) or die;
977 print $fh "\n" or die;
979 } or croak( "Unable to write $podfn: " . ( $! || $@ || 'unknown error') );