develooper Front page | perl.module.build | Postings from April 2007

Multiple packages sharing a single $VERSION

Thread Next
From:
John Peacock
Date:
April 18, 2007 09:26
Subject:
Multiple packages sharing a single $VERSION
Message ID:
462646AE.7040903@rowman.com
I have a couple of distros[1][2] that contain child modules that implement
specific feature (and hence have no life outside of the parent distribution).
Consequently, I want them to always report the same $VERSION as the parent
module.  However, if I use a block like this[1]:

    use base qw(SVN::Notify::Mirror);
    $VERSION = $SVN::Notify::Mirror::VERSION;

this works fine when actually *running* the code, but META.yml comes up with ''
(which resolves to undef as far as CPAN is concerned).  Then I tried to do this:

    use base qw(SVN::Notify::Mirror);
    require SVN::Notify::Mirror; $VERSION = $SVN::Notify::Mirror::VERSION;

but then META.yml picks up the *installed* module's version.

So I applied to following change to Module::Build itself:

=== lib/Module/Build/ModuleInfo.pm
==================================================================
--- lib/Module/Build/ModuleInfo.pm      (revision 2049)
+++ lib/Module/Build/ModuleInfo.pm      (local)
@@ -292,6 +292,7 @@
   my $eval = qq{BEGIN { q#  Hide from _packages_inside()
     #; package Module::Build::ModuleInfo::_version;
     no strict;
+    unshift \@INC, './blib/lib', './blib/arch';

     local $sigil$var;
     \$$var=undef;

and suddenly everything works, except for [2].  It turns out that for these
purposes, the 'require' module must be:

1) Pure Perl with no dependencies (especially if it has a dependency on the
module that we are actually trying to set the $VERSION for, e.g. circular);

2) The module with the $VERSION that is going to be inherited must also contain
the NAME (which is where the abstract comes from), or the Build.PL must manually
contain the abstract.

Is this too risky a patch to apply to Module::Build?  As it turns out, the
change is not needed except to build META.yml (i.e. I can apply that locally and
it isn't needed to build/test on an unpatched M::B).  Is there some other way I
can skin this particular cat?

John

1. http://search.cpan.org/search?query=SVN::Notify::Mirror
2. http://search.cpan.org/search?query=version

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Blvd
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About