如何为不同的 Perl 应用程序安装专门的环境? [英] How can I install specialized environments for different Perl applications?

查看:40
本文介绍了如何为不同的 Perl 应用程序安装专门的环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在功能方面是否有与 Python 的 virtualenv,但是对于 Perl 呢?

Is there anything equivalent or close in terms of functionality to Python's virtualenv, but for Perl?

我已经用 Python 进行了一些开发,并且可以在单独的环境中安装非系统版本的模块而不会造成任何混乱,这是一个巨大的优势.现在我必须在 Perl 中处理一个新项目,并且我正在寻找类似 virtualenv 的东西,但是对于 Perl.你能推荐任何 Perl 等价物或替代物来代替 python 的 virtualenv 吗?

I've done some development in Python and a possibility of having non-system versions of modules installed in a separate environment without creating any mess is a huge advantage. Now I have to work on a new project in Perl, and I'm looking for something like virtualenv, but for Perl. Can you suggest any Perl equivalent or replacement for python's virtualenv?

我正在尝试为要部署的 Y 个不同应用程序设置 X 组不同的非系统 Perl 包.更糟糕的是,这些应用程序可能需要相同包的不同版本,因此它们中的每一个都可能需要安装在单独的模块/库环境中.您可能希望为 X <手动执行此操作.Y<3. 但是您不应该手动为 10 > Y > X 执行此操作.

I'm trying to setup X different sets of non-system Perl packages for Y different applications to be deployed. Even worse, these applications may require different versions of the same package, so each of them may require to be installed in a separate module/library environment. You may want to do this manually for X < Y < 3. But you should not do this manually for 10 > Y > X.

理想情况下,我正在寻找的应该是这样的:

Ideally what I'm looking should work like this:

perl virtualenv.pl my_environment
. my_environment/bin/activate
wget http://.../foo-0.1.tar.gz
tar -xzf foo-0.1.tar.gz ; cd foo-0.1
perl Makefile.pl
make install # <-- package foo-0.1 gets installed inside my_environment
perl -MCPAN -e 'install Bar' # <-- now package Bar with all its deps gets installed inside my_environment

推荐答案

有一个工具叫做 local::lib 为您完成所有工作,很像 virtualenv.它会:

There's a tool called local::lib that wraps up all of the work for you, much like virtualenv. It will:

  • 在使用过程中设置@INC.
  • 为子进程设置 PERL5LIB 和其他类似的东西.
  • 设置正确的变量以说服 CPAN,MakeMakerModule::Build 等安装库并将配置存储在本地目录中.
  • 设置 PATH 以便可以找到已安装的二进制文件.
  • 从命令行使用时将环境变量打印到标准输出,以便您可以输入 eval $(perl -Mlocal::lib)在您的 .profile 中,然后几乎忘记它.
  • Set up @INC in the process where it's used.
  • Set PERL5LIB and other such things for child processes.
  • Set the right variables to convince CPAN, MakeMaker, Module::Build, etc. to install libraries and store configuration in a local directory.
  • Set PATH so that installed binaries can be found.
  • Print environment variables to stdout when used from the commandline so that you can put eval $(perl -Mlocal::lib) in your .profile and then mostly forget about it.

这篇关于如何为不同的 Perl 应用程序安装专门的环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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