简体   繁体   English

如何将 CRAN 包导出到 Conda yaml 文件?

[英]How to export CRAN packages to Conda yaml file?

I need to export a Conda R environment with a number of packages.我需要导出带有多个包的 Conda R 环境。 All except one are available through a Conda channel, so can be trivially added.除一个之外的所有内容都可以通过 Conda 渠道获得,因此可以轻松添加。 The problem is the package BiDAG, which is on CRAN, but none of the Conda channels.问题在于 CRAN 上的 package BiDAG,但没有任何 Conda 通道。

When I run install.packages("BiDAG") from inside the environment I want to export, the package is installed into the correct directory.当我从要导出的环境中运行install.packages("BiDAG")时,package 会安装到正确的目录中。 However, conda env export > env.yml does not recognise it, as it only tracks packages that are installed by conda itself.但是, conda env export > env.yml无法识别它,因为它只跟踪 conda 本身安装的包。

I've tried building from CRAN with我已经尝试从 CRAN 构建

conda skeleton CRAN bidag
conda build r-bidag

But this crashes on two packages (r-graph and r-rgraphviz) that are available from Bioconductor, and even through conda channels, but no longer on CRAN.但这会在 Bioconductor 甚至通过 conda 渠道提供的两个包(r-graph 和 r-rgraphviz)上崩溃,但不再在 CRAN 上。 They are therefore not recognised and the build fails.因此它们不被识别并且构建失败。

Is there a way to export a conda environment with this CRAN package BiDAG in the.yml?有没有办法在 .yml 中使用这个 CRAN package BiDAG 导出 conda 环境?

For future reference: This does not seem to be possible.供将来参考:这似乎是不可能的。 A better solution is to work with a container system like Docker or Singularity, which is what I will do.更好的解决方案是使用像 Docker 或 Singularity 这样的容器系统,这就是我要做的。

Avoid install.packages in Conda Environments避免在 Conda 环境中使用install.packages

Generally, using install.packages in a Conda-managed R environment complicates the environment and I recommend against it.通常,在 Conda 管理的 R 环境中使用install.packages会使环境复杂化,我建议不要这样做。 As you have found, Conda cannot recognize these packages, and so one loses the reproducibility that Conda offers via environment exporting.正如您所发现的,Conda 无法识别这些包,因此失去了 Conda 通过环境导出提供的可重复性。 Furthermore, install.packages often has trouble locating the shared libraries and build stack that was used for all the Conda package builds.此外, install.packages经常无法找到用于所有 Conda package 构建的共享库和构建堆栈。 This can lead to some packages having compilation, linking, or other shared library issues.这可能会导致某些包出现编译、链接或其他共享库问题。

Building r-bidag构建r-bidag

The Bioconductor packages are all hosted on the bioconda channel and are prefixed with bioconductor- instead of r- . Bioconductor 软件包都托管在bioconda频道上,并以bioconductor-而不是r-为前缀。 Hence, one should be able to build the package by modifying the meta.yaml that comes out of conda skeleton to replace r-graph and r-graphviz with bioconductor-graph and bioconductor-graphviz .因此,应该能够通过修改来自meta.yaml conda skeleton的 meta.yaml 以用bioconductor-graphbioconductor-graphviz替换r-graphr-graphviz来构建 package。 Then build the package with然后用

conda build --override-channels -c conda-forge -c bioconda -c defaults r-bidag

You may also need the --R argument to specify the R version for which to build.您可能还需要 --R 参数来指定要为其构建的--R版本。

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

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