Conda频道能包括多个频道吗?

huangapple go评论108阅读模式
英文:

Can conda channels include multiple channels?

问题

我正在阅读Conda通道文档,文档似乎表明:

  • 默认情况下,Conda使用defaults通道。这可以在本地验证:
  1. % conda config --show channels
  2. channels:
  3. - defaults

然而,快速查看首页显示,该通道似乎包括多个通道,如pkgs/mainpkgs/free等。这令人困惑,因为这反映了类似命令的输出,列出了默认通道:

  1. % conda config --show default_channels
  2. default_channels:
  3. - https://repo.anaconda.com/pkgs/main
  4. - https://repo.anaconda.com/pkgs/r

所以我的问题是,通道到底是什么?defaults只是默认通道列表的特殊硬编码别名,即pkgs/mainpkgs/r吗?还是任何通道都可以声明它包括多个通道?

英文:

I'm reading the documentation on Conda channels, and the documentation appears to state that:

  • By default, Conda uses the defaults channel. This can be verified locally:
  1. % conda config --show channels
  2. channels:
  3. - defaults

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:

  1. % conda config --show default_channels
  2. default_channels:
  3. - https://repo.anaconda.com/pkgs/main
  4. - 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文件中,有几个关键字值是关注的:channelscustom_multichannelsdefault_channelschannel_alias

channels下列出的任何值都是conda将搜索的单个通道或多通道。像conda-forge这样的单个通道可以仅列出通道名称或URL。

  1. channels:
  2. - https://my.customrepo.org/dev/win-64
  3. - conda-forge

但你也可以定义多通道,它们只是具有名称的一组通道,然后引用它。在下面的示例中,internal-dev不是http://conda.anaconda.org上的通道,而是指向一组内部通道的多通道的名称。

  1. channels:
  2. - conda-forge
  3. custom_multichannels:
  4. internal-dev:
  5. - https://conda.mywork.site/dev/noarch
  6. - https://conda.mywork.site/dev/win-64

现在,你可以在使用conda时引用internal-dev通道:

  1. conda create -n testenv python some_dev_package -c internal-dev

你还可以在.condarc文件中的默认通道列表中引用它。

  1. channels:
  2. - internal-dev
  3. - conda-forge
  4. custom_multichannels:
  5. internal-dev:
  6. - https://conda.mywork.site/dev/noarch
  7. - https://conda.mywork.site/dev/win-64

default_channels关键字只是另一个多通道,具有预定义的名称defaults。以下两个.condarc YAML文件在功能上是等效的:

  1. channels:
  2. - internal-dev
  3. - defaults
  4. - fastai
  5. default_channels:
  6. - https://repo.anaconda.com/pkgs/main
  7. - https://repo.anaconda.com/pkgs/r
  8. custom_multichannels:
  9. internal-dev:
  10. - https://conda.mywork.site/dev/noarch
  11. - https://conda.mywork.site/dev/win-64
  1. channels:
  2. - internal-dev
  3. - defaults
  4. - fastai
  5. custom_multichannels:
  6. defaults:
  7. - https://repo.anaconda.com/pkgs/main
  8. - https://repo.anaconda.com/pkgs/r
  9. internal-dev:
  10. - https://conda.mywork.site/dev/noarch
  11. - https://conda.mywork.site/dev/win-64

最后要注意的关键字是channel_alias。它设置用作查找通道根的默认服务器。默认值是https://conda.anaconda.org。但是,如果你几乎专门使用内部conda服务器,你可以更改此值,以便只需使用通道名称引用通道。

  1. channel_alias: https://conda.mywork.site
  2. channels:
  3. - internal-dev
  4. - defaults
  5. - fastai
  6. default_channels:
  7. - anaconda
  8. - r
  9. custom_multichannels:
  10. internal-dev:
  11. - dev-build
  12. - 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.

  1. channels:
  2. - https://my.customrepo.org/dev/win-64
  3. - 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.

  1. channels:
  2. - conda-forge
  3. custom_multichannels:
  4. internal-dev:
  5. - https://conda.mywork.site/dev/noarch
  6. - https://conda.mywork.site/dev/win-64

Now, you can refer to the interanl-dev channel when using conda:

  1. 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.

  1. channels:
  2. - internal-dev
  3. - conda-forge
  4. custom_multichannels:
  5. internal-dev:
  6. - https://conda.mywork.site/dev/noarch
  7. - 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:

  1. channels:
  2. - internal-dev
  3. - defaults
  4. - fastai
  5. default_channels:
  6. - https://repo.anaconda.com/pkgs/main
  7. - https://repo.anaconda.com/pkgs/r
  8. custom_multichannels:
  9. internal-dev:
  10. - https://conda.mywork.site/dev/noarch
  11. - https://conda.mywork.site/dev/win-64
  1. channels:
  2. - internal-dev
  3. - defaults
  4. - fastai
  5. custom_multichannels:
  6. defaults:
  7. - https://repo.anaconda.com/pkgs/main
  8. - https://repo.anaconda.com/pkgs/r
  9. internal-dev:
  10. - https://conda.mywork.site/dev/noarch
  11. - 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.

  1. channel_alias: https://conda.mywork.site
  2. channels:
  3. - internal-dev
  4. - defaults
  5. - fastai
  6. default_channels:
  7. - anaconda
  8. - r
  9. custom_multichannels:
  10. internal-dev:
  11. - dev-build
  12. - dev-test

All of the above channels point to https://conda.mywork.site/&lt;channel&gt; 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)

huangapple
  • 本文由 发表于 2023年3月21日 00:47:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793069.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定