mirror of https://github.com/mamba-org/mamba.git
Create empty base prefix with `env update` (#3519)
This commit is contained in:
parent
c329ca0401
commit
3d71f57517
|
@ -131,6 +131,11 @@ namespace mamba
|
|||
{
|
||||
auto& ctx = config.context();
|
||||
|
||||
// `env update` case
|
||||
if (update_params.env_update == EnvUpdate::Yes)
|
||||
{
|
||||
config.at("create_base").set_value(true);
|
||||
}
|
||||
config.at("use_target_prefix_fallback").set_value(true);
|
||||
config.at("use_default_prefix_fallback").set_value(true);
|
||||
config.at("use_root_prefix_fallback").set_value(true);
|
||||
|
|
|
@ -410,3 +410,31 @@ def test_env_create_whitespace(tmp_home, tmp_root_prefix, tmp_path):
|
|||
package["name"] == "scikit-learn" and Version(package["version"]) > Version("1.0.0")
|
||||
for package in packages
|
||||
)
|
||||
|
||||
|
||||
env_yaml_content_to_update_empty_base = """
|
||||
channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- python
|
||||
- xtensor
|
||||
"""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
|
||||
def test_env_update_empty_base(tmp_home, tmp_root_prefix, tmp_path):
|
||||
env_prefix = tmp_path / "env-update-empty-base"
|
||||
|
||||
os.environ["MAMBA_ROOT_PREFIX"] = str(env_prefix)
|
||||
|
||||
env_file_yml = tmp_path / "test_env_empty_base.yaml"
|
||||
env_file_yml.write_text(env_yaml_content_to_update_empty_base)
|
||||
|
||||
cmd = ["update", "-p", env_prefix, f"--file={env_file_yml}", "-y", "--json"]
|
||||
|
||||
res = helpers.run_env(*cmd)
|
||||
assert res["success"]
|
||||
|
||||
packages = helpers.umamba_list("-p", env_prefix, "--json")
|
||||
assert any(package["name"] == "xtensor" for package in packages)
|
||||
assert any(package["name"] == "python" for package in packages)
|
||||
|
|
|
@ -741,3 +741,30 @@ def test_reinstall_with_new_version(tmp_home, tmp_root_prefix):
|
|||
|
||||
res = helpers.umamba_run("-n", env_name, "python", "-c", "import pip; print(pip.__version__)")
|
||||
assert len(res)
|
||||
|
||||
|
||||
env_yaml_content_to_install_empty_base = """
|
||||
channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- python
|
||||
- xtensor
|
||||
"""
|
||||
|
||||
|
||||
def test_install_empty_base(tmp_home, tmp_root_prefix, tmp_path):
|
||||
env_prefix = tmp_path / "env-install-empty-base"
|
||||
|
||||
os.environ["MAMBA_ROOT_PREFIX"] = str(env_prefix)
|
||||
|
||||
env_file_yml = tmp_path / "test_install_env_empty_base.yaml"
|
||||
env_file_yml.write_text(env_yaml_content_to_install_empty_base)
|
||||
|
||||
cmd = ["-p", env_prefix, f"--file={env_file_yml}", "-y", "--json"]
|
||||
|
||||
res = helpers.install(*cmd)
|
||||
assert res["success"]
|
||||
|
||||
packages = helpers.umamba_list("-p", env_prefix, "--json")
|
||||
assert any(package["name"] == "xtensor" for package in packages)
|
||||
assert any(package["name"] == "python" for package in packages)
|
||||
|
|
Loading…
Reference in New Issue