Re: [Module::Build] version.pm and version number comparison problem
Status: Beta
Brought to you by:
kwilliams
|
From: John P. <jpe...@ro...> - 2006-02-02 14:06:34
|
Ron Savage wrote:
> and Text::RecordParser reports itself as being v1.0.0 (yes, with the goddam 'v',
> as if we needed it :-().
ENOTMYFAULT
Larry has spoken that version objects in Perl6 will be numbers with a leading
'v' (whether or not they are implemented in the same fashion as version.pm).
>
> So, I see where the components of the error message (v1.0.0 and 0.02) come from.
>
> My question is: Should this faulty comparison be something which is/can be
> handled properly by version.pm, meaning V 1.0.0 really is reported as being >
> V 0.02, or is this something we have to live with?
The problem is threefold:
1) Module::Build::ModuleInfo::_evaluate_version_line() currently uses version.pm
(if installed) to eval the $VERSION assignment, but then immediately throws away
the version object in preference to the *stringified* version;
2) Module::Build::Base::compare_versions() performs a trivial comparison (not
using the overloaded version comparison if available) of the two versions, which
will not work if the one version has a leading 'v' and multiple decimals;
3) The developers of Module::Build don't want to require version.pm to be
installed (because it requires XS code and I haven't been able to spend the time
to create a pure Perl implementation).
However, happily, I have a solution (diff vs. Module-Build-0.27_07):
--- lib/Module/Build/ModuleInfo.pm.orig 2006-02-02 08:46:21.000000000 -0500
+++ lib/Module/Build/ModuleInfo.pm 2006-02-02 08:59:23.000000000 -0500
@@ -299,7 +299,7 @@ sub _evaluate_version_line {
warn "Error evaling version line '$eval' in $self->{filename}: $@\n" if $@;
# Unbless it if it's a version.pm object
- $result = "$result" if UNIVERSAL::isa( $result, 'version' );
+ $result = $result->numify if UNIVERSAL::isa( $result, 'version' );
return $result;
}
This will render the version object into the equivalent numeric form, which
*will* compare trivially with non-version objects. All M::B tests pass and more
importantly for you, SQL::Translator now accepts the installed version of
Text::RecordParser.
HTH
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747
|