gpt4 book ai didi

perl - 使用 Dist::Zilla 声明对特定版本的 Perl 模块的依赖关系

转载 作者:行者123 更新时间:2023-12-04 18:29:59 26 4
gpt4 key购买 nike

我一直在工作项目中使用 Dist::Zilla,并且我已经在 [Prereqs / Requires] 中声明了我的所有依赖项。部分。到目前为止很好。

现在我发现我的一个依赖项的最新版本破坏了向后兼容性,所以我想限制我依赖的版本范围。类似于 cpanm支持:

# from perldoc cpanm
cpanm Plack~">= 1.0000, < 2.0000" # latest of 1.xxxx
cpanm Plack@0.9990 # specific version. same as Plack~"== 0.9990"

Module::Build :
'Other::Module' => '>= 1.2, != 1.5, < 2.0',

一般来说,我如何使用 Dist::Zilla 声明这种类型的依赖关系?

最佳答案

Dist::Zilla::Prereqs使用 CPAN::Meta::Spec 来做先决条件。该文档描述了 Version Ranges 中的语法。章节。

Some fields (prereq, optional_features) indicate the particularversion(s) of some other module that may be required as aprerequisite. This section details the Version Range type used toprovide this information.

The simplest format for a Version Range is just the version numberitself, e.g. 2.4. This means that at least version 2.4 must bepresent. To indicate that any version of a prerequisite is okay, evenif the prerequisite doesn't define a version at all, use the version0.

Alternatively, a version range may use the operators < (less than), <=(less than or equal), > (greater than), >= (greater than or equal), ==(equal), and != (not equal). For example, the specification < 2.0means that any version of the prerequisite less than 2.0 is suitable.

For more complicated situations, version specifications may be AND-edtogether using commas. The specification >= 1.2, != 1.5, < 2.0indicates a version that must be at least 1.2, less than 2.0, and notequal to 1.5.


所以你的先决条件会变成:
[Prereqs]
Plack = >= 1.0000, < 2.0000
Plack = == 0.9990
Other::Module = >= 1.2, != 1.5, < 2.0
注意单 =将模块名称(键)与版本或版本范围(值)分开。
这些版本意味着:

  • >= 1.0000, < 2.0000


    大于或等于 1.0000 且小于 2.0000

  • == 0.9990


    正是版本 0.9990

  • = 1.2, != 1.5, < 2.0


    大于或等于 12 而不是 1.5 且小于 2.0

  • 如您所见,这与 cpanfile 或 Module::Build 完全相同。

    关于perl - 使用 Dist::Zilla 声明对特定版本的 Perl 模块的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40173743/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com