WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3cae9e3

Browse files
jaimergpjezdezisuruf
authored
Fix empty channels being passed to solver handling _h_env creation (#5857)
* Use Index.expanded_channels instead of LAST_CHANNEL_URLS hack * pre-commit * add news * Remove old `Index` imports * update news * Apply suggestion from @isuruf Co-authored-by: Isuru Fernando <[email protected]> --------- Co-authored-by: Jannis Leidel <[email protected]> Co-authored-by: Isuru Fernando <[email protected]>
1 parent 9b03961 commit 3cae9e3

File tree

5 files changed

+28
-48
lines changed

5 files changed

+28
-48
lines changed

conda_build/environ.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
)
2626
from conda.base.context import context, reset_context
2727
from conda.common.io import env_vars
28-
from conda.core.index import LAST_CHANNEL_URLS
2928
from conda.core.link import PrefixSetup, UnlinkLinkTransaction
3029
from conda.core.package_cache_data import PackageCacheData, ProgressiveFetchExtract
3130
from conda.core.prefix_data import PrefixData
@@ -38,7 +37,7 @@
3837
UnsatisfiableError,
3938
)
4039
from conda.gateways.disk.create import TemporaryDirectory
41-
from conda.models.channel import Channel, prioritize_channels
40+
from conda.models.channel import Channel
4241
from conda.models.match_spec import MatchSpec
4342
from conda.models.records import PackageRecord
4443

@@ -62,6 +61,8 @@
6261
from pathlib import Path
6362
from typing import Any, TypedDict
6463

64+
from conda.core.index import Index
65+
6566
from .config import Config
6667
from .metadata import MetaData
6768

@@ -1262,7 +1263,7 @@ def get_pinned_deps(m, section):
12621263
# checks for this name in the call stack explicitly.
12631264
def install_actions(
12641265
prefix: str | os.PathLike | Path,
1265-
index,
1266+
index: Index,
12661267
specs: Iterable[str | MatchSpec],
12671268
subdir: str | None = None,
12681269
) -> InstallActionsType:
@@ -1280,25 +1281,8 @@ def install_actions(
12801281
},
12811282
callback=reset_context,
12821283
):
1283-
# a hack since in conda-build we don't track channel_priority_map
1284-
channels: tuple[Channel, ...] | None
1285-
subdirs: tuple[str, ...] | None
1286-
if LAST_CHANNEL_URLS:
1287-
channel_priority_map = prioritize_channels(LAST_CHANNEL_URLS)
1288-
# tuple(dict.fromkeys(...)) removes duplicates while preserving input order.
1289-
channels = tuple(
1290-
dict.fromkeys(Channel(url) for url in channel_priority_map)
1291-
)
1292-
subdirs = (
1293-
tuple(
1294-
dict.fromkeys(
1295-
subdir for channel in channels if (subdir := channel.subdir)
1296-
)
1297-
)
1298-
or context.subdirs
1299-
)
1300-
else:
1301-
channels = subdirs = None
1284+
channels: tuple[Channel, ...] | None = tuple(index.expanded_channels) or None
1285+
subdirs: tuple[str, ...] | None = tuple(index._subdirs) or None
13021286

13031287
mspecs = tuple(MatchSpec(spec) for spec in specs)
13041288

conda_build/index.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import os
77
from functools import partial
88
from os.path import dirname
9-
from typing import TYPE_CHECKING
109

1110
from conda.base.context import context
11+
from conda.core.index import Index
1212
from conda.exceptions import CondaHTTPError
1313
from conda.utils import url_path
1414

@@ -17,9 +17,6 @@
1717
get_logger,
1818
)
1919

20-
if TYPE_CHECKING:
21-
from conda.models.channels import Channel
22-
2320
try:
2421
from conda_index.index import update_index as _update_index
2522
except ImportError:
@@ -28,16 +25,6 @@
2825
)
2926

3027

31-
try:
32-
from conda.core.index import Index
33-
except ImportError:
34-
# FUTURE: remove for `conda >=24.9`
35-
from conda.core.index import get_index
36-
37-
def Index(channels: tuple[str | Channel, ...] = (), *args, **kwargs) -> dict: # type: ignore[no-redef]
38-
return get_index(channel_urls=channels, *args, **kwargs)
39-
40-
4128
log = get_logger(__name__)
4229

4330

conda_build/inspect_pkg.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from conda.api import Solver
1717
from conda.base.context import context
1818
from conda.cli.common import specs_from_args
19+
from conda.core.index import Index
1920
from conda.core.prefix_data import PrefixData
2021
from conda.models.records import PrefixRecord
2122

@@ -37,12 +38,6 @@
3738
package_has_file,
3839
)
3940

40-
try:
41-
from conda.core.index import Index
42-
except ImportError:
43-
# FUTURE: remove for `conda >=24.9`
44-
from conda_build.index import Index
45-
4641
if TYPE_CHECKING:
4742
from collections.abc import Iterable
4843
from typing import Literal

conda_build/skeletons/cpan.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from os.path import basename, dirname, exists, join
2222

2323
import requests
24+
from conda.core.index import Index
2425
from conda.exceptions import CondaError, CondaHTTPError
2526
from conda.gateways.connection.download import TmpDownload, download
2627
from conda.gateways.disk.create import TemporaryDirectory
@@ -33,12 +34,6 @@
3334
from ..variants import get_default_variant
3435
from ..version import _parse as parse_version
3536

36-
try:
37-
from conda.core.index import Index
38-
except ImportError:
39-
# FUTURE: remove for `conda >=24.9`
40-
from conda_build.index import Index
41-
4237
CPAN_META = """\
4338
{{% set name = "{packagename}" %}}
4439
{{% set version = "{version}" %}}

news/5857-empty-channels.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Enhancements
2+
3+
* <news item>
4+
5+
### Bug fixes
6+
7+
* Prevent empty channel lists from being passed to host environment creation. (#5857)
8+
9+
### Deprecations
10+
11+
* Remove fallback imports for `conda.core.index.Index`. (#5857)
12+
13+
### Docs
14+
15+
* <news item>
16+
17+
### Other
18+
19+
* <news item>

0 commit comments

Comments
 (0)