develooper Front page | perl.module-authors | Postings from August 2021

How to handle minimum versions of dependencies which are recommendedbut not required?

Thread Next
From:
Diab Jerius
Date:
August 8, 2021 19:35
Subject:
How to handle minimum versions of dependencies which are recommendedbut not required?
Message ID:
657929f3-8363-5321-43de-f6ec7c505717@cpan.org
Howdy!

I've a module 
(https://metacpan.org/release/DJERIUS/Data-Record-Serialize-0.27-TRIAL) 
which may use JSON and YAML writers.

For JSON, I use JSON::MaybeXS.  Cpanel::JSON::XS >= 3.0236 is required.

My code can use either YAML::XS or YAML::PP.  YAML::XS  >= 0.67 is required.

Since JSON & YAML output are optional, I've encoded the XS dependencies 
as runtime recommendations, rather than requirements. JSON::MaybeXS is 
specified as a runtime dependency (as is YAML::PP, but that's a mistake; 
it should also be a runtime recommendation).

Here are the relevant bits of  META.json 
(https://metacpan.org/release/DJERIUS/Data-Record-Serialize-0.27-TRIAL/source/META.json#L98)

|||"runtime"| |: {|
|||"recommends"| |: {|
|||"Cpanel::JSON::XS"| |: ||"3.0236"||,|
|||"JSON::PP"| |: ||"0"||,|
|||"YAML::XS"| |: ||"0.67"|
|||},|
|||"requires"| |: {|
|||"JSON::MaybeXS"| |: ||"0"||,|
|||"YAML::PP"| |: ||"0"||,|
|||}|
|||},|

Here's the problem, illustrated by this CPAN testers failure:

    http://www.cpantesters.org/cpan/report/2f961e48-6bf6-1014-90df-a468c69b7236

The smoker has versions of Cpanel::JSON::XS and YAML::XS which are older 
than my required versions.  Since the ::XS versions are prioritized over 
the ::PP versions, the code uses those and thus fails the tests.   I 
presume that because the ::XS versions are recommendations rather than 
requirements, they weren't updated to the versions that the code requires.

Is there some way of triggering an update to the required versions via 
the metadata, or should I put a runtime version check into the tests and 
skip if the appropriate versions aren't installed?

For production runs, I'll have to add a runtime check in the code which 
falls back to YAML::PP if the version of YAML::XS is too old, but I 
don't see how I can do that with JSON::MaybeXS, as there are no hooks to 
indicate acceptable versions of the backend.  I think my only option is 
to take the same approach as for YAML, namely manually specifying which 
backend libraries are acceptable.  I don't like this, as now I can't 
automatically take advantage of JSON::MaybeXS's list of backends.

Any advice on how to gracefully handle this situation?

Thanks,

Diab




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About