分发 Perl 应用程序
我最近创建了一个小型 Perl 应用程序,它使用了一些需要通过 CPAN 安装的非核心模块。
有没有一种方法可以分发应用程序,并能够检查是否安装了所需的模块,如果没有安装,则从 CPAN 中提取它们?我想我正在寻找类似于 CPAN 自动依赖项安装功能的东西。
我考虑过使用 module-starter 和 Module::Install 创建一个类似模块的目录结构,然后定制构建文件以将应用程序安装到 /bin...但我不确定这是否是一个鞋拔子解决方案。
I recently created a little Perl application that utilizes a few non-core modules that will need to be installed via CPAN.
Is there a way to distribute the application with the ability to check to see if the required modules are installed and pull them from CPAN if they aren't? I suppose I am looking for something similar to the CPAN auto-dependency-install feature.
I thought about using module-starter and Module::Install to create a module-like directory structure and then tailor the Build file to install the application to /bin... but I'm not sure if this is a shoe-horn solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个鞋拔子解决方案,而是正确的做法。由于特殊情况,您应该让专门的工具处理依赖关系,例如在安装说明中写入:
cpan .
。您无需更改构建文件即可将程序安装在
bin
目录中,默认情况下会这样做。It's not a shoe-horn solution, but the Right Thing to do. You should let a specialised tool handle the dependencies because of the corner cases, e.g. write in the installation instructions:
cpan .
in the unarchived directory.You need not change the Build file to install programs in the
bin
directory, it does this by default.您可以轻松检查某个模块是否存在,并a)尝试安装它并退出/重新启动应用程序b)croak/die。 (就像上面的代码片段中的那样)
您还可以附加要打包的模块,将它们解压到某个目录,并将该目录推送到开始块中的@INC。
You can easily check if certain module is present and a)try to install it and exit/restart application b)croak/die. (sth like in the code snippet above)
You can also attach the modules you want to package, extract them to a certain directory, and push the dir to @INC in the begin block.