使用 Dist::Zilla 声明对特定版本的 Perl 模块的依赖
Declaring dependencies on specific versions of Perl modules using Dist::Zilla
我一直在为一个工作项目使用 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 uses CPAN::Meta::Spec to do the prereqs. That doc describes the syntax in the 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, != 1.5, < 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, != 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.
完全相同
上面的 simbaque 几乎是正确的,剩下的就是 Fabrice Gabolde(我不知道如何 link 命名)。
实现方式:
[Prereqs]
Plack = >= 1.000, < 2.000
Other::Module = == 1.0
Other::Other::Module = >= 1.2, != 1.5, < 2.0
预计到达时间:simbaque 已经更正了他们的答案;留给子孙后代。
我一直在为一个工作项目使用 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 uses CPAN::Meta::Spec to do the prereqs. That doc describes the syntax in the 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, != 1.5, < 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, != 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.
完全相同上面的 simbaque 几乎是正确的,剩下的就是 Fabrice Gabolde(我不知道如何 link 命名)。
实现方式:
[Prereqs]
Plack = >= 1.000, < 2.000
Other::Module = == 1.0
Other::Other::Module = >= 1.2, != 1.5, < 2.0
预计到达时间:simbaque 已经更正了他们的答案;留给子孙后代。