develooper Front page | | Postings from April 2007

Multiple packages sharing a single $VERSION

Thread Next
John Peacock
April 18, 2007 09:26
Multiple packages sharing a single $VERSION
Message ID:
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/
--- lib/Module/Build/      (revision 2049)
+++ lib/Module/Build/      (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;

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 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About