如何托管自己的私有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?

您可以使用

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 index /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.

如果您有一个依赖于X版本的"abc"的项目,那么我们只需将其添加到该项目的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
...

创建此频道后,最好将其添加到您的

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