Re: [Module-build-general] [BUG] ./Build dist problem with scanning for packages
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-07-07 22:09:54
|
On Monday, July 7, 2003, at 04:36 PM, Ken Williams wrote:
>
> On Monday, July 7, 2003, at 02:30 PM, Dave Rolsky wrote:
>
>> Ok, I just found a somwhat serious bug in the 0.18_04 release, and I
>> think
>> it's still present in the CVS version.
>>
>> If I run "./Build dist" on a new distro, it tries to load all the .pm
>> files in the MANIFEST file and scan them for packages via
>> Module::Info.
>>
>> But if you've never installed the distro at hand, then loading the
>> various
>> module may fail unless the ./lib (or equivalent) directory is
>> included in
>> your lib path.
>>
>> I'm not sure if this is a new bug or if I've just not used
>> Module::Build
>> for an entirely new module, which is what provoked the problem.
>
> Argh, you're right. I wish Module::Info could override CORE::use() or
> something so it wouldn't have to run any other modules to get the > info.
So, now I'm checking the following patch into CVS. What do you think?
It at least doesn't have that *particular* problem anymore. :-/
-Ken
Index: Build.PL
===================================================================
RCS file: /cvsroot/module-build/Module-Build/Build.PL,v
retrieving revision 1.25
diff -u -r1.25 Build.PL
--- Build.PL 1 Jul 2003 23:33:27 -0000 1.25
+++ Build.PL 7 Jul 2003 22:08:37 -0000
@@ -31,7 +31,6 @@
'Archive::Tar' => '1.00',
'ExtUtils::Install' => 0.30,
'ExtUtils::ParseXS' => 2.02,
- 'Module::Info' => 0,
# Module::Signature => 0.21, # Our support isn't good enough yet
},
build_requires => {
Index: Changes
===================================================================
RCS file: /cvsroot/module-build/Module-Build/Changes,v
retrieving revision 1.105
diff -u -r1.105 Changes
--- Changes 7 Jul 2003 16:37:27 -0000 1.105
+++ Changes 7 Jul 2003 22:08:38 -0000
@@ -10,6 +10,12 @@
locate object method "format_compiler_cmd"'.
(http://rt.cpan.org/Ticket/Display.html?id=2391)
+ - We now don't depend on Module::Info to scan for packages during the
+ 'dist' action anymore, because it's way too aggressive about
+ loading other modules that you may not want loaded. We now just
+ (ick, yuck) scan the .pm files with a regular expression to find
+ "package Foo::Bar;" statements.
+
0.18_03
- Added support for the 'install_path' parameter, which allows custom
Index: lib/Module/Build/Base.pm
===================================================================
RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v
retrieving revision 1.139
diff -u -r1.139 Base.pm
--- lib/Module/Build/Base.pm 7 Jul 2003 02:39:13 -0000 1.139
+++ lib/Module/Build/Base.pm 7 Jul 2003 22:08:40 -0000
@@ -1370,23 +1370,26 @@
foreach my $file (@pm_files) {
next if $file =~ m{^t/}; # Skip things in t/
- return unless $] >= 5.006; # perl 5.6 required for Module::Info
- return unless eval "use Module::Info 0.19; 1";
-
my $localfile = File::Spec->catfile( split m{/}, $file );
my $version = $self->version_from_file( $localfile );
-
- print "Scanning $localfile for packages\n";
- my $module = Module::Info->new_from_file( $localfile );
-
- foreach my $package ($module->packages_inside) {
- $out{$package} = {
- file => $file,
- version => $version,
- };
+
+ foreach my $package ($self->_packages_inside($localfile)) {
+ $out{$package}{file} = $file;
+ $out{$package}{version} = $version if defined $version;
}
}
return \%out;
+}
+
+sub _packages_inside {
+ # XXX this SUCKS SUCKS SUCKS! Damn you perl!
+ my ($self, $file) = @_;
+ my $fh = IO::File->new($file) or die "Can't read $file: $!";
+ my @packages;
+ while (defined(my $line = <$fh>)) {
+ push @packages, $1 if $line =~ /^[\s\{;]*package\s+([\w:]+)/;
+ }
+ return @packages;
}
sub make_tarball {
|