diff --git a/python/helpers/conda_packaging_tool.py b/python/helpers/conda_packaging_tool.py index 147334ab72ac..d35fb059bc7e 100644 --- a/python/helpers/conda_packaging_tool.py +++ b/python/helpers/conda_packaging_tool.py @@ -44,10 +44,8 @@ def _iter_packages(major_version, minor_version): objects (attribute access) instead of the legacy dict-like entries returned by ``get_index``. """ if major_version >= 25: - init_context() - from conda.core.subdir_data import SubdirData - for pkg in SubdirData.query_all('*'): - yield Pkg(name=pkg.name, version=pkg.version, depends=pkg.depends) + for pkg in _iter_packages_subdir_data(): + yield pkg return if major_version >= 22 or (major_version >= 4 and minor_version >= 4): @@ -68,6 +66,39 @@ def _iter_packages(major_version, minor_version): yield Pkg(name=pkg["name"], version=pkg["version"], depends=pkg["depends"]) +def _iter_packages_subdir_data(): + """Iterate package records via ``SubdirData`` for conda 25+. + + The ``SubdirData.query_all`` signature changed across releases: conda 25 accepts a single + positional ``MatchSpec`` and infers ``channels``/``subdirs`` from the current context, while + conda 26 made ``channels`` and ``subdirs`` required keyword arguments (passing only the spec + raises ``TypeError``). Try the modern explicit form first, then fall back to the older one. + """ + context = init_context() + from conda.core.subdir_data import SubdirData + try: + from conda.models.match_spec import MatchSpec + spec = MatchSpec("*") + except ImportError: + spec = "*" + + channels = getattr(context, "channels", None) if context is not None else None + subdirs = getattr(context, "subdirs", None) if context is not None else None + + records = None + if channels is not None and subdirs is not None: + try: + records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs) + except TypeError: + records = None + + if records is None: + records = SubdirData.query_all(spec) + + for pkg in records: + yield Pkg(name=pkg.name, version=pkg.version, depends=pkg.depends) + + def do_list_channels(): context = init_context() if context: diff --git a/python/python-test-env/common/src/com/intellij/python/test/env/common/PredefinedPyEnvironments.kt b/python/python-test-env/common/src/com/intellij/python/test/env/common/PredefinedPyEnvironments.kt index 58de322858f9..4618c37a77d3 100644 --- a/python/python-test-env/common/src/com/intellij/python/test/env/common/PredefinedPyEnvironments.kt +++ b/python/python-test-env/common/src/com/intellij/python/test/env/common/PredefinedPyEnvironments.kt @@ -211,6 +211,15 @@ enum class PredefinedPyEnvironments(val spec: PyEnvironmentSpec<*>) { */ CONDA_25(condaEnvironment("py312_25.11.1-1") { pythonVersion = pythonVersion("3.12") + }), + + /** + * Conda 26.x environment used by helper-script tests to verify that the index-loading + * code path continues to work on the latest major conda release. + * Tags: conda, conda26 + */ + CONDA_26(condaEnvironment("py312_26.5.3-1") { + pythonVersion = pythonVersion("3.12") }); companion object { @@ -241,7 +250,8 @@ enum class PredefinedPyEnvironments(val spec: PyEnvironmentSpec<*>) { VENV_3_14 to setOf("python3", "python3.14", "ruff"), VANILLA_3_14 to setOf("vanilla"), CONDA to setOf("conda"), - CONDA_25 to setOf("conda", "conda25") + CONDA_25 to setOf("conda", "conda25"), + CONDA_26 to setOf("conda", "conda26") ) } }