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',
54 'Math::BigInt' => '1.80',
55 'Math::Base36' => '0.07',
64 my $rdbms_mssql_odbc = {
67 my $rdbms_mssql_sybase = {
70 my $rdbms_mssql_ado = {
73 my $rdbms_msaccess_odbc = {
76 my $rdbms_msaccess_ado = {
95 my $rdbms_informix = {
96 'DBD::Informix' => '0',
98 my $rdbms_sqlanywhere = {
99 'DBD::SQLAnywhere' => '0',
101 my $rdbms_sqlanywhere_odbc = {
104 my $rdbms_firebird = {
105 'DBD::Firebird' => '0',
107 my $rdbms_firebird_interbase = {
108 'DBD::InterBase' => '0',
110 my $rdbms_firebird_odbc = {
118 title => 'Storage::Replicated',
119 desc => 'Modules required for L<DBIx::Class::Storage::DBI::Replicated>',
126 'Test::Moose' => '0',
136 title => 'DBIx::Class::Admin',
137 desc => 'Modules required for the DBIx::Class administrative library',
146 title => 'dbicadmin',
147 desc => 'Modules required for the CLI DBIx::Class interface dbicadmin',
153 'SQL::Translator' => '0.11018',
156 title => 'Storage::DBI::deploy()',
157 desc => 'Modules required for L<DBIx::Class::Storage::DBI/deployment_statements> and L<DBIx::Class::Schema/deploy>',
162 req => $id_shortener,
165 test_component_accessor => {
167 'Class::Unload' => '0.07',
173 'Test::Pod' => '1.42',
177 test_podcoverage => {
179 'Test::Pod::Coverage' => '1.08',
180 'Pod::Coverage' => '0.20',
186 'Test::EOL' => '1.0',
187 'Test::NoTabs' => '0.9',
193 'Test::Strict' => '0.20',
197 test_prettydebug => {
198 req => $min_json_any,
201 test_admin_script => {
204 %$test_and_dist_json_any,
207 'Cpanel::JSON::XS' => 0,
210 # for t/admin/10script.t
211 ? ('Win32::ShellQuote' => 0)
212 # DWIW does not compile (./configure even) on win32
213 : ('JSON::DWIW' => 0 )
218 test_leaks_heavy => {
220 'Class::MethodCache' => '0.02',
221 'PadWalker' => '1.06',
226 req => $datetime_basic,
234 'DateTime::Format::SQLite' => '0',
241 # t/inflate/datetime_mysql.t
242 # (doesn't need Mysql itself)
243 'DateTime::Format::MySQL' => '0',
250 # t/inflate/datetime_pg.t
251 # (doesn't need PG itself)
252 'DateTime::Format::Pg' => '0.16004',
258 'Class::DBI::Plugin::DeepAbstractSearch' => '0',
260 'Time::Piece::MySQL' => '0',
261 'Date::Simple' => '3.03',
265 # this is just for completeness as SQLite
266 # is a core dep of DBIC for testing
272 title => 'SQLite support',
273 desc => 'Modules required to connect to SQLite',
279 # when changing this list make sure to adjust xt/optional_deps.t
283 title => 'PostgreSQL support',
284 desc => 'Modules required to connect to PostgreSQL',
288 rdbms_mssql_odbc => {
293 title => 'MSSQL support via DBD::ODBC',
294 desc => 'Modules required to connect to MSSQL via DBD::ODBC',
298 rdbms_mssql_sybase => {
300 %$rdbms_mssql_sybase,
303 title => 'MSSQL support via DBD::Sybase',
304 desc => 'Modules required to connect to MSSQL via DBD::Sybase',
313 title => 'MSSQL support via DBD::ADO (Windows only)',
314 desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
318 rdbms_msaccess_odbc => {
320 %$rdbms_msaccess_odbc,
323 title => 'MS Access support via DBD::ODBC',
324 desc => 'Modules required to connect to MS Access via DBD::ODBC',
328 rdbms_msaccess_ado => {
330 %$rdbms_msaccess_ado,
333 title => 'MS Access support via DBD::ADO (Windows only)',
334 desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
343 title => 'MySQL support',
344 desc => 'Modules required to connect to MySQL',
353 title => 'Oracle support',
354 desc => 'Modules required to connect to Oracle',
363 title => 'Sybase ASE support',
364 desc => 'Modules required to connect to Sybase ASE',
373 title => 'DB2 support',
374 desc => 'Modules required to connect to DB2',
383 title => 'DB2 on AS/400 support',
384 desc => 'Modules required to connect to DB2 on AS/400',
393 title => 'Informix support',
394 desc => 'Modules required to connect to Informix',
398 rdbms_sqlanywhere => {
403 title => 'SQLAnywhere support',
404 desc => 'Modules required to connect to SQLAnywhere',
408 rdbms_sqlanywhere_odbc => {
410 %$rdbms_sqlanywhere_odbc,
413 title => 'SQLAnywhere support via DBD::ODBC',
414 desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
423 title => 'Firebird support',
424 desc => 'Modules required to connect to Firebird',
428 rdbms_firebird_interbase => {
430 %$rdbms_firebird_interbase,
433 title => 'Firebird support via DBD::InterBase',
434 desc => 'Modules required to connect to Firebird via DBD::InterBase',
438 rdbms_firebird_odbc => {
440 %$rdbms_firebird_odbc,
443 title => 'Firebird support via DBD::ODBC',
444 desc => 'Modules required to connect to Firebird via DBD::ODBC',
448 # the order does matter because the rdbms support group might require
449 # a different version that the test group
452 $ENV{DBICTEST_PG_DSN}
454 # when changing this list make sure to adjust xt/optional_deps.t
456 'DBD::Pg' => '2.009002',
461 test_rdbms_mssql_odbc => {
463 $ENV{DBICTEST_MSSQL_ODBC_DSN}
470 test_rdbms_mssql_ado => {
472 $ENV{DBICTEST_MSSQL_ADO_DSN}
479 test_rdbms_mssql_sybase => {
481 $ENV{DBICTEST_MSSQL_DSN}
483 %$rdbms_mssql_sybase,
488 test_rdbms_msaccess_odbc => {
490 $ENV{DBICTEST_MSACCESS_ODBC_DSN}
492 %$rdbms_msaccess_odbc,
499 test_rdbms_msaccess_ado => {
501 $ENV{DBICTEST_MSACCESS_ADO_DSN}
503 %$rdbms_msaccess_ado,
510 test_rdbms_mysql => {
512 $ENV{DBICTEST_MYSQL_DSN}
519 test_rdbms_oracle => {
521 $ENV{DBICTEST_ORA_DSN}
524 'DateTime::Format::Oracle' => '0',
525 'DBD::Oracle' => '1.24',
532 $ENV{DBICTEST_SYBASE_DSN}
541 $ENV{DBICTEST_DB2_DSN}
548 test_rdbms_db2_400 => {
550 $ENV{DBICTEST_DB2_400_DSN}
557 test_rdbms_informix => {
559 $ENV{DBICTEST_INFORMIX_DSN}
566 test_rdbms_sqlanywhere => {
568 $ENV{DBICTEST_SQLANYWHERE_DSN}
575 test_rdbms_sqlanywhere_odbc => {
577 $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN}
579 %$rdbms_sqlanywhere_odbc,
584 test_rdbms_firebird => {
586 $ENV{DBICTEST_FIREBIRD_DSN}
593 test_rdbms_firebird_interbase => {
595 $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN}
597 %$rdbms_firebird_interbase,
602 test_rdbms_firebird_odbc => {
604 $ENV{DBICTEST_FIREBIRD_ODBC_DSN}
606 %$rdbms_firebird_odbc,
613 $ENV{DBICTEST_MEMCACHED}
615 'Cache::Memcached' => 0,
622 %$test_and_dist_json_any,
623 'ExtUtils::MakeMaker' => '6.64',
624 'Pod::Inherit' => '0.91',
630 'CPAN::Uploader' => '0.103001',
640 # OO for (mistakenly considered) ease of extensibility, not due to any need to
641 # carry state of any sort. This API is currently used outside, so leave as-is.
642 # FIXME - make sure to not propagate this further if module is extracted as a
643 # standalone library - keep the stupidity to a DBIC-secific shim!
646 my ($class, $group) = @_;
648 croak "req_list_for() expects a requirement group name"
651 my $deps = $reqs->{$group}{req}
652 or croak "Requirement group '$group' does not exist";
658 return { map { $_ => { %{ $reqs->{$_}{req} || {} } } } (keys %$reqs) };
661 sub req_errorlist_for {
662 my ($class, $group) = @_;
664 croak "req_errorlist_for() expects a requirement group name"
667 return $class->_check_deps($group)->{errorlist};
671 my ($class, $group) = @_;
673 croak "req_ok_for() expects a requirement group name"
676 return $class->_check_deps($group)->{status};
679 sub req_missing_for {
680 my ($class, $group) = @_;
682 croak "req_missing_for() expects a requirement group name"
685 return $class->_check_deps($group)->{missing};
688 sub die_unless_req_ok_for {
689 my ($class, $group) = @_;
691 croak "die_unless_req_ok_for() expects a requirement group name"
694 $class->_check_deps($group)->{status}
695 or die sprintf( "Required modules missing, unable to continue: %s\n", $class->_check_deps($group)->{missing} );
702 our %req_availability_cache;
704 my ($class, $group) = @_;
706 return $req_availability_cache{$group} ||= do {
708 my $deps = $class->req_list_for ($group);
711 for my $mod (keys %$deps) {
712 my $req_line = "require $mod;";
713 if (my $ver = $deps->{$mod}) {
714 $req_line .= "$mod->VERSION($ver);";
719 $errors{$mod} = $@ if $@;
725 my $missing = join (', ', map { $deps->{$_} ? qq("${_}~>=$deps->{$_}") : $_ } (sort keys %errors) );
726 $missing .= " (see $class documentation for details)" if $reqs->{$group}{pod};
729 errorlist => \%errors,
745 # This is to be called by the author only (automatically in Makefile.PL)
747 my ($class, $distver, $pod_dir) = @_;
749 die "No POD root dir supplied" unless $pod_dir;
752 eval { require DBIx::Class; DBIx::Class->VERSION; }
755 "\n\n---------------------------------------------------------------------\n" .
756 'Unable to load core DBIx::Class module to determine current version, '.
757 'possibly due to missing dependencies. Author-mode autodocumentation ' .
759 "\n\n---------------------------------------------------------------------\n"
762 # do not ask for a recent version, use 1.x API calls
763 # this *may* execute on a smoker with old perl or whatnot
766 (my $modfn = __PACKAGE__ . '.pm') =~ s|::|/|g;
768 (my $podfn = "$pod_dir/$modfn") =~ s/\.pm$/\.pod/;
769 (my $dir = $podfn) =~ s|/[^/]+$||;
771 File::Path::mkpath([$dir]);
773 my $sqltver = $class->req_list_for ('deploy')->{'SQL::Translator'}
774 or die "Hrmm? No sqlt dep?";
784 #########################################################################
785 ##################### A U T O G E N E R A T E D ########################
786 #########################################################################
788 # The contents of this POD file are auto-generated. Any changes you make
789 # will be lost. If you need to change the generated text edit _gen_pod()
790 # at the end of $modfn
794 "$class - Optional module dependency specifications (for module authors)",
804 Somewhere in your build-file (e.g. L<Module::Install>'s Makefile.PL):
808 configure_requires 'DBIx::Class' => '$distver';
812 my \$deploy_deps = $class->req_list_for('deploy');
814 for (keys %\$deploy_deps) {
815 requires \$_ => \$deploy_deps->{\$_};
820 Note that there are some caveats regarding C<configure_requires()>, more info
821 can be found at L<Module::Install/configure_requires>
827 #@@ DESCRIPTION HEADING
830 '=head1 DESCRIPTION',
832 Some of the less-frequently used features of L<DBIx::Class> have external
833 module dependencies on their own. In order not to burden the average user
834 with modules he will never use, these optional dependencies are not included
835 in the base Makefile.PL. Instead an exception with a descriptive message is
836 thrown when a specific feature is missing one or several modules required for
837 its operation. This module is the central holding place for the current list
838 of such dependencies, for DBIx::Class core authors, and DBIx::Class extension
845 #@@ REQUIREMENT GROUPLIST HEADING
848 '=head1 CURRENT REQUIREMENT GROUPS',
850 Dependencies are organized in C<groups> and each group can list one or more
851 required modules, with an optional minimum version (or 0 for any version).
852 The group name can be used in the
856 for my $group (sort keys %$reqs) {
857 my $p = $reqs->{$group}{pod}
860 my $modlist = $reqs->{$group}{req}
863 next unless keys %$modlist;
866 "=head2 $p->{title}",
869 ( map { "=item * $_" . ($modlist->{$_} ? " >= $modlist->{$_}" : '') } (sort keys %$modlist) ),
871 "Requirement group: B<$group>",
877 #@@ API DOCUMENTATION HEADING
881 '=head2 req_group_list',
883 '=item Arguments: none',
884 '=item Return Value: \%list_of_requirement_groups',
887 This method should be used by DBIx::Class packagers, to get a hashref of all
888 dependencies keyed by dependency group. Each key (group name) can be supplied
889 to one of the group-specific methods below.
892 '=head2 req_list_for',
894 '=item Arguments: $group_name',
895 '=item Return Value: \%list_of_module_version_pairs',
898 This method should be used by DBIx::Class extension authors, to determine the
899 version of modules a specific feature requires in the B<current> version of
900 DBIx::Class. See the L</SYNOPSIS> for a real-world
906 '=item Arguments: $group_name',
907 '=item Return Value: 1|0',
910 Returns true or false depending on whether all modules required by
911 C<$group_name> are present on the system and loadable.
914 '=head2 req_missing_for',
916 '=item Arguments: $group_name',
917 '=item Return Value: $error_message_string',
920 Returns a single line string suitable for inclusion in larger error messages.
921 This method would normally be used by DBIx::Class core-module author, to
922 indicate to the user that he needs to install specific modules before he will
923 be able to use a specific feature.
925 For example if some of the requirements for C<deploy> are not available,
926 the returned string could look like:
928 "SQL::Translator~>=$sqltver" (see $class documentation for details)
930 The author is expected to prepend the necessary text to this message before
931 returning the actual error seen by the user.
934 '=head2 die_unless_req_ok_for',
936 '=item Arguments: $group_name',
939 Checks if L</req_ok_for> passes for the supplied C<$group_name>, and
940 in case of failure throws an exception including the information
941 from L</req_missing_for>.
944 '=head2 req_errorlist_for',
946 '=item Arguments: $group_name',
947 '=item Return Value: \%list_of_loaderrors_per_module',
950 Returns a hashref containing the actual errors that occurred while attempting
951 to load each module in the requirement group.
960 '=head1 FURTHER QUESTIONS?',
961 'Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.',
962 '=head1 COPYRIGHT AND LICENSE',
964 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
965 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
966 redistribute it and/or modify it under the same terms as the
967 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
974 open (my $fh, '>', $podfn) or die;
975 print $fh join ("\n\n", @chunks) or die;
976 print $fh "\n" or die;
978 } or croak( "Unable to write $podfn: " . ( $! || $@ || 'unknown error') );