Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 在安装conda软件包期间更新@INC变量_Perl_Environment Variables_Conda_Environment_Conda Build - Fatal编程技术网

Perl 在安装conda软件包期间更新@INC变量

Perl 在安装conda软件包期间更新@INC变量,perl,environment-variables,conda,environment,conda-build,Perl,Environment Variables,Conda,Environment,Conda Build,我正在尝试安装Perl模块的conda包。到目前为止,我能够使用conda build创建包。为此,我有一个包含build.sh和meta.yaml文件的配方 然后我使用conda install在一个新环境中安装它,我希望能够运行我刚刚安装的Perl模块中的一些Perl脚本 所有这些步骤都很有效,但当我运行一些脚本时,我会出现一个错误,即: 在@INC中找不到PMP/util.pm(您可能需要安装PMP::util模块)(@INC包含:/.autofs/home/antoine/anacond

我正在尝试安装Perl模块的conda包。到目前为止,我能够使用
conda build
创建包。为此,我有一个包含
build.sh
meta.yaml
文件的配方

然后我使用
conda install
在一个新环境中安装它,我希望能够运行我刚刚安装的Perl模块中的一些Perl脚本

所有这些步骤都很有效,但当我运行一些脚本时,我会出现一个错误,即:

在@INC中找不到PMP/util.pm(您可能需要安装PMP::util模块)(@INC包含:/.autofs/home/antoine/anaconda2/envs/testCustomChannel/lib/site_perl/5.26.2/x86_64-linux-thread-multi/.autofs/home/antoine/anaconda2/envs/testCustomChannel/lib/site_perl/5.26.2/.autofs/home/antoine/anaconda2/envs/testCustomChannel/lib/5.26.2/envs/testCustomChannel/lib/5.26.2/x86-linux-thread-multi/.autofs/home/antoine/antoine/anaconda2/testconda2/testconda2.2。)

正如您所看到的,当我执行Perl时,Perl模块中的某些模块似乎无法识别。我知道要解决此问题,我可以修改@INC变量,并将bin/添加到PATH中,将lib/添加到PERL5LIB中,但我需要在模块安装期间将此过程自动化

我真的不知道应该在哪里修改环境变量。例如,在创建包的过程中,通过在
build.sh
中添加一些东西?或者我应该在安装过程中管理它,如果是,我该如何做

如有任何建议,将不胜感激

谢谢

编辑:

meta.yaml=>

{% set name = "module_name" %}
{% set version = "0.8.3" %}

package:
  name: "{{ name }}"
  version: "{{ version }}"

source:
  git_url: ssh://git@adress/bspcore/perl_module.git

build:
  number: 0

requirements:
  host:
    - perl
    - perl-extutils-makemaker
  run:
    - perl

about:
  home: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  license: xxx
  license_family: xxx
  summary: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#!/bin/bash
if [ -f Build.PL ]; then
    perl Build.PL
    perl ./Build
    # Make sure this goes in site
    perl ./Build install --installdirs site
elif [ -f Makefile.PL ]; then
    # Make sure this goes in site
    perl Makefile.PL INSTALLDIRS=site
    make
    make install
else
    echo 'Unable to find Build.PL or Makefile.PL. You need to modify build.sh.'
    exit 1
fi

chmod u+rwx $PREFIX/bin/*
echo "${PREFIX}"
Build.sh=>

{% set name = "module_name" %}
{% set version = "0.8.3" %}

package:
  name: "{{ name }}"
  version: "{{ version }}"

source:
  git_url: ssh://git@adress/bspcore/perl_module.git

build:
  number: 0

requirements:
  host:
    - perl
    - perl-extutils-makemaker
  run:
    - perl

about:
  home: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  license: xxx
  license_family: xxx
  summary: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#!/bin/bash
if [ -f Build.PL ]; then
    perl Build.PL
    perl ./Build
    # Make sure this goes in site
    perl ./Build install --installdirs site
elif [ -f Makefile.PL ]; then
    # Make sure this goes in site
    perl Makefile.PL INSTALLDIRS=site
    make
    make install
else
    echo 'Unable to find Build.PL or Makefile.PL. You need to modify build.sh.'
    exit 1
fi

chmod u+rwx $PREFIX/bin/*
echo "${PREFIX}"
编辑2:


另一个可以帮助你们更好地理解我的情况的编辑。我刚刚意识到,当我构建包时,我的perl模块的lib文件夹(其中我有
PMP::util
)位于
lib/site\u perl/5.26.0/perl\u module
下。我非常确定,如果我能够直接将它安装在
lib/
文件夹下,它将解决此问题。但是,我不确定如何修改build.sh文件以修改我们构建perl模块的位置。

以下是一个简单的示例,说明如何创建一个安装perl模块(取决于CPAN模块)的conda包,这可能会帮助您解决问题:

在Linux上安装miniconda 创建包: perl hello/meta.yaml

package:
  name: perl-hello3
  version: "1.0"

source:
  path: ../src # NOTE: if you had put "src" in same folder as "meta.yaml", 
               # conda-build would have include the src folder in info/recipe in 
               # the generated package. It is not necessary to include  the 
               # source code in the generated package.

requirements:
  build:
    - perl >= 5.22
    - make

  run:
    - perl >= 5.22

about:
  license: Artistic
  summary: Simple perl function
$ tree ../src
../src
├── lib
│   └── My
│       └── Module.pm
└── Makefile.PL
use utf8;
use ExtUtils::MakeMaker;

WriteMakefile(
    MIN_PERL_VERSION => 5.022000,
    NAME             => 'My::Module',
    VERSION_FROM     => 'lib/My/Module.pm',
    PREREQ_PM        =>
    {
        'ExtUtils::MakeMaker' => '7.12',
        'Data::Dump'          => 0,
    },
    ABSTRACT_FROM    => 'lib/My/Module.pm',
    AUTHOR           => 'Håkon Hægland <hakon.hagland@gmail.com>',
    LICENSE          => 'perl',
);
package My::Module;
our $VERSION = 0.01;
use strict;
use warnings;
use Exporter qw(import);

our @EXPORT = qw(hello);
our @EXPORT_OK = @EXPORT;

use Data::Dump;
sub hello {
    print "Hello world!\n";
    my $str = "Testing Perl module Data::Dump";
    dd $str;
}
1;
# PERL_MM_USE_DEFAULT=1  -> automatically answer "yes" on config questions
PERL_MM_USE_DEFAULT=1 cpan App::cpanminus
perl ${PREFIX}/bin/cpanm Data::Dump
perl Makefile.PL INSTALLDIRS=site
make
make install
。/src/

package:
  name: perl-hello3
  version: "1.0"

source:
  path: ../src # NOTE: if you had put "src" in same folder as "meta.yaml", 
               # conda-build would have include the src folder in info/recipe in 
               # the generated package. It is not necessary to include  the 
               # source code in the generated package.

requirements:
  build:
    - perl >= 5.22
    - make

  run:
    - perl >= 5.22

about:
  license: Artistic
  summary: Simple perl function
$ tree ../src
../src
├── lib
│   └── My
│       └── Module.pm
└── Makefile.PL
use utf8;
use ExtUtils::MakeMaker;

WriteMakefile(
    MIN_PERL_VERSION => 5.022000,
    NAME             => 'My::Module',
    VERSION_FROM     => 'lib/My/Module.pm',
    PREREQ_PM        =>
    {
        'ExtUtils::MakeMaker' => '7.12',
        'Data::Dump'          => 0,
    },
    ABSTRACT_FROM    => 'lib/My/Module.pm',
    AUTHOR           => 'Håkon Hægland <hakon.hagland@gmail.com>',
    LICENSE          => 'perl',
);
package My::Module;
our $VERSION = 0.01;
use strict;
use warnings;
use Exporter qw(import);

our @EXPORT = qw(hello);
our @EXPORT_OK = @EXPORT;

use Data::Dump;
sub hello {
    print "Hello world!\n";
    my $str = "Testing Perl module Data::Dump";
    dd $str;
}
1;
# PERL_MM_USE_DEFAULT=1  -> automatically answer "yes" on config questions
PERL_MM_USE_DEFAULT=1 cpan App::cpanminus
perl ${PREFIX}/bin/cpanm Data::Dump
perl Makefile.PL INSTALLDIRS=site
make
make install
。/src/Makefile.PL

package:
  name: perl-hello3
  version: "1.0"

source:
  path: ../src # NOTE: if you had put "src" in same folder as "meta.yaml", 
               # conda-build would have include the src folder in info/recipe in 
               # the generated package. It is not necessary to include  the 
               # source code in the generated package.

requirements:
  build:
    - perl >= 5.22
    - make

  run:
    - perl >= 5.22

about:
  license: Artistic
  summary: Simple perl function
$ tree ../src
../src
├── lib
│   └── My
│       └── Module.pm
└── Makefile.PL
use utf8;
use ExtUtils::MakeMaker;

WriteMakefile(
    MIN_PERL_VERSION => 5.022000,
    NAME             => 'My::Module',
    VERSION_FROM     => 'lib/My/Module.pm',
    PREREQ_PM        =>
    {
        'ExtUtils::MakeMaker' => '7.12',
        'Data::Dump'          => 0,
    },
    ABSTRACT_FROM    => 'lib/My/Module.pm',
    AUTHOR           => 'Håkon Hægland <hakon.hagland@gmail.com>',
    LICENSE          => 'perl',
);
package My::Module;
our $VERSION = 0.01;
use strict;
use warnings;
use Exporter qw(import);

our @EXPORT = qw(hello);
our @EXPORT_OK = @EXPORT;

use Data::Dump;
sub hello {
    print "Hello world!\n";
    my $str = "Testing Perl module Data::Dump";
    dd $str;
}
1;
# PERL_MM_USE_DEFAULT=1  -> automatically answer "yes" on config questions
PERL_MM_USE_DEFAULT=1 cpan App::cpanminus
perl ${PREFIX}/bin/cpanm Data::Dump
perl Makefile.PL INSTALLDIRS=site
make
make install
build.sh

package:
  name: perl-hello3
  version: "1.0"

source:
  path: ../src # NOTE: if you had put "src" in same folder as "meta.yaml", 
               # conda-build would have include the src folder in info/recipe in 
               # the generated package. It is not necessary to include  the 
               # source code in the generated package.

requirements:
  build:
    - perl >= 5.22
    - make

  run:
    - perl >= 5.22

about:
  license: Artistic
  summary: Simple perl function
$ tree ../src
../src
├── lib
│   └── My
│       └── Module.pm
└── Makefile.PL
use utf8;
use ExtUtils::MakeMaker;

WriteMakefile(
    MIN_PERL_VERSION => 5.022000,
    NAME             => 'My::Module',
    VERSION_FROM     => 'lib/My/Module.pm',
    PREREQ_PM        =>
    {
        'ExtUtils::MakeMaker' => '7.12',
        'Data::Dump'          => 0,
    },
    ABSTRACT_FROM    => 'lib/My/Module.pm',
    AUTHOR           => 'Håkon Hægland <hakon.hagland@gmail.com>',
    LICENSE          => 'perl',
);
package My::Module;
our $VERSION = 0.01;
use strict;
use warnings;
use Exporter qw(import);

our @EXPORT = qw(hello);
our @EXPORT_OK = @EXPORT;

use Data::Dump;
sub hello {
    print "Hello world!\n";
    my $str = "Testing Perl module Data::Dump";
    dd $str;
}
1;
# PERL_MM_USE_DEFAULT=1  -> automatically answer "yes" on config questions
PERL_MM_USE_DEFAULT=1 cpan App::cpanminus
perl ${PREFIX}/bin/cpanm Data::Dump
perl Makefile.PL INSTALLDIRS=site
make
make install
请注意,我使用
perl${PREFIX}/bin/cpanm
运行了
cpanm
。我无法简单地以
cpanm
的形式运行它,有关更多信息,请参阅

构建包 (记下生成的输出,并确定生成包的路径。在我的情况下,路径名为:

/home/hakon/miniconda3/conda-bld/linux-64/perl-hello3-1.0-pl526_0.tar.bz2
将包上载到anaconda服务器
  • 在以下位置注册新用户:

  • 安装客户端

    $ conda install anaconda-client
    
  • 登录到您的帐户:

    $ anaconda login
    
  • 上载生成的包:

    $ anaconda upload /home/hakon/miniconda3/conda-bld/linux-64/perl-hello3-1.0-pl526_0.tar.bz2
    
测试软件包(可以在任何linux机器上完成):
  • 创建一个新环境:

     $ conda create --name perltest
     $ conda activate perltest
    
  • 在新环境中安装软件包:

     $ conda install -c hakonhagland perl-hello3 
     # Alternatively: You can test the package locally before uploading with
     #   "conda install --use-local perl-hello3"
    
  • 测试软件包:

     $ perl -E 'use My::Module; hello'
     Hello world!
     "Testing Perl module Data::Dump"
    

您是如何安装perl 5.26.2的?您正在运行哪些脚本?您是如何运行它们的?perl安装:在meta.yaml中,我的requirements
run/host
字段中有
-perl
。我运行了一个位于perl模块的t/文件夹中的测试。我通过运行来调用它:
perl
。PS:我要编辑我的问题to添加build.sh和meta.yaml文件:)谢谢你的更新。我以前没有使用过conda,但我想试用一下。我可以下载你从某处创建的conda软件包吗?然后我可以试着在我的机器上安装它。我很乐意,但这是我公司的perl模块。我不能将它分享给任何人……嘿,谢谢你花时间帮助我这个问题。你的答案很有帮助!我将努力解决这个问题,使我的Perl模块正常工作。我正在努力理解路径:../src。我一直有一个错误,比如说它无法复制我的Perl模块的内容。我试着按照你的例子来做。但在我的情况下,我没有这个问题,因为源代码来自GitHub:)但是我仍然无法让它工作,我尝试复制您的小教程,但是您似乎正确地设置了perl模块相对于配方文件夹的路径?通过使用
path:../src
我避免将源代码合并到生成的conda包中。如果我将
src
文件夹放在与
build.sh
相同的文件夹中,然后在
meta.yaml
中使用
path:src
,则,
conda build
将在生成的包中包含
info/recipe
中的
src
文件夹。@AntMau我已更新我的答案,包括从Anaconda云安装的内容。现在,您可以使用
conda安装-c hakonhagland perl-hello3
测试我的包,如果您愿意的话!你好,我又回到你身边了。我按照您的教程从头开始安装该软件包。我本来可以做到,但在@INC中找不到
Data::Dumper。首先,如果在build.sh中我有
perl${PREFIX}/bin/cpanm Data::Dump
,则生成失败,说明文件
cpanm
不存在。我看了看,我有一个
cpan
脚本,但没有
cpanm
脚本。如果我改为使用
perl${PREFIX}/bin/cpan Data::Dump
,那么构建工作会很困难,但是如果我尝试通过运行
$perl-E'来测试模块,那么使用My::module;您好“
我有一个错误:
在@INC中找不到Data/Dump.pm