channel#

Defines Channel and MultiChannel objects and other channel-related functions.

Object inheritance:

Inheritance diagram of Channel, MultiChannel

Classes#

ChannelType

This metaclass does basic caching and enables static constructor method usage with a

Channel

Channel:

MultiChannel

Channel:

Functions#

tokenized_startswith(→ bool)

tokenized_conda_url_startswith(→ bool)

_get_channel_for_name(→ Channel)

_read_channel_configuration(→ tuple[str | None, ...)

parse_conda_channel_url(→ Channel)

get_conda_build_local_url(...)

prioritize_channels(→ dict[str, tuple[str, int]])

Make a dictionary of channel priorities.

all_channel_urls(→ boltons.setutils.IndexedSet)

offline_keep(→ bool)

get_channel_objs(→ tuple[Channel, Ellipsis])

Return current channels as Channel objects

class ChannelType#

Bases: type

This metaclass does basic caching and enables static constructor method usage with a single arg.

__call__(*args, **kwargs)#

Call self as a function.

class Channel(scheme: str | None = None, auth: str | None = None, location: str | None = None, token: str | None = None, name: str | None = None, platform: str | None = None, package_filename: str | None = None)#

Channel: scheme <> auth <> location <> token <> channel <> subchannel <> platform <> package_filename

Package Spec: channel <> subchannel <> namespace <> package_name

property channel_location: str | None#
property channel_name: str#
property subdir: str | None#
property canonical_name: str#
property base_url: str | None#
property base_urls: tuple[str | None, Ellipsis]#
property subdir_url: str#
property channels: tuple[Channel, Ellipsis]#
property url_channel_wtf: tuple[str | None, str]#
_cache_#
static _reset_state() None#
static from_url(url: str) Channel#
static from_channel_name(channel_name: str) Channel#
static from_value(value: str | None) Channel#

Construct a new Channel from a single value.

Parameters:

value --

Anyone of the following forms:

None, or one of the special strings "<unknown>", "None:///<unknown>", or "None":

represents the unknown channel, used for packages with unknown origin.

A URL including a scheme like file:// or https://:

represents a channel URL.

A local directory path:

represents a local channel; relative paths must start with ./.

A package file (i.e. the path to a file ending in .conda or .tar.bz2):

represents a channel for a single package

A known channel name:

represents a known channel, e.g. from the users .condarc file or the global configuration.

Returns:

A channel object.

static make_simple_channel(channel_alias: Channel, channel_url: str, name: str | None = None) Channel#
urls(with_credentials: bool = False, subdirs: collections.abc.Iterable[str] | None = None) list[str]#

Generate URLs for this channel across specified platforms.

Parameters:
  • with_credentials -- If True, include authentication credentials (token, auth) in URLs.

  • subdirs -- Specific platform subdirs to generate URLs for. If None, uses the channel's platform (if defined) or falls back to context.subdirs. If this is explicitly provided, overrides any platform defined in the channel.

Examples

>>> channel = Channel("conda-forge")
>>> channel.urls()  # Uses context.subdirs
['https://conda.anaconda.org/conda-forge/linux-64',
'https://conda.anaconda.org/conda-forge/noarch']
>>> channel = Channel("conda-forge/linux-aarch64")
>>> channel.urls()  # Uses channel's platform
['https://conda.anaconda.org/conda-forge/linux-aarch64',
'https://conda.anaconda.org/conda-forge/noarch']
>>> channel.urls(subdirs=("osx-64", "noarch"))
['https://conda.anaconda.org/conda-forge/osx-64',
'https://conda.anaconda.org/conda-forge/noarch']
Returns:

List of URLs for accessing this channel's specified subdirectories.

Return type:

list[str]

url(with_credentials: bool = False) str | None#
__str__() str#

Return str(self).

__repr__() str#

Return repr(self).

__eq__(other: Any) bool#

Return self==value.

__hash__() int#

Return hash(self).

__nonzero__() bool#
__bool__() bool#
__json__() dict[str, Any]#
dump() dict[str, Any]#
class MultiChannel(name: str, channels: collections.abc.Iterable[Channel], platform: str | None = None)#

Bases: Channel

Channel: scheme <> auth <> location <> token <> channel <> subchannel <> platform <> package_filename

Package Spec: channel <> subchannel <> namespace <> package_name

property canonical_name: str#
property base_url: None#
property base_urls: tuple[str | None, Ellipsis]#
property channels: tuple[Channel, Ellipsis]#
urls(with_credentials: bool = False, subdirs: collections.abc.Iterable[str] | None = None) list[str]#

Generate URLs for this channel across specified platforms.

Parameters:
  • with_credentials -- If True, include authentication credentials (token, auth) in URLs.

  • subdirs -- Specific platform subdirs to generate URLs for. If None, uses the channel's platform (if defined) or falls back to context.subdirs. If this is explicitly provided, overrides any platform defined in the channel.

Examples

>>> channel = Channel("conda-forge")
>>> channel.urls()  # Uses context.subdirs
['https://conda.anaconda.org/conda-forge/linux-64',
'https://conda.anaconda.org/conda-forge/noarch']
>>> channel = Channel("conda-forge/linux-aarch64")
>>> channel.urls()  # Uses channel's platform
['https://conda.anaconda.org/conda-forge/linux-aarch64',
'https://conda.anaconda.org/conda-forge/noarch']
>>> channel.urls(subdirs=("osx-64", "noarch"))
['https://conda.anaconda.org/conda-forge/osx-64',
'https://conda.anaconda.org/conda-forge/noarch']
Returns:

List of URLs for accessing this channel's specified subdirectories.

Return type:

list[str]

url(with_credentials: bool = False) None#
dump() dict[str, Any]#
tokenized_startswith(test_iterable: collections.abc.Iterable[Any], startswith_iterable: collections.abc.Iterable[Any]) bool#
tokenized_conda_url_startswith(test_url: collections.abc.Iterable[str], startswith_url: collections.abc.Iterable[str]) bool#
_get_channel_for_name(channel_name: str) Channel#
_read_channel_configuration(scheme: str | None, host: str | None, port: str | None, path: str | None) tuple[str | None, str | None, str | None, str | None, str | None]#
parse_conda_channel_url(url: str) Channel#
get_conda_build_local_url() tuple[conda.common.path.PathType]#
prioritize_channels(channels: collections.abc.Iterable[Channel | str], with_credentials: bool = True, subdirs: collections.abc.Iterable[str] | None = None) dict[str, tuple[str, int]]#

Make a dictionary of channel priorities.

Maps channel names to priorities, e.g.:

>>> prioritize_channels(["conda-canary", "defaults", "conda-forge"])
{
    'https://conda.anaconda.org/conda-canary/osx-arm64': ('conda-canary', 0),
    'https://conda.anaconda.org/conda-canary/noarch': ('conda-canary', 0),
    'https://repo.anaconda.com/pkgs/main/osx-arm64': ('defaults', 1),
    'https://repo.anaconda.com/pkgs/main/noarch': ('defaults', 1),
    'https://repo.anaconda.com/pkgs/r/osx-arm64': ('defaults', 2),
    'https://repo.anaconda.com/pkgs/r/noarch': ('defaults', 2),
    'https://conda.anaconda.org/conda-forge/osx-arm64': ('conda-forge', 3),
    'https://conda.anaconda.org/conda-forge/noarch': ('conda-forge', 3),
}

Compare with conda.resolve.Resolve._make_channel_priorities.

all_channel_urls(channels: collections.abc.Iterable[str | Channel], subdirs: collections.abc.Iterable[str] | None = None, with_credentials: bool = True) boltons.setutils.IndexedSet#
offline_keep(url: Any) bool#
get_channel_objs(ctx: conda.base.context.Context) tuple[Channel, Ellipsis]#

Return current channels as Channel objects