如何托管我自己的私有 conda 存储库? [英] How can I host my own private conda repository?

查看:45
本文介绍了如何托管我自己的私有 conda 存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个相互依赖的 python 项目.我对每个项目都有不同的发布版本,不同的项目可能依赖于特定项目的不同发布版本.我想在内部服务器上创建自己的 conda 存储库,我可以将这些项目的版本作为 conda 包推送,其他项目可以从那里安装所需的版本.这可能吗?如果有怎么办?

I have a few python projects that are dependent on each other. I have different release versions for each project and different projects might be dependent on different release versions of a particular project. I would like to create my own conda repository on an internal server where I can push the releases of these projects as conda packages and the other projects can install the required version from there. Is this possible? If so how?

推荐答案

你可以使用 conda 自定义频道 作为您的私人仓库.基本步骤是使用conda build"创建一个 conda 包,然后将该包复制到您的自定义频道(一个目录)中,然后在该目录上运行 conda index.然后,您可以使用conda install -c"从该频道安装软件包.

You can use a conda custom channel as your private repo. The essential steps are to use "conda build" to create a conda package, then copy that package into your custom channel (a directory), and now run conda index on that directory. You can then install packages from this channel by using the "conda install -c ".

一个例子,更详细地说,假设 linux-64:

An example, in more detail, let's assume linux-64:

  • 创建频道:
    mkdir -p/tmp/my-conda-channel/linux-64
  • 现在假设您有一个名为abc"的项目,其中包含 meta.yaml 和 build.sh,其中包含某个版本 X.现在您构建它:

  • Create the channel:
    mkdir -p /tmp/my-conda-channel/linux-64
  • Now assuming you have some project named "abc" with a meta.yaml and build.sh with some version X. Now you build it:

conda build abc

这将在您的 conda-bld 目录中构建一个 tar.bz2 文件.例如:~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2.将该文件复制到您的频道:

This will build a tar.bz2 file in your conda-bld directory. For example: ~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2. Copy that file to your channel:

cp ~/miniconda3/conda-bld/linux-64/abc-X-py35_0.tar.bz2/tmp/my-conda-channel/linux-64/

现在索引它:

conda 索引/tmp/my-conda-channel/linux-64/

您现在已将该软件包上传到您的自定义频道.您可以通过以下方式将其安装在任何 conda 环境中:

You've now uploaded that package to your custom channel. You can install it in any of your conda environments by doing:

conda install -c file://tmp/my-conda-channel/ abc=X

回想一下,X 是版本,因此,一旦您在频道中放置了更多版本,您就可以安装特定版本.

Where, recall, the X is the version so, once you've placed more versions in your channel, you can install specific versions.

如果您有一个项目依赖于abc"的 X 版本,那么我们只需将其添加到该项目的 meta.yaml 中.示例:

If you have a project that depends on the X version of "abc" then we simply add it to that projects meta.yaml. Example:

package:
  name: some-other-project
  version: 0.1
requirements:
  build:
   - abc X
...

创建此频道后,最好将其添加到您的 .condarc 文件,以便自动搜索.例如:

Once you have created this channel it's probably a good idea to add it to your .condarc file so that it will get automatically searched. For example:

channels:
- file://tmp/my-conda-channel/   
- defaults

这篇关于如何托管我自己的私有 conda 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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