CPAN Requirements File

二次信任 提交于 2020-01-02 01:21:06

问题


With pip you are able to create a requirements file to specify which libraries to install. Is there an equivalent for perl modules using CPAN?

I came across ExtUtils::MakeMaker, but this seems like the make file is for each module specifically.

I guess to try and give a better idea of what I am asking is if there is a way to do something like

cpan install -r requirements.txt

and then specify which modules to install in that requirements file.

Thanks in advance!


回答1:


I think Carton is what you're looking for.

To start using Carton, install it. Then create a cpanfile with your dependencies:

require 'Test::Most';
require 'Math::BaseConvert';

With this file in place, run

carton install

This will install those modules, if necessary, and write a file called cpanfile.snapshot with dependency information.

Also see: Brief Notes on Managing Perl Dependencies with Carton

PS: Check out Stratopan.




回答2:


When you install modules from CPAN, each module specifies its dependencies in the Makefile.PL (or Build.PL) and the CPAN shell will resolve those dependencies recursively when installing.

If you want to specify dependencies for an application (rather than a CPAN module), you can create a file called cpanfile in this format:

requires 'JSON';
requires 'Template';
requires 'DateTime';
requires 'DBIx::Class';

Then you can install those dependencies with one command:

cpanm --installdeps .

The cpanm command comes from the App::cpanminus distribution and is an alternative tool for installing modules from CPAN.

See the cpanfile docs for more information.



来源:https://stackoverflow.com/questions/31327281/cpan-requirements-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!