Re^3: $VERSION in module files
by tobyink (Canon) on Mar 26, 2020 at 16:04 UTC
|
I usually use perl-reversion for changing all the version numbers for every module in a distribution.
| [reply] |
|
| [reply] [d/l] [select] |
|
| [reply] [d/l] |
Re^3: $VERSION in module files
by hippo (Bishop) on Mar 26, 2020 at 11:14 UTC
|
Not necessarily. If you maintain a version number for the dist which applies also to all the modules then you can pick one master module which all the others use and have them set their versions from that one. eg.
package Foo;
our $VERSION = '1.01';
# ...
package Foo::Bar;
use Foo;
our $VERSION = $Foo::VERSION;
I never bother specifying version numbers in POD so you're on your own there. :-) Doubtless there's a way in Dist::Zilla but then you'd have $problems++
| [reply] [d/l] [select] |
|
If you specify the module version like this, it won't be picked up by tools like ExtUtils::MakeMaker, and won't be properly indexed on CPAN by PAUSE. The version needs to be specified by a single line, and won't be able to load modules from the current distribution.
| [reply] |
|
package Foo;
our $VERSION = '1.01';
# ...
package Foo::Bar;
use Foo;
our $VERSION = $Foo::VERSION;
If that's in a single file that may work, I'm not sure, however, I suspect at least some of the tools that rely on a static parse won't be able to handle that.
| [reply] [d/l] |
|
my $release = '1.01';
my %MF = (
META_MERGE => {
'meta-spec' => { version => 2 },
provides => {
'Foo' => {
file => 'lib/Foo.pm',
version => $release
},
'Foo::Bar' => {
file => 'lib/Foo/Bar.pm',
version => $release
},
},
},
# ...
};
WriteMakefile (%MF);
So the version is specified explicitly twice: once in the Makefile.PL and once in the master module. If there's a reliable way to specify it explicitly only once that would be good to know.
| [reply] [d/l] |
|
|
|
|
Not necessarily. If you maintain a version number for the dist which applies also to all the modules then you can pick one master module which all the others use and have them set their versions from that one. eg.
inheriting a version number is like inheriting your fathers age/birthdate
yeah my wife just gave birth to a beautiful baby, 9lbs, 32 years old
| [reply] [d/l] |
|
| [reply] |
|
|
|
Re^3: $VERSION in module files
by pryrt (Abbot) on Mar 26, 2020 at 13:15 UTC
|
In Win32::Mechanize::NotepadPlusPlus, I added a rule in my Makefile.PL postamble, so that make populateversion will take the VERSION that the Makefile sees (which it grabs from the "primary" module in the dist, thanks to $mm_args{VERSION_FROM} ), and uses perl to do an in-place edit of the our $VERSION =... from the related modules.
# auto-populate the VERSION in the submodules from $(VERSION), which c
+omes from main module
populateversion :: lib/Win32/Mechanize/NotepadPlusPlus.pm
$(NOECHO) $(ECHO) want to auto-populate VERSION in all sub-modules
+: $(VERSION)
$(PERL) -pi -e "s/^(\s*our\s+.VERSION\s*=).*?;.*?$$/\1 '$(VERSION)
+'; # auto-populated from W::M::NPP/" lib/Win32/Mechanize/NotepadPlusP
+lus/Notepad.pm lib/Win32/Mechanize/NotepadPlusPlus/Editor.pm
So I just have to change the version in one master location, and then make populateversion (or, since I have other rules that depend on that rule, run one of those other rules for doing other documentation updates) to get the version in sync across the modules. | [reply] [d/l] [select] |