Skip to content

Commit 5f35601

Browse files
costajohntjezdez
andauthored
Show target platform instead of host in cross-platform export (#911)
Co-authored-by: Jannis Leidel <jannis@leidel.info>
1 parent 947b7b6 commit 5f35601

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: {context.subdir}\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+
_CROSS_PLATFORM_TARGET = "linux-64" if context.subdir != "linux-64" else "win-64"
661+
662+
663+
@pytest.mark.parametrize(
664+
"subdirs,expected_platform",
665+
(
666+
pytest.param(
667+
(_CROSS_PLATFORM_TARGET, "noarch"),
668+
_CROSS_PLATFORM_TARGET,
669+
id="cross-platform-target",
670+
),
671+
pytest.param(
672+
("noarch",),
673+
context.subdir,
674+
id="noarch-only-fallback",
675+
),
676+
),
677+
)
678+
def test_cross_platform_spinner_message(
679+
tmp_path: Path,
680+
subdirs: tuple[str, ...],
681+
expected_platform: str,
682+
) -> None:
683+
"""
684+
https://github.com/conda/conda-libmamba-solver/pull/911
685+
686+
The ``Platform:`` line of the metadata-collection spinner message should
687+
show the first non-``noarch`` entry of ``self.subdirs`` (the actual
688+
target platform during cross-platform export) and fall back to
689+
``context.subdir`` when ``self.subdirs`` only contains ``noarch``.
690+
"""
691+
from conda.models.channel import Channel
692+
693+
solver = Solver(
694+
prefix=tmp_path,
695+
channels=["conda-forge"],
696+
specs_to_add=["tzdata"],
697+
command="create",
698+
)
699+
# Assign after construction so the noarch-only case bypasses the
700+
# ``next(s for s in self.subdirs if s != "noarch")`` call in ``__init__``.
701+
solver.subdirs = subdirs
702+
message = solver._collect_all_metadata_spinner_message(channels=[Channel("conda-forge")])
703+
assert f"Platform: {expected_platform}" in message
704+
assert "Platform: noarch" not 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)