develooper Front page | perl.perl5.porters | Postings from November 2003

Package/Distribution version format and sorting

Thread Next
From:
Leon Brocard
Date:
November 23, 2003 03:27
Subject:
Package/Distribution version format and sorting
Message ID:
20031123112615.GA12453@kanga.astray.com
Hi.

I'm getting confused about versions and Perl. I'd like your
opinion. More specifically, about the format of versions and how I
should sort them. First off, packages (ie code inside Acme::Buffy and
its $VERSION = "1.3") and CPAN distributions (ie
Acme-Buffy-1.3.tar.gz) are distinct. Right, let's go:

[I'm going to ignore vstrings, as nothing on CPAN uses them other than
for perl version deps]

Exporter.pm says:
    Since the default require_version method treats the $VERSION number as a
    simple numeric value it will regard version 1.10 as lower than 1.9. For
    this reason it is strongly recommended that you use numbers with at
    least two decimal places, e.g., 1.09.

So, "use Foo::Bar qw(1.10)" will just treat the $VERSION in the
package as a numeric floating point value.

ExtUtils::MakeMaker says:
   PREREQ_PM
      Hashref: Names of modules that need to be available to run this
      extension (e.g. Fcntl for SDBM_File) are the keys of the hash and the
      desired version is the value. If the required version number is 0, we
      only check if any version is installed already.

Which really isn't much information at all. However, it does then go
on to say:

      The first line in the file that contains the regular expression

          /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/

      will be evaluated with eval() and the value of the named variable
      after the eval() will be assigned to the VERSION attribute of the
      MakeMaker object. 

which implies that a $VERSION can be pretty much anything (including a
vstring).

00modlist.long.html says:

  To be fully compatible with the Exporter and MakeMaker modules you
  should store your module's version number in a non-my package
  variable called $VERSION. This should be a valid floating point
  number with at least two digits after the decimal (ie hundredths,
  e.g, $VERSION = "0.01"). See Exporter.pm for details

which means that $VERSION should be a floating point number.

It also says:

  Use the number in announcements and archive file names when
  releasing the module (ModuleName-1.02.tar.gz).

... which implies that the distribution number should also just be a
floating point number.

04pause.html says:

  Please, make sure the filename you choose contains a version
  number. For security reasons you will never be able to upload a file
  with identical name again.

... which doesn't say much.

perlmod doesn't say anything. perlmodlib says use floating point.

CPAN.pm has a CPAN::Version package which provides a vcmp, but none of
it is documented. Does it do the right thing?

CPANPLUS uses the same regex from ExtUtils::MakeMaker
(CPANPLUS::Internals::Install), but I think uses floating point for
comparison (can't find).

Thus, if I understand correctly, in order to sort package $VERSIONs, I
should use a numeric sort. Also, in order to sort module distribution
versions, I should also use a numeric sort [ignoring alpha versions
for now]. I should not use Sort::Versions or version.pm for doing
either one.

I understand this properly, I want to clarify this in the docs and
webpages.

Leon
-- 
Leon Brocard.............................http://www.astray.com/
scribot.................................http://www.scribot.com/

... Clap on! (clap, clap) Clap off! (clap@#&$NO CARRIER

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