Skip to content

Commit

Permalink
gracefully handle conflicting names in yaml specs (#3083)
Browse files Browse the repository at this point in the history
* Revert "Remove hard coded mamba (#3069)"

This reverts commit 212d1e9.

* gracefully handle conflicting names in yaml specs

* Revert "Revert "Remove hard coded mamba (#3069)""

This reverts commit b5717e6.
  • Loading branch information
jchorl committed Dec 27, 2023
1 parent a7a92f3 commit bcf8141
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,10 +889,10 @@ namespace mamba
{
env_name.set_cli_yaml_value(parse_result.name);
}
else if (parse_result.name.size() != 0 && parse_result.name != env_name.value<std::string>())
else if (parse_result.name.size() != 0 && parse_result.name != env_name.cli_value<std::string>())
{
LOG_WARNING << "YAML specs have different environment names. Using "
<< env_name.value<std::string>();
<< env_name.cli_value<std::string>();
}

if (parse_result.dependencies.size() != 0)
Expand Down
22 changes: 22 additions & 0 deletions micromamba/tests/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@ def test_multiple_yaml_specs_only_one_has_channels(tmp_home, tmp_root_prefix, tm
assert res["specs"] == ["xtensor", "xsimd"]


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_multiple_yaml_specs_different_names(tmp_home, tmp_root_prefix, tmp_path):
env_prefix = tmp_path / "myenv"

cmd = ["-p", env_prefix]

spec_file_1 = tmp_path / "env1.yaml"
spec_file_1.write_text("name: env1\ndependencies: [xtensor]")

spec_file_2 = tmp_path / "env2.yaml"
spec_file_2.write_text(
"name: env2\ndependencies: [xsimd]\nchannels: [bioconda]",
)

cmd += ["-f", spec_file_1, "-f", spec_file_2]

res = helpers.create(*cmd, "--print-config-only", default_channel=False)
assert res["spec_file_env_name"] == "env1"
assert res["channels"] == ["bioconda"]
assert res["specs"] == ["xtensor", "xsimd"]


@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
def test_multiprocessing(tmp_home, tmp_root_prefix):
if platform.system() == "Windows":
Expand Down

0 comments on commit bcf8141

Please sign in to comment.