简体   繁体   English

如何在不安装CPAN模块的情况下安装deps?

[英]How do I install deps for CPAN module without installing it?

This is a follow-up to my previous question about developing Perl applications . 这是我之前关于开发Perl应用程序的问题的后续内容 Let's say I develop an application as a CPAN module using Module::Install . 假设我使用Module::Install将应用程序开发为CPAN模块。 Now I upload the code to the production server, say using a git push , and I would like to install the application dependencies listed in Makefile.PL . 现在我将代码上传到生产服务器,比如使用git push ,我想安装Makefile.PL列出的应用程序依赖项。 If I simply run cpan . 如果我只是运行cpan . , the thing tries to install the application like a regular Perl module, ie. ,该东西尝试像常规Perl模块一样安装应用程序,即。 starts to copy the modules and documentation to standard Perl directories all over the system. 开始将模块和文档复制到整个系统的标准Perl目录。

Is this the way it's supposed to be? 这是应该的方式吗? Do you install the application into the standard Perl directories? 您是否将应用程序安装到标准Perl目录中? I am used to having my Perl applications in one directory with separate lib . 我习惯将Perl应用程序放在一个带有单独lib目录中。 Otherwise it seems I'd have to manage a lot of other things, like installing the resources somewhere on path etc. If I just want to install the deps declared in Makefile.PL and run the application tests to make sure everything works, what should I do? 否则,似乎我必须管理很多其他的东西,比如在路径上的某处安装资源等。如果我只想安装在Makefile.PL声明的deps并运行应用程序测试以确保一切正常,那么应该怎样我做?

(Is this documented somewhere? I mean, is there something like best practice for deploying and updating non-trivial Perl applications? Or is everybody doing this his own way?) (这是在某处记录的吗?我的意思是,是否有类似于部署和更新非平凡Perl应用程序的最佳实践?或者每个人都以自己的方式这样做?)

I might be misunderstanding, but I think what you're looking for is 我可能会误解,但我认为你在寻找的是什么

perl Makefile.PL
make installdeps

If you are using Module::Install , you're really using ExtUtils::MakeMaker behind the scenes. 如果你使用的是Module :: Install ,那么你真的在后台使用ExtUtils :: MakeMaker You can use all of the MakeMaker features and the targets it provides. 您可以使用所有MakeMaker功能及其提供的目标。 Although the documentation doesn't show every feature, there are some valuable things to be found in the generated Makefile . 虽然文档没有显示每个功能,但在生成的Makefile可以找到一些有价值的东西。

However, MakeMaker is old news and most everyone has asked Santa Claus for it to disappear. 然而, MakeMaker是一个古老的新闻,大多数人都要求圣诞老人消失。 If you want better control, including creating your own targets and process, Module::Build is orders of magnitude easier to work with as well as cross-platform (even if that just means not using a different make , gmake , or whatever on the same OS on different boxes). 如果你想要更好的控制,包括创建你自己的目标和进程, Module :: Build是更容易使用的数量级以及跨平台(即使这只是意味着不使用不同的makegmake或其他任何东西不同盒子上的相同操作系统)。 If you deviate from the normal, consumer-grade installation process, you're life will be easier without MakeMaker . 如果您偏离正常的消费级安装过程,那么没有MakeMaker ,您的生活将更加轻松。

Some people appreciate the brevity of the Module::Install build file, but once constructed, you don't spend a lot of time messing with your build file so it's not that much of a real benefit. 有些人很欣赏Module::Install构建文件的简洁性,但是一旦构建完成,你就不会花很多时间搞乱你的构建文件,所以它并没有那么多真正的好处。 When the little benefit you get locks you into MakeMaker , it's not a win at all. 当你获得的小利益锁定了MakeMaker ,它根本不是一场胜利。


A 2014 update: Module::Build has now fallen out of favor and needs a maintainer. 2014年更新: Module :: Build现已失宠,需要维护者。 It never quite got to the point where people could use it to build and distribute XS modules. 它从来没有达到人们可以使用它来构建和分发XS模块的程度。 It was deprecated in Perl v5.19 although you can still get it from CPAN. 它在Perl v5.19中已被弃用,尽管您仍然可以从CPAN获取它。

You could look at Module::ScanDeps to generate a list of dependent modules for installing. 您可以查看Module :: ScanDeps以生成用于安装的相关模块列表。 Or Par::Packer for packaging up the whole thing as an "app". 或者Par :: Packer将整个东西打包成“app”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM