Skip to content

Commit dfe08cb

Browse files
costajohntjezdez
authored andcommitted
fix: guard cross-platform export spinner against noarch-only subdirs
1 parent 0f16735 commit dfe08cb

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

conda_libmamba_solver/solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _collect_all_metadata_spinner_message(
209209
return (
210210
f"Channels:\n"
211211
f" - {canonical_names_dashed}\n"
212-
f"Platform: {next(s for s in self.subdirs if s != 'noarch')}\n"
212+
f"Platform: {next((s for s in self.subdirs if s != 'noarch'), context.subdir)}\n"
213213
f"Collecting package metadata ({self._repodata_fn})"
214214
)
215215

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### Enhancements
2+
3+
* <news item>
4+
5+
### Bug fixes
6+
7+
* Show the target platform instead of the host platform in the progress
8+
message during cross-platform lockfile export. (#911)
9+
10+
### Deprecations
11+
12+
* <news item>
13+
14+
### Docs
15+
16+
* <news item>
17+
18+
### Other
19+
20+
* <news item>

tests/test_solver.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,53 @@ def test_pytorch_gpu(specs):
657657
raise AssertionError("No pytorch found")
658658

659659

660+
def test_cross_platform_spinner_shows_target_platform(tmp_path: Path) -> None:
661+
"""
662+
https://github.com/conda/conda-libmamba-solver/pull/911
663+
664+
When ``subdirs`` is set to a non-host platform, the ``Platform:`` line of
665+
the metadata-collection spinner message should show the target platform,
666+
not the host platform, and must never show ``noarch``.
667+
"""
668+
from conda.models.channel import Channel
669+
670+
target = "linux-64" if context.subdir != "linux-64" else "win-64"
671+
solver = Solver(
672+
prefix=tmp_path,
673+
channels=["conda-forge"],
674+
subdirs=(target, "noarch"),
675+
specs_to_add=["tzdata"],
676+
command="create",
677+
)
678+
message = solver._collect_all_metadata_spinner_message(
679+
channels=[Channel("conda-forge")]
680+
)
681+
assert f"Platform: {target}" in message
682+
assert "Platform: noarch" not in message
683+
684+
685+
def test_cross_platform_spinner_falls_back_when_only_noarch(tmp_path: Path) -> None:
686+
"""
687+
https://github.com/conda/conda-libmamba-solver/pull/911
688+
689+
If ``self.subdirs`` only contains ``noarch`` the spinner message must not
690+
raise ``StopIteration``; it should fall back to ``context.subdir``.
691+
"""
692+
from conda.models.channel import Channel
693+
694+
solver = Solver(
695+
prefix=tmp_path,
696+
channels=["conda-forge"],
697+
specs_to_add=["tzdata"],
698+
command="create",
699+
)
700+
solver.subdirs = ("noarch",)
701+
message = solver._collect_all_metadata_spinner_message(
702+
channels=[Channel("conda-forge")]
703+
)
704+
assert f"Platform: {context.subdir}" in message
705+
706+
660707
def test_channel_subdir_set_correctly(tmp_env: TmpEnvFixture) -> None:
661708
"""
662709
https://github.com/conda/conda-libmamba-solver/issues/662

0 commit comments

Comments
 (0)