mirror of https://github.com/mamba-org/mamba.git
Make `self-update` a command for micromamba only (#3906)
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz> Co-authored-by: Klaim <Klaim@users.noreply.github.com>
This commit is contained in:
parent
3364c8e2d7
commit
f182c7bd3e
|
@ -102,6 +102,7 @@ endif()
|
|||
if(BUILD_STATIC)
|
||||
message(STATUS "Adding executable micromamba")
|
||||
mambaexe_create_target(micromamba STATIC micromamba)
|
||||
target_compile_definitions(micromamba PRIVATE BUILDING_MICROMAMBA)
|
||||
endif()
|
||||
|
||||
# Installation
|
||||
|
|
|
@ -51,8 +51,10 @@ set_umamba_command(CLI::App* com, mamba::Configuration& config)
|
|||
CLI::App* update_subcom = com->add_subcommand("update", "Update packages in active environment");
|
||||
set_update_command(update_subcom, config);
|
||||
|
||||
#ifdef BUILDING_MICROMAMBA
|
||||
CLI::App* self_update_subcom = com->add_subcommand("self-update", "Update micromamba");
|
||||
set_self_update_command(self_update_subcom, config);
|
||||
#endif
|
||||
|
||||
CLI::App* repoquery_subcom = com->add_subcommand(
|
||||
"repoquery",
|
||||
|
|
|
@ -52,8 +52,10 @@ set_umamba_command(CLI::App* com, mamba::Configuration& config);
|
|||
void
|
||||
set_update_command(CLI::App* subcom, mamba::Configuration& config);
|
||||
|
||||
#ifdef BUILDING_MICROMAMBA
|
||||
void
|
||||
set_self_update_command(CLI::App* subcom, mamba::Configuration& config);
|
||||
#endif
|
||||
|
||||
void
|
||||
set_repoquery_search_command(CLI::App* subcmd, mamba::Configuration& config);
|
||||
|
|
|
@ -27,6 +27,33 @@
|
|||
|
||||
using namespace mamba; // NOLINT(build/namespaces)
|
||||
|
||||
void
|
||||
set_update_command(CLI::App* subcom, Configuration& config)
|
||||
{
|
||||
init_install_options(subcom, config);
|
||||
|
||||
static bool prune_deps = true;
|
||||
static bool update_all = false;
|
||||
subcom->add_flag("--prune-deps,!--no-prune-deps", prune_deps, "Prune dependencies (default)");
|
||||
|
||||
subcom->get_option("specs")->description("Specs to update in the environment");
|
||||
subcom->add_flag("-a,--all", update_all, "Update all packages in the environment");
|
||||
|
||||
subcom->callback(
|
||||
[&]
|
||||
{
|
||||
auto update_params = UpdateParams{
|
||||
update_all ? UpdateAll::Yes : UpdateAll::No,
|
||||
prune_deps ? PruneDeps::Yes : PruneDeps::No,
|
||||
EnvUpdate::No,
|
||||
RemoveNotSpecified::No,
|
||||
};
|
||||
return update(config, update_params);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef BUILDING_MICROMAMBA
|
||||
namespace
|
||||
{
|
||||
auto database_has_package(solver::libsolv::Database& database, specs::MatchSpec spec) -> bool
|
||||
|
@ -197,32 +224,6 @@ update_self(Configuration& config, const std::optional<std::string>& version)
|
|||
return ec ? ec.value() : status;
|
||||
}
|
||||
|
||||
void
|
||||
set_update_command(CLI::App* subcom, Configuration& config)
|
||||
{
|
||||
init_install_options(subcom, config);
|
||||
|
||||
static bool prune_deps = true;
|
||||
static bool update_all = false;
|
||||
subcom->add_flag("--prune-deps,!--no-prune-deps", prune_deps, "Prune dependencies (default)");
|
||||
|
||||
subcom->get_option("specs")->description("Specs to update in the environment");
|
||||
subcom->add_flag("-a,--all", update_all, "Update all packages in the environment");
|
||||
|
||||
subcom->callback(
|
||||
[&]
|
||||
{
|
||||
auto update_params = UpdateParams{
|
||||
update_all ? UpdateAll::Yes : UpdateAll::No,
|
||||
prune_deps ? PruneDeps::Yes : PruneDeps::No,
|
||||
EnvUpdate::No,
|
||||
RemoveNotSpecified::No,
|
||||
};
|
||||
return update(config, update_params);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
set_self_update_command(CLI::App* subcom, Configuration& config)
|
||||
{
|
||||
|
@ -234,3 +235,4 @@ set_self_update_command(CLI::App* subcom, Configuration& config)
|
|||
|
||||
subcom->callback([&] { return update_self(config, version); });
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -901,6 +901,10 @@ def tmp_umamba():
|
|||
os.chmod(mamba_exe, 0o755)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
"micromamba" not in Path(helpers.get_umamba()).stem,
|
||||
reason="micromamba-only test",
|
||||
)
|
||||
@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
|
||||
@pytest.mark.parametrize("interpreter", get_self_update_interpreters())
|
||||
def test_self_update(
|
||||
|
|
Loading…
Reference in New Issue