develooper Front page | perl.perl5.porters | Postings from January 2008

Dev version numbers, warnings, XS and MakeMaker dont play nicely together.

From:
demerphq
Date:
January 6, 2008 16:54
Subject:
Dev version numbers, warnings, XS and MakeMaker dont play nicely together.
Message ID:
9b18b3110801061654i3e42667escc8b2d0c5609f52b@mail.gmail.com
So we are told the way to mark a module as development is to use an
underbar in the version number:

$VERSION= "1.23_01";

but this will produce warnings if you assert a required version
number, as the version isn't numeric.

So the standard response is to do

$VERSION= eval $VERSION;

on the next line. This means that MakeMaker sees "1.23_01" but Perl
internal code for doing version checks sees "1.2301". This is all fine
and dandy with pure perl modules.

BUT, if the module is "bog standard" and uses XS this is a recipe for
a fatal error. XS_BOOT_VERSIONCHECK will compare "1.23_01" to "1.2301"
and decide that they are different versions and die.

The solution I came up with was to add

  XS_VERSION=> eval MM->parse_version("Filename"),

to the WriteMakefile() call in the Makefile.PL.

But to me this is unsatisfactory. It means either duplicating code
because there is normally something like:

  VERSION_FROM => "DB_File.pm"

or something like it in the WriteMakefile() arguments. Even if you use
a variable so that you end up with

$file= "DB_File.pm";
WriteMakefile(
  XS_VERSION=> eval MM->parse_version($file),
  VERSION_FROM => $file,
...
);

you are still duplicating effort, essentially parsing the version
twice, no biggie really in terms of CPU cycles, but somewhat
distasteful nevertheless.

I thought of fixing XS_BOOT_VERSIONCHECK so that when there is a
mismatch it checks for an underbar and then evals the string first,
but this didnt seem either fun (its C code after all) or really all
that great a solution since on older perls it wouldnt help at all.

About the best thing I can think of is making it so that the version
checked in XS_BOOT_VERSIONCHECK is ALWAYS numeric. IOW, MakeMaker
should do the eval trick itself.  I think that this would work out,
but im not sure of the ramifications. (its late).

Anyway, i welcome any thoughts anyone might have on this.

Ive cross posted this because I think this is as much a Perl core dev
issue as it is a Quality Assurance issue as well as a MakeMaker issue.
I apologise if this irritates anyone.

Cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"



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