英文:
Can conda channels include multiple channels?
问题
我正在阅读Conda通道文档,文档似乎表明:
- 默认情况下,Conda使用
defaults通道。这可以在本地验证:
% conda config --show channels
channels:
- defaults
defaults通道托管在repo.anaconda.com
然而,快速查看首页显示,该通道似乎包括多个通道,如pkgs/main,pkgs/free等。这令人困惑,因为这反映了类似命令的输出,列出了默认通道:
% conda config --show default_channels
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
所以我的问题是,通道到底是什么?defaults只是默认通道列表的特殊硬编码别名,即pkgs/main和pkgs/r吗?还是任何通道都可以声明它包括多个通道?
英文:
I'm reading the documentation on Conda channels, and the documentation appears to state that:
- By default, Conda uses the
defaultschannel. This can be verified locally:
% conda config --show channels
channels:
- defaults
- The
defaultschannel is hosted on repo.anaconda.com
However, a quick glance at the landing page shows that this channel seems to include multiple channels, such as pkgs/main, pkgs/free, etc. This is extra confusing because this reflects the output of a similar command to list default channels:
% conda config --show default_channels
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
So my question is, what exactly is a channel? Is defaults just a special, hard-coded alias for a list of default channels, namely pkgs/main and pkgs/r? Or can any channel declare that it includes multiple channels within itself?
答案1
得分: 1
在你的.condarc文件中,有几个关键字值是关注的:channels,custom_multichannels,default_channels和channel_alias。
在channels下列出的任何值都是conda将搜索的单个通道或多通道。像conda-forge这样的单个通道可以仅列出通道名称或URL。
channels:
- https://my.customrepo.org/dev/win-64
- conda-forge
但你也可以定义多通道,它们只是具有名称的一组通道,然后引用它。在下面的示例中,internal-dev不是http://conda.anaconda.org上的通道,而是指向一组内部通道的多通道的名称。
channels:
- conda-forge
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
现在,你可以在使用conda时引用internal-dev通道:
conda create -n testenv python some_dev_package -c internal-dev
你还可以在.condarc文件中的默认通道列表中引用它。
channels:
- internal-dev
- conda-forge
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
default_channels关键字只是另一个多通道,具有预定义的名称defaults。以下两个.condarc YAML文件在功能上是等效的:
channels:
- internal-dev
- defaults
- fastai
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
channels:
- internal-dev
- defaults
- fastai
custom_multichannels:
defaults:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
最后要注意的关键字是channel_alias。它设置用作查找通道根的默认服务器。默认值是https://conda.anaconda.org。但是,如果你几乎专门使用内部conda服务器,你可以更改此值,以便只需使用通道名称引用通道。
channel_alias: https://conda.mywork.site
channels:
- internal-dev
- defaults
- fastai
default_channels:
- anaconda
- r
custom_multichannels:
internal-dev:
- dev-build
- dev-test
上述所有通道都指向https://conda.mywork.site/<channel>,而不是外部服务器。要指向互联网上的通道,你需要使用完整的URL(例如https://conda.anacond.org/conda-forge)。
英文:
In your .condarc file there are several keys of interest: channels, custom_multichannels, default_channels, and channel_alias
Any values listed under channels are a single channel or a multi-channel that conda will search. A single channel such as conda-forge can be listed using just the channel name or the url.
channels:
- https://my.customrepo.org/dev/win-64
- conda-forge
But you can also define multi-channels, which are just a collection of channels with a name, and then reference that. In the example below, the internal-dev is not a channel on http://conda.anaconda.org, but instead is the name of a multichannel pointing to a set of internal channels.
channels:
- conda-forge
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
Now, you can refer to the interanl-dev channel when using conda:
conda create -n testenv python some_dev_package -c internal-dev
You can also reference it in your list of default channels in the .condarc file.
channels:
- internal-dev
- conda-forge
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
The default_channels key is just another multichannel, with a pre-defined name of defaults. The following two .condarc YAML files are functionally equivalent:
channels:
- internal-dev
- defaults
- fastai
default_channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
custom_multichannels:
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
channels:
- internal-dev
- defaults
- fastai
custom_multichannels:
defaults:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
internal-dev:
- https://conda.mywork.site/dev/noarch
- https://conda.mywork.site/dev/win-64
The last key to be aware of is channel_alias. This sets the default server to use as the root for finding channels. The default is https://conda.anaconda.org. However, if you have an internal conda server that you use almost exclusively, you can change this value so you can reference the channels by just their name.
channel_alias: https://conda.mywork.site
channels:
- internal-dev
- defaults
- fastai
default_channels:
- anaconda
- r
custom_multichannels:
internal-dev:
- dev-build
- dev-test
All of the above channels point to https://conda.mywork.site/<channel> and not to an outside server. To point to a channel on the internet, you would need to use the full URL (i.e. https://conda.anacond.org/conda-forge)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论