Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: $VERSION in module files

by bliako (Monsignor)
on Mar 26, 2020 at 10:46 UTC ( [id://11114667]=note: print w/replies, xml ) Need Help??


in reply to Re: $VERSION in module files
in thread $VERSION in module files

OK thanks. So, I must have a $VERSION var in EACH (package) file in the module. I must change those $VERSION strings manually each time. And I must change POD versions manually too. Right?

Replies are listed 'Best First'.
Re^3: $VERSION in module files
by tobyink (Canon) on Mar 26, 2020 at 16:04 UTC

      perl-reversion works for me. It changed both our $VERSION and POD versions. Worrying thing is that it scanned bash files too... (just tried inserting a VERSION=0.21 in a bash script and perl-reversion bumped that version too. Definetely good to know but perhaps a bit dangerous.)

        You can give it a list of files and directories to limit what it scans. Hopefully if you do perl-reversion --bump bin/*.pl lib it'll only be finding Perl files.

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++

      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.

      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.

        For the static parse I rely on the "provides" list in the metadata. For the above example the Makefile.PL includes something like this:

        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.

      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

        Yes and no. It can also be like having different birthdays for your limbs. It might make sense for a peg leg, but mostly unnecessary.

        Depends on how interdependent the modules are.

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114667]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found