Author: dagolden
Date: Mon Nov 16 19:38:06 2009
New Revision: 13548

Modified:
   Module-Build/trunk/Build.PL
   Module-Build/trunk/Changes
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/t/bundle_inc.t

Log:
Omnibus fixes for author-type dependencies

Multiple tests were failing due to dependency problems.  Author
dependencies have been largely removed from core 'requires' into
optional features.  Feature prereq detection and messaging have been
expanded and bugs on older Perls have been removed.



Modified: Module-Build/trunk/Build.PL
==============================================================================
--- Module-Build/trunk/Build.PL (original)
+++ Module-Build/trunk/Build.PL Mon Nov 16 19:38:06 2009
@@ -25,6 +25,8 @@
     'Test::More'            => 0.49,
     'Test::Harness'         => 3.16,    # PERL5LIB fixes
   },
+  # KEEP 'requires' as low as possible and target Build/test/install
+  # Requirements for authors should be implemented as optional features
   requires    => {
     'perl'                  => '5.006001',
     'Data::Dumper'          => 0,
@@ -35,10 +37,9 @@
     'File::Path'            => 0,
     'File::Spec'            => ($^O eq 'MSWin32' ? 3.30 : '0.82'), # rel2abs()
     'ExtUtils::Install'     => 0,
-    'ExtUtils::Installed'   => 0,
     'ExtUtils::Manifest'    => 0,
     'ExtUtils::Mkbootstrap' => 0,
-    'IO::File'              => 1.13, # fixes binmode bug on perl < 5.8.8
+    'IO::File'              => 0,
     'Cwd'                   => 0,
     'Text::Abbrev'          => 0,
     'Text::ParseWords'      => 0,
@@ -46,13 +47,8 @@
     'Test::Harness'         => 0,
   },
   recommends => {
-    'Archive::Tar'       => 1.09,
-    'ExtUtils::CBuilder' => 0.260301, # numerous bug fixes
     'ExtUtils::Install'  => 0.30,
     'ExtUtils::Manifest' => 1.54, # public maniskip()
-    'ExtUtils::ParseXS'  => 2.21,
-    'Pod::Readme'        => 0.04,
-    'Module::Signature'  => 0.21,
     'version'            => 0.74,
   },
   recursive_test_files => 1,
@@ -62,15 +58,42 @@
 
   # overwrite the M::B that shipped in core
   installdirs   => ($] >= 5.009004 ? 'core' : 'site'),
-  
-  # Some CPANPLUS::Dist::Build versions need to allow mismatches 
+
+  # Some CPANPLUS::Dist::Build versions need to allow mismatches
   # On logic: thanks to Module::Install, CPAN.pm must set both keys, but
   # CPANPLUS sets only the one
-  allow_mb_mismatch => ( 
+  allow_mb_mismatch => (
     $ENV{PERL5_CPANPLUS_IS_RUNNING} && ! $ENV{PERL5_CPAN_IS_RUNNING} ? 1 : 0
   ),
 
   auto_features => {
+    dist_authoring => {
+      description => "Create new distributions",
+      requires => {
+        'Archive::Tar'       => 1.09,
+      },
+      recommends => {
+        'Pod::Readme'        => 0.04,
+        'Module::Signature'  => 0.21,
+      },
+    },
+    license_creation => {
+      description => "Create licenses automatically in distributions",
+      requires => {
+        'Software::License'  => 0,
+      },
+    },
+    PPM_support => {
+      description => "Generate PPM files for distributions",
+      requires    => {'IO::File' => 1.13}, # binmode bug in older core IO::File
+    },
+    inc_bundling_support => {
+      description => "Bundle Module::Build in inc/",
+      requires    => {
+        'ExtUtils::Install'     => 1.54, # also gets us ExtUtils::Installed 
1.999_001
+        'ExtUtils::Installed'   => 1.999, # technically 1.999_001 is what's 
available
+      },
+    },
     YAML_support => {
       description => "Use YAML::Tiny to write META.yml files",
       requires    => {'YAML::Tiny' => 1.38},
@@ -82,7 +105,7 @@
     },
     manpage_support => {
       description => "Create Unix man pages",
-      requires    => {'Pod::Man' => 0, 'Pod::Simple' => 0},
+      requires    => {'Pod::Man' => 0 },
     },
     HTML_support => {
       description => "Create HTML documentation",

Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes  (original)
+++ Module-Build/trunk/Changes  Mon Nov 16 19:38:06 2009
@@ -2,6 +2,13 @@
 
 0.35_08 - 
 
+ Bug fixes:
+
+ - Multiple tests were failing due to dependency problems.  Author
+   dependencies have been largely removed from core 'requires' into
+   optional features.  Feature prereq detection and messaging have been
+   expanded and bugs on older Perls have been removed.
+
 0.35_07 - Sat Nov 14 17:14:39 EST 2009
 
  Bug fixes:

Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Mon Nov 16 19:38:06 2009
@@ -45,7 +45,10 @@
 of the modules indicated above before proceeding with this installation
 
 EOF
-    unless ( $ENV{PERL5_CPANPLUS_IS_RUNNING} || $ENV{PERL5_CPAN_IS_RUNNING} ) {
+    unless (
+      $self->dist_name eq 'Module-Build' ||
+      $ENV{PERL5_CPANPLUS_IS_RUNNING} || $ENV{PERL5_CPAN_IS_RUNNING} 
+    ) {
       $self->log_warn(
         "Run 'Build installdeps' to install missing prerequisites.\n\n"
       );
@@ -621,10 +624,18 @@
     }
 
     if (my $info = $ph->{auto_features}->access($key)) {
-      my $failures = $self->prereq_failures($info);
-      my $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
-                          keys %$failures ) ? 1 : 0;
-      return !$disabled;
+      my $disabled;
+      for my $type ( @{$self->prereq_action_types} ) {
+        next if $type eq 'description' || $type eq 'recommends' || ! exists 
$info->{$type};
+        my $prereqs = $info->{$type};
+        for my $modname ( sort keys %$prereqs ) {
+          my $spec = $prereqs->{$modname};
+          my $status = $self->check_installed_status($modname, $spec);
+          if ((!$status->{ok}) xor ($type =~ /conflicts$/)) { return 0; }
+          if ( ! eval "require $modname; 1" ) { return 0; }
+        }
+      }
+      return 1;
     }
 
     return $ph->{features}->access($key, @_);
@@ -658,6 +669,15 @@
   }
 }
 
+sub _warn_mb_feature_deps {
+  my $self = shift;
+  my $name = shift;
+  $self->log_warn(
+    "The '$name' feature is not available.  Please install missing\n" .
+    "feature dependencies and try again.\n".
+    $self->_feature_deps_msg($name) . "\n"
+  );
+}
 
 sub add_build_element {
     my ($self, $elem) = @_;
@@ -1250,13 +1270,14 @@
 
   sub set_bundle_inc {
     my $self = shift;
+    
     my $bundle_inc = $self->{properties}{bundle_inc};
     my $bundle_inc_preload = $self->{properties}{bundle_inc_preload};
     # We're in author mode if inc::latest is loaded, but not from cwd
     return unless inc::latest->can('loaded_modules');
     require ExtUtils::Installed;
     # ExtUtils::Installed is buggy about finding additions to default @INC
-    my $inst = ExtUtils::Installed->new(extra_libs => [$self->_added_to_INC]);
+    my $inst = ExtUtils::Installed->new(extra_libs => [...@inc]);
     my @bundle_list = map { [ $_, 0 ] } inc::latest->loaded_modules;
 
     # XXX TODO: Need to get ordering of prerequisites correct so they are
@@ -1306,30 +1327,12 @@
   my $max_name_len = length($longest->(keys %$features));
 
   my ($num_disabled, $log_text) = (0, "\nChecking optional features...\n");
-  while (my ($name, $info) = each %$features) {
-    my $feature_text = "  $name" . '.' x ($max_name_len - length($name) + 4);
-
-    my $disabled;
-    if ( my $failures = $self->prereq_failures($info) ) {
-      $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
-                          keys %$failures ) ? 1 : 0;
-      $feature_text .= $disabled ? "disabled\n" : "enabled\n";
-      $num_disabled++ if $disabled;
-
-      while (my ($type, $prereqs) = each %$failures) {
-       while (my ($module, $status) = each %$prereqs) {
-         my $required =
-           ($type =~ /^(?:\w+_)?(?:requires|conflicts)$/) ? 1 : 0;
-         my $prefix = ($required) ? '-' : '*';
-         $feature_text .= "    $prefix $status->{message}\n";
-       }
-      }
-    } else {
-      $feature_text .= "enabled\n";
-    }
-    $log_text .= $feature_text if $disabled || $self->verbose;
+  for my $name ( sort keys %$features ) {
+    $log_text .= $self->_feature_deps_msg($name, $max_name_len);
   }
 
+  $num_disabled = () = $log_text =~ /disabled/g;
+
   # warn user if features disabled
   if ( $num_disabled ) {
     $self->log_warn( $log_text );
@@ -1341,6 +1344,38 @@
   }
 }
 
+sub _feature_deps_msg {
+  my ($self, $name, $max_name_len) = @_;
+    $max_name_len ||= length $name;
+    my $features = $self->auto_features;
+    my $info = $features->{$name};
+    my $feature_text = "$name" . '.' x ($max_name_len - length($name) + 4);
+
+    my ($log_text, $disabled) = ('','');
+    if ( my $failures = $self->prereq_failures($info) ) {
+      $disabled = grep( /^(?:\w+_)?(?:requires|conflicts)$/,
+                  keys %$failures ) ? 1 : 0;
+      $feature_text .= $disabled ? "disabled\n" : "enabled\n";
+
+      for my $type ( @{ $self->prereq_action_types } ) {
+        next unless exists $failures->{$type};
+        $feature_text .= "  $type:\n";
+        my $prereqs = $failures->{$type};
+        for my $module ( sort keys %$prereqs ) {
+          my $status = $prereqs->{$module};
+          my $required =
+            ($type =~ /^(?:\w+_)?(?:requires|conflicts)$/) ? 1 : 0;
+          my $prefix = ($required) ? '!' : '*';
+          $feature_text .= "    $prefix $status->{message}\n";
+        }
+      }
+    } else {
+      $feature_text .= "enabled\n";
+    }
+    $log_text .= $feature_text if $disabled || $self->verbose;
+    return $log_text;
+}
+
 # Automatically detect and add prerequisites based on configuration
 sub auto_require {
   my ($self) = @_;
@@ -1414,7 +1449,8 @@
 
   foreach my $type (@types) {
     my $prereqs = $info->{$type};
-    while ( my ($modname, $spec) = each %$prereqs ) {
+    for my $modname ( keys %$prereqs ) {
+      my $spec = $prereqs->{$modname};
       my $status = $self->check_installed_status($modname, $spec);
 
       if ($type =~ /^(?:\w+_)?conflicts$/) {
@@ -1463,23 +1499,20 @@
   my $failures = $self->prereq_failures($info);
 
   if ( $failures ) {
+    $self->log_warn($log_text);
     for my $type ( @{ $self->prereq_action_types } ) {
       my $prereqs = $failures->{$type};
+      $self->log_warn("  ${type}:\n") if keys %$prereqs;
       for my $module ( sort keys %$prereqs ) {
         my $status = $prereqs->{$module};
-        my $prefix = ($type =~ /^(?:\w+_)?recommends$/) ? "* $type:" : "! 
$type:";
-        $log_text .= "$prefix $status->{message}\n";
+        my $prefix = ($type =~ /^(?:\w+_)?recommends$/) ? "* " : "! ";
+        $self->log_warn("    $prefix $status->{message}\n");
       }
     }
-
-    $self->log_warn( $log_text );
     return 0;
-
   } else {
-
     $self->log_verbose($log_text . "Looks good\n\n");
     return 1;
-
   }
 }
 
@@ -3350,6 +3383,7 @@
 
 sub ACTION_ppd {
   my ($self) = @_;
+
   require Module::Build::PPMMaker;
   my $ppd = Module::Build::PPMMaker->new();
   my $file = $ppd->make_ppd(%{$self->{args}}, build => $self);
@@ -3575,6 +3609,11 @@
   my $self = shift;
   $self->log_info("Creating LICENSE file\n");
 
+  if (  ! $self->_mb_feature('license_creation') ) {
+    $self->_warn_mb_feature_deps('license_creation');
+    die "Aborting.\n";
+  }
+
   my $l = $self->license
     or die "No license specified";
 
@@ -3583,7 +3622,7 @@
   my $class = "Software::License::$key";
 
   eval "use $class; 1"
-    or die "Can't load Software::License to create LICENSE file: $@";
+    or die "Can't load Software::License::$key to create LICENSE file: $@";
 
   $self->delete_filetree('LICENSE');
 
@@ -3680,6 +3719,11 @@
 sub ACTION_distdir {
   my ($self) = @_;
 
+  if ( @{$self->bundle_inc} && ! $self->_mb_feature('inc_bundling_support') ) {
+    $self->_warn_mb_feature_deps('inc_bundling_support');
+    die "Aborting.\n";
+  }
+
   $self->depends_on('distmeta');
   
   # Must not include MYMETA
@@ -4166,7 +4210,7 @@
 
     if (my $key = $self->valid_licenses->{ $l }) {
       my $class = "Software::License::$key";
-      if (eval "use $class; 1") {
+      if (eval "require Software::License; require $class; 1") {
         # S::L requires a 'holder' key
         $node->{resources}{license} = $class->new({holder=>"nobody"})->url;
       }

Modified: Module-Build/trunk/t/bundle_inc.t
==============================================================================
--- Module-Build/trunk/t/bundle_inc.t   (original)
+++ Module-Build/trunk/t/bundle_inc.t   Mon Nov 16 19:38:06 2009
@@ -10,10 +10,15 @@
 use ExtUtils::Packlist;
 use File::Path;
 
-plan tests => 17;
-
 # Ensure any Module::Build modules are loaded from correct directory
 blib_load('Module::Build');
+blib_load('Module::Build::ConfigData');
+
+if ( Module::Build::ConfigData->feature('inc_bundling_support') ) {
+  plan tests => 18;
+} else {
+  plan skip_all => 'inc_bundling_support feature is not enabled';
+}
 
 # need to do a temp install of M::B being tested to ensure a packlist
 # is available for bundling
@@ -24,6 +29,7 @@
 my $lib_path = File::Spec->catdir($temp_install,qw/lib perl5/);
 my $arch_path = File::Spec->catdir( $lib_path, $arch );
 mkpath ( $arch_path );
+ok( -d $arch_path, "created temporary M::B pseudo-install directory");
 
 unshift @INC, $lib_path, $arch_path;
 local $ENV{PERL5LIB} = join( $Config{path_sep}, 

Reply via email to