如何制作"prereq"的CPAN :: Meta :: Spec需要分发而不是软件包? [英] How to make "prereqs" of CPAN::Meta::Spec require a distribution instead of a package?

查看:116
本文介绍了如何制作"prereq"的CPAN :: Meta :: Spec需要分发而不是软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究如何打包我的一些Perl应用程序并更好地管理它们的依赖关系,以使我和我的客户更轻松地进行分发,这很可能根本不包括上传到CPAN.相反,我会在必要时提供自定义存储库,或者更有可能提供对Subversion之类的SCM的访问.

I'm researching about how to package some of my Perl apps and better manage their dependencies to make distribution easier for me and my customers, which most likely doesn't include uploading to CPAN at all. Instead, I would provide custom repos if necessary or, more likely, access to SCMs like Subversion.

CPAN :: Meta :: Spec 似乎提供了什么我需要描述我的应用程序,它们的依赖性以及从何处获取它们,但是我想知道的是有关先决条件的详细程度. 规范包含以下句子:

CPAN::Meta::Spec seems to provide what I need to describe my apps, their dependencies and even where to get them from, but what I'm wondering is about the level of detail of pre-requisites. The spec contains the following sentence:

关系集必须指定为程序包名称到版本范围的映射.

The set of relations must be specified as a Map of package names to version ranges.

需要的软件包似乎对我的需求来说有点太低了,我宁愿需要发行版. Maven和Gradle之类的水平工具(据我所知)在例如Apache Commons Lang与Apache Commons IO等,而不是单独的类,例如org.apache.commons.lang3.AnnotationUtilsorg.apache.commons.io.ByteOrderMark. OTOH,文档中的示例包含以下几行:

Requiring packages seems a little too low level for my needs, I would prefer requiring distributions instead. Pretty much the level (from my understanding) tools like Maven and Gradle work at, e.g. Apache Commons Lang vs. Apache Commons IO etc. instead of individual classes like org.apache.commons.lang3.AnnotationUtils or org.apache.commons.io.ByteOrderMark. OTOH, the example in the docs contains the following lines:

requires => {
  'perl'          => '5.006',
  'File::Spec'    => '0.86',
  'JSON'          => '2.16',
},

在我看来,包含perl的行不像是一个包,我在系统上的任何地方都找不到package perlperl.pm.在我看来,这种处理方式与示例中的其他内容有所不同.

The line containing perl doesn't look like a package to me and I didn't find some package perl or perl.pm anywhere on my system. Seems to me like that is handled differently to the other things of the example.

我有一个系统范围的文件夹,其中包含一些实用程序包,对我来说似乎可以与某些抽象perl相提并论.该文件夹应被定义为一个发行版,并维护该文件夹中所有软件包的版本号,因此应允许其他应用程序对该整体进行require处理.如果我正确理解了文档,则不仅需要在文件夹中创建META.yml,还需要创建一些其他内容,例如sysutils.pm包含package sysutils;并定义了某些版本.

I have a system wide folder containing e.g. some utility packages, which seems comparable to some abstract perl to me. That folder should get defined as one distribution, maintain a version number for all of the packages in that folder and therefore should allow other apps to require that whole thing. If I understand the docs correctly, I would need to create not only the META.yml in the folder, but additionally some e.g. sysutils.pm containing package sysutils; and defining some version.

是否有某种方法可以避免创建该文件,而实际上仅require发行版本身?

Is there some way to avoid creating that file and really require the distribution itself only?

META.yml已经包含一个名称和版本,因此在理论上看起来有些抽象的东西可能会成为require.我看不到需要添加一个额外的.pm文件来代表发行版本身,而只允许require工作.就我而言,它不包含任何业务逻辑.

The META.yml already contains a name and version on it's own, so looks like some abstract thing one could require in theory. I don't see the need of adding an additional .pm-file representing the distribution itself only to allow require to work. It wouldn't contain any business logic in my case.

谢谢!

推荐答案

那真的不是您想要的.您想预先要求您实际需要.因此,例如,如果您需要File::Spec,那么这就是您所需要的,而不管它是来自perl内核还是来自单独的CPAN发行版.

That's really not what you want to do. You want to pre-req what you actually require. So, for example, if you need File::Spec, that's what you need, regardless of whether it comes from perl core or from a separate CPAN distribution.

我已经看到某些模块从CPAN迁移到核心,反之亦然的情况.通过直接要求该模块,您不必仅因为您所依赖的人更改了他们的分发方法就发布了依赖发行版的新版本.

I've seen cases where certain modules have moved from CPAN to core, or vice versa. By requiring the module directly, you don't need to ship new releases of your dependent distributions simply because someone you depend on changed their method of distribution.

我还看到了某些情况,当确定某些模块作为独立模块很有价值时,它们就会从其原始发行版中分离出来.取决于模块意味着您不再需要为简单的依赖关系而拖入其他模块.

I've also seen cases where certain modules are split off from their original distributions when it was determined they were valuable as standalone modules. Depending on the module means that you no longer drag in a bunch of other modules for a simple dependency.

您正在寻找的或多或少类似于Task::*模块.在大多数情况下,没有真正的逻辑,只是更多依赖项的列表.

What you're more or less looking for is akin to the Task::* modules. No real logic in most of them, just a list of further dependencies.

这篇关于如何制作"prereq"的CPAN :: Meta :: Spec需要分发而不是软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆