【问题标题】:How can I build a Perl distribution with DIst::Zilla and use Carton for dependencies?如何使用 DIst::Zilla 构建 Perl 发行版并将 Carton 用于依赖项?
【发布时间】:2014-08-22 07:34:47
【问题描述】:

我有一个使用 Dist::Zilla 构建的 perl 发行版,因此我不必用依赖项污染我安装的 Perl 库,我使用 Carton 来管理它们。

事情在开发中运行良好,但是当我运行 dzil testdzil release 并运行测试时,找不到依赖项并且测试失败,因为无法加载模块。

我尝试过carton exec -- dzil testPERL5LIB=local/lib/perl5 dzil test,但我认为这意味着我需要将我所有的 Dist::Zilla deps 放入 cpanfile,这似乎完全错误(我确实有 Dist::Zilla 和我需要的 deps安装在我的 perl 的 lib 路径中)。

有没有更好的办法?

【问题讨论】:

    标签: perl dist-zilla


    【解决方案1】:

    我解决了:

    export PERL5LIB=$PERL5LIB:/absolute/path/to/project/local/lib/perl5; dzil release
    

    【讨论】:

      【解决方案2】:

      如果我们想分离开发和包本身之间的依赖关系并通过carton安装所有东西(即不要将它们保留在系统中),这就是我们需要做的事情。同时当 Dist::Zilla::Plugin::CPANFile 覆盖包 cpanfile。

      1. 使用 carton 通过 cpanfile 将所有 Dist::Zilla 和其他开发依赖项安装在单独的路径上
      2. 将这些本地库链接到主项目
      3. 这里你在你的项目中做一些事情,例如,添加更多的依赖项
      4. carton exec dzil build(Dist::Zilla::Plugin::CPANFile 会自动创建带有项目依赖的 cpanfile)
      5. 像往常一样使用carton 安装它们
      6. 从现在开始carton exec dzil test 将起作用!

      让我来说明这一点,就好像所有开发依赖项都在 dev 目录中:

      #!perl
      
      chdir 'dev'; 
      system 'carton'; # (1)
      chdir ".."; # (2)
      if (!-l "local") { symlink("dev/local", "local") or die $@; } # (2)
      if (!-l "cpanfile.snapshot") { symlink("dev/cpanfile.snapshot", "cpanfile.snapshot") or die $@; } # (2)
      system 'carton'; # (5)
      
      print "done\n";
      

      【讨论】:

        猜你喜欢
        • 2017-03-03
        • 2012-09-16
        • 2012-07-19
        • 2019-10-03
        • 2019-09-22
        • 2012-05-30
        • 2020-07-24
        • 1970-01-01
        • 2011-05-23
        相关资源
        最近更新 更多