Perl中的核心,供应商和站点位置之间有什么区别? [英] What is the difference between the core, vendor and site locations in Perl?

查看:60
本文介绍了Perl中的核心,供应商和站点位置之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在安装某些模块时遇到了麻烦,令我惊讶的是,许多已安装的模块具有重复的安装和版本。尝试使用 cpanm 跟踪标准安装(如果有这样的事情)中东西的位置,我发现以下结果非常令人困惑。

I recently ran into some trouble installing some modules and discovered to my surprise that many of the modules that had been installed, have duplicated installations and versions. Trying to track where stuff goes in a standard (if there is such a thing) installation using cpanm, I found the following results very confusing.

报告显示以下位置:


  • 使用 cpan -V

  • Using cpan -V:
# cpan -V

/usr/bin/cpan script version 1.672, CPAN.pm version 2.22
--------------------------------------------------
Checking install dirs...
Checking core
        + /usr/share/perl5/5.26
        + /usr/lib/perl5/5.26/x86_64-cygwin-threads
Checking vendor
        + /usr/share/perl5/vendor_perl/5.26
        + /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
Checking site
        + /usr/local/share/perl5/site_perl/5.26
        + /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
Checking PERL5LIB
        no directories for PERL5LIB
Checking PERLLIB
        no directories for PERLLIB




  • 使用 perl -V :。* site。*

    • Using perl -V:.*site.*:
    • # perl -V:.*site.* |column -t -s "=" |sort -d -i -k 1.22
      
      d_sitearch           'define';
      usesitecustomize     'undef';
      siteprefix           '/usr/local';
      siteprefixexp        '/usr/local';
      installsitebin       '/usr/local/bin';
      installsitescript    '/usr/local/bin';
      sitebin              '/usr/local/bin';
      sitebinexp           '/usr/local/bin';
      sitescript           '/usr/local/bin';
      sitescriptexp        '/usr/local/bin';
      installsitearch      '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
      sitearch             '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
      sitearchexp          '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
      installsitehtml1dir  '/usr/local/share/doc/perl/html/html1';
      sitehtml1dir         '/usr/local/share/doc/perl/html/html1';
      sitehtml1direxp      '/usr/local/share/doc/perl/html/html1';
      installsitehtml3dir  '/usr/local/share/doc/perl/html/html3';
      sitehtml3dir         '/usr/local/share/doc/perl/html/html3';
      sitehtml3direxp      '/usr/local/share/doc/perl/html/html3';
      installsiteman1dir   '/usr/local/share/man/man1';
      siteman1dir          '/usr/local/share/man/man1';
      siteman1direxp       '/usr/local/share/man/man1';
      installsiteman3dir   '/usr/local/share/man/man3';
      siteman3dir          '/usr/local/share/man/man3';
      siteman3direxp       '/usr/local/share/man/man3';
      installsitelib       '/usr/local/share/perl5/site_perl/5.26';
      sitelib              '/usr/local/share/perl5/site_perl/5.26';
      sitelib_stem         '/usr/local/share/perl5/site_perl/5.26';
      sitelibexp           '/usr/local/share/perl5/site_perl/5.26';
      




      • 使用 @INC

        • Using @INC:
        • # perl -e 'print join("\n",@INC,"")'
          
          /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
          /usr/local/share/perl5/site_perl/5.26
          /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
          /usr/share/perl5/vendor_perl/5.26
          /usr/lib/perl5/5.26/x86_64-cygwin-threads
          /usr/share/perl5/5.26
          

          结果是 cpan-outdated -p --verbose 显示的过期模块列表与 cpan -lO 可以。不用说,模块安装在各处,我不知道如何了解是否存在默认安装位置及其默认位置,或者应该去。

          The result is that cpan-outdated -p --verbose show a completely different (and shorter) list of outdated modules than what cpan -lO does. Needless to say, modules are installed all over the place and I don't see how to understand if there is a default install location and where it goes, or should go.

          问题


          1. 那么核心供应商网站路径的类型

          2. 为什么每种类型都有2条路径?

          1. So what is the difference between the core, vendor and site type of paths?
          2. Why are there 2 paths in each type?


          推荐答案

          这些安装位置的最佳参考可能是 ExtUtils :: MakeMaker 文档将其安装在何处。本质上:

          The best reference for these install locations is probably the ExtUtils::MakeMaker documentation for where it installs things. In essence:


          • 核心 (也称为 privlib )-与Perl一起安装的核心模块所在的位置。在版本5.12之前的Perls上,还需要在此处通过核心版本安装对双生命模块的更新,而不是站点或供应商lib,因为privlib首先出现在 @INC 中。在5.12之前。在系统Perl中,这尤其危险,在该系统中,privlib中的文件通常由包管理器管理。

          • 供应商 -发行商可以在其中安装模块。通常是系统软件包管理器将非核心模块安装到的位置。

          • 站点 -CPAN的位置客户端会在直接调用时将模块安装到,除非像上面提到的双寿命模块那样禁止不正常的配置。

          • core (also known as privlib) - is where core modules that are installed with Perl goes. On Perls older than 5.12, updates to dual-life modules also need to be installed here over the core versions instead of into site or vendor lib, because privlib came first in @INC before 5.12. This is especially dangerous in a system Perl where the files in privlib are usually managed by a package manager.
          • vendor - is where a distribution vendor may install modules to. This is usually where system package managers install non-core modules to.
          • site - is where CPAN clients install modules to when invoked directly, barring unusual configuration like for dual-life modules as mentioned above.

          (双寿命模块是核心模块,这些模块也可以在CPAN上单独获得,这意味着您可以安装更新的版本。)

          (Dual-life modules are core modules which are also available separately on CPAN, which means that you can install an updated version.)

          每个这些lib位置都有一个 arch 变体,它是带有特定于构建的输出文件的发行版的安装位置。没有动态配置的纯Perl发行版将安装到标准体系结构不可知的目录中,并且只要满足其要求,通常就可以在其他Perl和体系结构安装中以未修改的方式运行(尽管这不是一个好主意,除非您真的知道自己是什么)在做)。 具有任何已编译XS模块或在构建过程中动态生成模块的发行版都安装在 arch 目录中,因此不能从其他Perl中安全使用。

          Each of these lib locations have an arch variant, which is where distributions with build-specific output files are installed to. Pure-perl distributions with no dynamic configuration are installed into the standard architecture-agnostic directory, and can usually run unmodified in other installations of Perl and architectures provided their requirements are still satisfied (though it's not a good idea unless you really know what you are doing). Distributions with any compiled XS modules or that generate modules dynamically in the build process are installed into the arch directory and are not safe to use from another Perl.

          所有这些位置都是在构建Perl时配置的,可以使用 perl -V 选项发现如您所示。它们每个都有相应的脚本 bin 目录(通常是相同的)和手册页目录。

          All of these locations are configured when the Perl is built and can be discovered using the perl -V option as you showed. They also each have accompanying script and bin directories (which are usually the same) and directories for manpages.

          关于 cpan过时的差异-此工具(就像许多使用 ExtUtils :: Installed )仅限于查找具有 packlists 的模块,这些模块在使用CPAN安装模块时会包括在内客户端,但不包含核心模块,通常从供应商软件包中剥离它们。因此,很可能 cpan-outdated 仅会发现 sitelib 中的模块,但这通常就是您所需要的。我不确定cpan命令会使用哪种机制。

          As to the discrepancy of cpan-outdated - this tool (like many tools using ExtUtils::Installed) is restricted to finding modules that have packlists, which are included when installing a module using a CPAN client, but not with core modules and they are generally stripped from vendor packages. So most likely cpan-outdated will only discover modules in sitelib, but this is usually all you need to find. I'm not sure what mechanism the cpan command uses.

          这篇关于Perl中的核心,供应商和站点位置之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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