[MetaCPAN] Getting verison numbers for provided modules

Buddy Burden barefootcoder at gmail.com
Wed May 5 23:59:38 GMT 2021


Olaf,

> We’ve been trying to get the mailing list removed, so this may be one of the last messages on it.

Aww, that's a shame.  While there are some issues that SO is good for, and there are some issues that IRC[1] is good for, I 
do still believe there's some issues where a mailing list is the best option, so I'm sad to see it go.  But I understand that 
the world moves on.

> You could use the API to solve this problem, but I think you can do it more easily with something like https://metacpan.org/pod/OrePAN2 Check out the examples. Basically just inject the tarballs you need into your minicpan and then run the indexer. You’ll then have an 02packages containing all of the modules + versions which you just injected. I think this should solve your problem?

Well, primarily for the benefit of people in the future reading this on the archive pages ...

This is a classic chicken-and-egg issue.  I'm trying to figure out whether I need to install a module or not; if I have to 
install it to figure that out, it sort of defeats the purpose. :-/  I could go into more detail, but a dying mailing list is 
neither the time nor place. :-D

Your suggestion of looking at OrePAN2's code was spot on, though ... I did remember to go looking at DarkPAN modules to see 
how they built 02packages.details.txt, but I iniitially had forgotten there were two versions and ended up looking at 
OrePAN's code, which was ... not encouraging. :-/  But then I remembered about OrePAN2[2] and its code was way more 
instructive.  So my approach will be twofold:

1) Use Module::Load::Conditional's `check_install` to see if the module is installed or not.  If it's not, I don't really 
care about what version I say I need for the module: it needs to get installed anyway.  So I'll just use my (current) trick 
of pretending that all modules in a dist have the same version.

2) If it _is_ installed, then get version numbers the same way OrePAN2 does it: using Parse::LocalDistribution.[3]

I was really hoping that the answer wasn't something this annoyingly tricky, but it is what it is.  Thx Olaf for all you do!


		-- Buddy


[1] Or I suppose it's mostly Slack, these days ...
[2] Which is part of our DarkPAN solution, so thank you Olaf for your hard work on that module!
[3] Obviously Olaf already knows this, but, again for the benefit of posterity: technically OrePAN2 only uses 
Parse::LocalDistribution after first checking the META file(s), very similarly to how Carton does it for building snapshots. 
This _might_ be a useful shortcut for short-circuiting a full dist file scan like Parse::LocalDistribution does, but so few 
dists put a `provides` in their META files that I'm not sure it's worth the extra layer of complexity for my purposes. 
Perahps I'll try it both ways to see what the actual speed difference is.



More information about the MetaCPAN mailing list