加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

使用Dist :: Zilla声明对特定版本的Perl模块的依赖性

发布时间:2020-12-16 06:21:14 所属栏目:大数据 来源:网络整理
导读:我一直在使用Dist :: Zilla进行工作,我已经在[Prereqs / Requires]部分声明了所有依赖项.到目前为止这很好. 现在我发现我的一个依赖项的最新版本打破了向后兼容性,所以我想限制我依赖的版本范围.像cpanm支持的东西: # from perldoc cpanmcpanm Plack~"= 1.0
我一直在使用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"

或者模块::构建:

'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 particular
version(s) of some other module that may be required as a
prerequisite. This section details the Version Range type used to
provide this information.

The simplest format for a Version Range is just the version number
itself,e.g. 2.4. This means that at least version 2.4 must be
present. To indicate that any version of a prerequisite is okay,even
if the prerequisite doesn’t define a version at all,use the version
0.

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.0
means that any version of the prerequisite less than 2.0 is suitable.

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

所以你的先决条件将成为:

[Prereqs]
Plack = >= 1.0000,< 2.0000
Plack = == 0.9990
Other::Module = >= 1.2,< 2.0

请注意,single =将模块名称(键)与版本或版本范围(值)分开.

这些版本意味着:

>

>= 1.0000,< 2.0000

大于或等于1.0000且小于2.0000
>

== 0.9990

完全版本0.9990
>

= 1.2,< 2.0

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读