Conda channels#

Conda-build 支持标准的 conda channel 行为。

相同的 channel 和包名称问题#

如果 channel 和包名称相同,则在使用短 channel 名称时可能会遇到构建问题。

假设您的 Anaconda.org 用户名或组织名称为 example。并假设您创建了一个包 example,其文件布局类似于

setup.py
conda/meta.yaml
example/

如果您的构建依赖于 channel 内的其他一些包,您将需要添加 -c example,但是,以下代码

conda-build ./conda/ -c example

将失败并显示以下错误消息(路径将有所不同)

requests.exceptions.HTTPError: 404 Client Error: None for url:
file:///path/to/your/local/example/noarch/repodata.json
[...]
The remote server could not find the noarch directory for the requested channel with
url: file:///path/to/your/local/example/noarch/repodata.json
[...]
As of conda 4.3, a valid channel must contain a `noarch/repodata.json` and
associated `noarch/repodata.json.bz2` file, even if `noarch/repodata.json`
is empty. please request that the channel administrator create
`noarch/repodata.json` and associated `noarch/repodata.json.bz2` files.

发生这种情况是因为 conda-build 会将项目中的目录 ./example/ 视为一个 channel。这是根据 conda 的 CI 服务器设计的,其中构建路径可能很长、很复杂且在构建之前不可预测。

有几种方法可以解决此问题。

  1. 使用所需 channel 的 URL

    conda-build ./conda/ -c https://conda.anaconda.org/example/
    
  2. 从 conda recipe 目录内部运行构建

    cd conda
    conda-build . -c example
    
  3. 使用标签规范变通方法

conda-build ./conda/ -c example/label/main

这在技术上与 -c example 相同,因为 main 是默认标签,但现在它不会错误地在本地文件系统上找到 channel example/label/main