Eric Wilhelm wrote:
Well, I would say that either the documentation is wrong or the ModuleInfo code is wrong because the treatment was always looking at the module/file name in deciding which of however many seen VERSION lines to treat as what.
Not entirely. With the original code, if you didn't pass a module into ModuleInfo::_init, it would open the file, read in any and all packages, then try to find matching $VERSION and package name from the list of packages (@candidates). In my case (and I suspect many other cases), it would find only one package in that file and correctly set the dist version based on that. I think maybe it should be looking for dist_name (if it exists) instead of module_name.
I also note that just setting module_name is not sufficient, and in this case it really should be. I find that I have to set module_name in both the class creator *and* build options, plus the dist_name in the build options (all of which are exactly the same string 'version'). I don't have time right now to dig through that logic, but really, setting module_name once should have been sufficient for such a simple(?) case...
That being said, if I reapply that revision and take out the lines to change the module_name, I find that now both the XS and pure Perl code build just fine; I don't remember now why I thought I needed to set module_name. So maybe your change can stay after all (with clarified documentation). Perhaps something like this:
=== lib/Module/Build/API.pod ================================================================== --- lib/Module/Build/API.pod (revision 2222) +++ lib/Module/Build/API.pod (local) @@ -268,6 +268,10 @@ this process, so there's no real opportunity to change to something better. +If the target file of L</dist_version_from> contains more than one package +declaration, the version returned will be the one matching the configured +L</module_name>. + =item dynamic_config [version 0.07] John