我如何托管自己的私人conda存储库?

时间:2016-02-12 09:36:14

标签: python pip anaconda pypi conda

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

3 个答案:

答案 0 :(得分:30)

您可以使用conda custom channel作为私人回购。基本步骤是使用“conda build”创建一个conda包,然后将该包复制到您的自定义通道(目录)中,现在在该目录上运行conda index。然后,您可以使用“conda install -c”从该通道安装软件包。

更详细的一个例子,让我们假设linux-64:

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

    conda build abc

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

    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环境中:

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

在哪里,回想一下,X是版本,所以,一旦你在频道中放置了更多版本,你就可以安装特定的版本。

如果您的项目依赖于“abc”的X版本,那么我们只需将其添加到项目meta.yaml中。例如:

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

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

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

答案 1 :(得分:2)

这有两个部分:如何创建通道以及如何使用它。第二部分是最难做到的。

第一部分在conda documentation中进行了详细描述。 您可以直接通过文件或通过静态网络服务器投放频道。

要使用该渠道,一种方法是<key>UIApplicationExitsOnSuspend</key> <true/> ,但是最新的conda版本允许通过自定义渠道提供更好的解决方案,而该渠道(最近添加到了conda)。

可通过-c file://tmp/my-conda-channel/获得该文档,其中包括以下部分:

conda config --describe

未记录添加通道的语法,但是reading the source的正确调用被视为:

# custom_channels (map: str)
#   A map of key-value pairs where the key is a channel name and the value
#   is a channel location. Channels defined here override the default
#   'channel_alias' value. The channel name (key) is not included in the
#   channel location (value).  For example, to override the location of
#   the 'conda-forge' channel where the url to repodata is
#   https://anaconda-repo.dev/packages/conda-forge/linux-64/repodata.json,
#   add an entry 'conda-forge: https://anaconda-repo.dev/packages'.
#
# custom_channels: {}

(注意:conda --set custom_channels.my-conda-channel file://tmp/ 不是路径的一部分)。 将此添加到您的配置后,您现在可以使用自己的频道,就像my-conda-channel/或其他“内置”频道一样:

conda-forge

对于任何使用MS Windows设置的用户,将其与Windows共享一起使用的正确斜杠和反斜杠设置为conda install -c my-conda-channel my-cool-package 。很有魅力。

答案 2 :(得分:0)

如果要在 Windows 上添加频道,请尝试:

conda config --append channels file:///C:\tmp\my-conda-channel

请确保您遵循了Paul和Janus的回答。