-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ my %parms = ( | |
NAME => 'ack', | ||
AUTHOR => 'Andy Lester <[email protected]>', | ||
ABSTRACT => 'A grep-like program for searching source code', | ||
VERSION_FROM => 'lib/App/Ack.pm', | ||
VERSION => _version_from( 'lib/App/Ack.pm' ), | ||
LICENSE => 'artistic_2', | ||
MIN_PERL_VERSION => 5.010001, | ||
META_MERGE => { | ||
|
@@ -55,6 +55,20 @@ my %parms = ( | |
|
||
WriteMakefile( %parms ); | ||
|
||
# VERSION_FROM in MakeMaker can't handle version objects. | ||
sub _version_from { | ||
my $file = shift; | ||
|
||
open( my $fh, '<', $file ) or die "Can't open $file: $!"; | ||
my ($line) = grep { /^\s*\$VERSION\s+=/ } <$fh>; | ||
close $fh; | ||
|
||
die "Couldn't find a version line in $file" unless $line; | ||
$line =~ /^\s*\$VERSION\s+=\s+(v3\.\d+\.\d+);/ or die "Can't parse VERSION on this line: $line"; | ||
|
||
return $1; | ||
} | ||
|
||
package MY; | ||
|
||
# Suppress EU::MM test rule. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use bare vstrings as versions. Always quote them. EUMM should handle it fine.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bare v-strings are inappropriate as module versions. They don't print correctly or compare numerically. A string in this form is correctly used since 5.10.1 at least. See http://blogs.perl.org/users/grinnz/2018/04/a-guide-to-versions-in-perl.html. I would instead ask, why use them, necessitating such a workaround?
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't debating you. I asked "why" because you said "Do X" without explanation.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. It gets tiring explaining version issues after a while. Hope the blog post is helpful.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the post a number of times now and I still don't understand why you're saying that the quoted strings is better.
What I'm seeing here is that
$^V
itself is a v-string, and that the version with the strings and string comparisons doesn't compare correctly like the v-string version does.What am I missing?
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$^V
is not a v-string (except before 5.10), it is a version.pm object. Version objects are how you correctly compare both numerically and string. Otherwise people expect numeric comparisons to work and they don't, in either case - this is just because numeric comparisons are a mistake unless you have version.pm objects, not vstrings. The difference is that v-strings don't print, EUMM doesn't understand them (as you found), they are surprisingly unintuitive. They are turned into version.pm objects by UNIVERSAL::VERSION otherwise they wouldn't work at all. A string in the form 'vX.Y.Z' is used correctly by everything since 5.10. There is no benefit and several downsides to vstrings.b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everyone only used version.pm objects and UNIVERSAL::VERSION and never touched $Package::VERSION directly, vstrings could be acceptable though still weird. But people generally expect direct printing and numerical comparison to work, and even though you can't get the latter to work unless you use version objects, a string means printing will work at least. The more consistently people use the most useful forms, the more useful they will be.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also seems the vstring caused PAUSE to fail to index it as a newer version: https://cpanmeta.grinnz.com/packages?module=app%3A%3Aack&match_mode=prefix
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm not sure, that may be because the first
our $VERSION
line does not contain the assignment. The PAUSE email should indicate...b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where I'm stuck. You say that a "string in the form 'vX.Y.Z' is used correctly by everything" but yet
gives me "Bad". That doesn't seem like doing the right thing.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you expect string comparison to be correct for versions?
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I thought that's what the whole point of version strings was, so that we could compare v3.6.5 to v3.10.1 and have it do the right thing.
As
perldata
says:b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the point of vstrings, yes. I don't see how that's useful for module versions, since it's not expected, and it means other things don't work.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to boil this down, you're stating "You don't need the magic of vstrings in a module version, and the indexing tools get confused by them, so don't use them."
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, with the addition that they also confuse humans.
b3c43d4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've released v3.1.3. Thanks for the pointers. See 457f3e3