Perl-Toolchain-Gang / Module-Metadata

Gather package and POD information from perl module files
http://metacpan.org/release/Module-Metadata/
Other
8 stars 16 forks source link

M::M can't figure out VERSION for Bio::Perl #28

Closed hartzell closed 6 years ago

hartzell commented 6 years ago

[edit, add a link for Bio::Root::Version]

I'd like to use Carton to manage a project that uses Bio::Perl. Unfortunately it fails thusly:

(alice)[14:44:22]blah>>carton install
Installing modules using /Users/hartzell/blah/cpanfile
Successfully installed Module-Build-0.4224
Successfully installed URI-1.72
Successfully installed Sub-Uplevel-0.2800
Successfully installed Test-Warn-0.32
Successfully installed Devel-StackTrace-2.03
Successfully installed Class-Data-Inheritable-0.08
Successfully installed Exception-Class-1.44
Successfully installed Test-Exception-0.43
Successfully installed Test-Deep-1.127
Successfully installed Algorithm-Diff-1.1903
Successfully installed Text-Diff-1.45
Successfully installed Capture-Tiny-0.46
Successfully installed Test-Differences-0.64
Successfully installed Test-Most-0.35
Successfully installed IO-String-1.08
Successfully installed Data-Stag-0.14
Successfully installed BioPerl-1.007002
! Installing the dependencies failed: Missing version info for module 'Bio::Perl'
! Bailing out the installation for /Users/hartzell/blah/.
17 distributions installed
Installing modules failed

The problem is that Bio/Perl.pm doesn't explicitly set VERSION, instead does this:

use Bio::Root::Version '$VERSION';

and Bio::Root::Version has an import statement here that sets the appropriate packages $VERSION. I believe that this is from the pre-dzil days as a way to avoid having to update every file in the tree.

My work-around is to have my project depend on Bio::Root::Version, but that's not really very nice.

I suppose the fix would be to actually eval the module and ask it for it's version (perhaps in a subprocess) but I can imagine that might cause additional problems.

karenetheridge commented 6 years ago

You could not declare a specific Bio::Perl you depend on, if you can get away with that safely. But Bio::Perl needs to declare its version properly for static version detection to work.

karenetheridge commented 6 years ago

There's nothing really to be done here on the Module::Metadata side, so I'm closing this.

hartzell commented 6 years ago

Thanks @karenetheridge!

There were arguments in the Bio::Perl community about this back in the day, it won't change. This (and a companion bug here) are mostly to save the next person (or me, in a year) from wasting time debugging this....

Just out of curiousity, is there a "proper way to declare a version"?

There's always been more than one way to do it (e.g. Chromatics blog post). I get that a static analysis tool can only do so much, but I'm curious if someone has put their foot down.

karenetheridge commented 6 years ago

Chromatic's post is mostly orthogonal to the problem you encountered here. How Module::Metadata (and MM->parse_version, which is an earlier even more dumbed down version of the same strategy) does it is by evaluating the single line of code upon which the declaration is found. That line needs to contain all the information needed to define the version, without depending on an external module to be loaded.

If one did

require Bio::Root::Version; our $VERSION = $Bio::Root::Version::VERSION;

..in a single line this would almost work, except that one cannot guarantee that Bio::Root::Version is installed in the caller's @INC at the time of parsing.

Is it really out of the question for Bio::Perl to update $VERSION declarations as part of the release process? Some distributions do this by incorporating a bump target into their Makefile and ensuring this target is triggered during make release (or whatever other release helper they are using).

hartzell commented 6 years ago

Thanks for the additional detail.

I've raised the issue on the Bio::Perl side and we'll see what comes of it. Worst case, there's a workaround.

Thanks!

cjfields commented 6 years ago

Is it really out of the question for Bio::Perl to update $VERSION declarations as part of the release process? Some distributions do this by incorporating a bump target into their Makefile and ensuring this target is triggered during make release (or whatever other release helper they are using).

@karenetheridge can you point to any specific (non-dzil) examples of this?

haarg commented 6 years ago
cjfields commented 6 years ago

@haarg thanks!