如何解读"feature:/win-64::__cuda==11.1=0"等conda包规范?
How to interpret conda package specifications such as "feature:/win-64::__cuda==11.1=0"?
我 运行 conda install 但它抛出以下错误:
UnsatisfiableError: The following specifications were found to be
incompatible with your system:
- feature:/win-64::__cuda==11.1=0
Your installed version is: 11.1
我不是在问如何解决这个错误,而是这个语句是什么意思?
如何阅读feature:/win-64::__cuda==11.1=0
?
什么是 :/
、::
、__
? 11.1=0
是什么?
如果我安装的版本是 11.1,包是否需要 cuda 版本 0?
来自 managing virtual packages 上的 conda 文档:
Managing virtual packages
"Virtual" packages are injected into the conda solver to allow real packages to depend on features present on the system that cannot be managed directly by conda, like system driver versions or CPU features. Virtual packages are not real packages and not displayed by conda list
. Instead conda
runs a small bit of code to detect the presence or absence of the system feature that corresponds to the package. The currently supported list of virtual packages includes:
__cuda
: Maximum version of CUDA supported by the display driver.
__osx
: OSX version if applicable.
__glibc
: Version of glibc supported by the OS.
因此,feature
指的是系统功能,在本例中是指支持的显示驱动程序版本。
根据 conda package specification,__cuda==11.1
表示显示驱动程序必须与 cuda 版本 11.1、11.1.0、11.1.0.0 等之一完全匹配。
conda 包的 MatchSpec
查询语言
conda源代码文件match_spec.py定义了MatchSpec
class。此 class 的文档字符串包括 conda 包的技术规范。
`MatchSpec` is, fundamentally, a query language for conda packages. Any
of the fields that comprise a `PackageRecord` can be used to compose a
`MatchSpec`.
`MatchSpec` can be composed with keyword arguments, where keys are any of
the attributes of `PackageRecord`. Values for keyword arguments are the
exact values the attribute should match against. Many fields can also be
matched against non-exact values--by including wildcard `*` and `>`/`<`
ranges--where supported. Any non-specified field is the equivalent of a
full wildcard match.
`MatchSpec` can also be composed using a single positional argument, with
optional keyword arguments. Keyword arguments also override any
conflicting information provided in the positional argument. The
positional argument can be either an existing `MatchSpec` instance or a
string. Conda has historically had several string representations for
equivalent `MatchSpec`s. This `MatchSpec` should accept any existing
valid spec string, and correctly compose a `MatchSpec` instance.
A series of rules are now followed for creating the canonical string
representation of a `MatchSpec` instance. The canonical string
representation can generically be represented by
(channel(/subdir):(namespace):)name(version(build))[key1=value1,key2=value2]
where `()` indicate optional fields. The rules for constructing a
canonical string representation are:
1. `name` (i.e. "package name") is required, but its value can be '*'.
Its position is always outside the key-value brackets.
2. If `version` is an exact version, it goes outside the key-value
brackets and is prepended by `==`. If `version` is a "fuzzy" value
(e.g. `1.11.*`), it goes outside the key-value brackets with the
`.*` left off and is prepended by `=`. Otherwise `version` is
included inside key-value brackets.
3. If `version` is an exact version, and `build` is an exact value,
`build` goes outside key-value brackets prepended by a `=`.
Otherwise, `build` goes inside key-value brackets. `build_string`
is an alias for `build`.
4. The `namespace` position is being held for a future conda feature.
5. If `channel` is included and is an exact value, a `::` separator is
used between `channel` and `name`. `channel` can either be a
canonical channel name or a channel url. In the canonical string
representation, the canonical channel name will always be used.
6. If `channel` is an exact value and `subdir` is an exact value,
`subdir` is appended to `channel` with a `/` separator. Otherwise,
`subdir` is included in the key-value brackets.
7. Key-value brackets can be delimited by comma, space, or
comma+space. Value can optionally be wrapped in single or double
quotes, but must be wrapped if `value` contains a comma, space, or
equal sign. The canonical format uses comma delimiters and single
quotes.
8. When constructing a `MatchSpec` instance from a string, any
key-value pair given inside the key-value brackets overrides any
matching parameter given outside the brackets.
When `MatchSpec` attribute values are simple strings, the are interpreted
using the following conventions:
- If the string begins with `^` and ends with `$`, it is converted
to a regex.
- If the string contains an asterisk (`*`), it is transformed from a
glob to a regex.
- Otherwise, an exact match to the string is sought.
Examples:
>>> str(MatchSpec(name='foo', build='py2*', channel='conda-forge'))
'conda-forge::foo[build=py2*]'
>>> str(MatchSpec('foo 1.0 py27_0'))
'foo==1.0=py27_0'
>>> str(MatchSpec('foo=1.0=py27_0'))
'foo==1.0=py27_0'
>>> str(MatchSpec('conda-forge::foo[version=1.0.*]'))
'conda-forge::foo=1.0'
>>> str(MatchSpec('conda-forge/linux-64::foo>=1.0'))
"conda-forge/linux-64::foo[version='>=1.0']"
>>> str(MatchSpec('*/linux-64::foo>=1.0'))
"foo[subdir=linux-64,version='>=1.0']"
To fully-specify a package with a full, exact spec, the fields
- channel
- subdir
- name
- version
- build
must be given as exact values. In the future, the namespace field will be
added to this list.
Alternatively, an exact spec is given by
'*[md5=12345678901234567890123456789012]'.
回到最初的例子:
feature:/win-64::__cuda==11.1=0
根据上面的MatchSpec
定义:
feature
- 虚拟包频道。
:/win-64
- 虚拟包通道子目录,表示系统是Windows操作系统的64位版本。
::
- 由于包含 channel
字段并且是一个精确值,因此 channel
和 name
之间使用了 ::
分隔符。
__cuda
- 虚拟包名称,在本例中指的是显示驱动程序规范。
==
- 精确版本匹配约束。
11.1
- 要匹配的确切 version
,包括 11.1、11.1.0、11.1.0.0 等
=0
- 由于 version
是精确版本,而 build
是精确值(在本例中为 0
),因此 =
符号是前置的。
我 运行 conda install 但它抛出以下错误:
UnsatisfiableError: The following specifications were found to be incompatible with your system:
- feature:/win-64::__cuda==11.1=0
Your installed version is: 11.1
我不是在问如何解决这个错误,而是这个语句是什么意思?
如何阅读feature:/win-64::__cuda==11.1=0
?
什么是 :/
、::
、__
? 11.1=0
是什么?
如果我安装的版本是 11.1,包是否需要 cuda 版本 0?
来自 managing virtual packages 上的 conda 文档:
Managing virtual packages
"Virtual" packages are injected into the conda solver to allow real packages to depend on features present on the system that cannot be managed directly by conda, like system driver versions or CPU features. Virtual packages are not real packages and not displayed by
conda list
. Insteadconda
runs a small bit of code to detect the presence or absence of the system feature that corresponds to the package. The currently supported list of virtual packages includes:
__cuda
: Maximum version of CUDA supported by the display driver.__osx
: OSX version if applicable.__glibc
: Version of glibc supported by the OS.
因此,feature
指的是系统功能,在本例中是指支持的显示驱动程序版本。
根据 conda package specification,__cuda==11.1
表示显示驱动程序必须与 cuda 版本 11.1、11.1.0、11.1.0.0 等之一完全匹配。
conda 包的 MatchSpec
查询语言
conda源代码文件match_spec.py定义了MatchSpec
class。此 class 的文档字符串包括 conda 包的技术规范。
`MatchSpec` is, fundamentally, a query language for conda packages. Any
of the fields that comprise a `PackageRecord` can be used to compose a
`MatchSpec`.
`MatchSpec` can be composed with keyword arguments, where keys are any of
the attributes of `PackageRecord`. Values for keyword arguments are the
exact values the attribute should match against. Many fields can also be
matched against non-exact values--by including wildcard `*` and `>`/`<`
ranges--where supported. Any non-specified field is the equivalent of a
full wildcard match.
`MatchSpec` can also be composed using a single positional argument, with
optional keyword arguments. Keyword arguments also override any
conflicting information provided in the positional argument. The
positional argument can be either an existing `MatchSpec` instance or a
string. Conda has historically had several string representations for
equivalent `MatchSpec`s. This `MatchSpec` should accept any existing
valid spec string, and correctly compose a `MatchSpec` instance.
A series of rules are now followed for creating the canonical string
representation of a `MatchSpec` instance. The canonical string
representation can generically be represented by
(channel(/subdir):(namespace):)name(version(build))[key1=value1,key2=value2]
where `()` indicate optional fields. The rules for constructing a
canonical string representation are:
1. `name` (i.e. "package name") is required, but its value can be '*'.
Its position is always outside the key-value brackets.
2. If `version` is an exact version, it goes outside the key-value
brackets and is prepended by `==`. If `version` is a "fuzzy" value
(e.g. `1.11.*`), it goes outside the key-value brackets with the
`.*` left off and is prepended by `=`. Otherwise `version` is
included inside key-value brackets.
3. If `version` is an exact version, and `build` is an exact value,
`build` goes outside key-value brackets prepended by a `=`.
Otherwise, `build` goes inside key-value brackets. `build_string`
is an alias for `build`.
4. The `namespace` position is being held for a future conda feature.
5. If `channel` is included and is an exact value, a `::` separator is
used between `channel` and `name`. `channel` can either be a
canonical channel name or a channel url. In the canonical string
representation, the canonical channel name will always be used.
6. If `channel` is an exact value and `subdir` is an exact value,
`subdir` is appended to `channel` with a `/` separator. Otherwise,
`subdir` is included in the key-value brackets.
7. Key-value brackets can be delimited by comma, space, or
comma+space. Value can optionally be wrapped in single or double
quotes, but must be wrapped if `value` contains a comma, space, or
equal sign. The canonical format uses comma delimiters and single
quotes.
8. When constructing a `MatchSpec` instance from a string, any
key-value pair given inside the key-value brackets overrides any
matching parameter given outside the brackets.
When `MatchSpec` attribute values are simple strings, the are interpreted
using the following conventions:
- If the string begins with `^` and ends with `$`, it is converted
to a regex.
- If the string contains an asterisk (`*`), it is transformed from a
glob to a regex.
- Otherwise, an exact match to the string is sought.
Examples:
>>> str(MatchSpec(name='foo', build='py2*', channel='conda-forge'))
'conda-forge::foo[build=py2*]'
>>> str(MatchSpec('foo 1.0 py27_0'))
'foo==1.0=py27_0'
>>> str(MatchSpec('foo=1.0=py27_0'))
'foo==1.0=py27_0'
>>> str(MatchSpec('conda-forge::foo[version=1.0.*]'))
'conda-forge::foo=1.0'
>>> str(MatchSpec('conda-forge/linux-64::foo>=1.0'))
"conda-forge/linux-64::foo[version='>=1.0']"
>>> str(MatchSpec('*/linux-64::foo>=1.0'))
"foo[subdir=linux-64,version='>=1.0']"
To fully-specify a package with a full, exact spec, the fields
- channel
- subdir
- name
- version
- build
must be given as exact values. In the future, the namespace field will be
added to this list.
Alternatively, an exact spec is given by
'*[md5=12345678901234567890123456789012]'.
回到最初的例子:
feature:/win-64::__cuda==11.1=0
根据上面的MatchSpec
定义:
feature
- 虚拟包频道。:/win-64
- 虚拟包通道子目录,表示系统是Windows操作系统的64位版本。::
- 由于包含channel
字段并且是一个精确值,因此channel
和name
之间使用了::
分隔符。__cuda
- 虚拟包名称,在本例中指的是显示驱动程序规范。==
- 精确版本匹配约束。11.1
- 要匹配的确切version
,包括 11.1、11.1.0、11.1.0.0 等=0
- 由于version
是精确版本,而build
是精确值(在本例中为0
),因此=
符号是前置的。