mirror of https://github.com/mamba-org/mamba.git
fix: Only register channels in the context once (#3521)
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
This commit is contained in:
parent
d2d16517ed
commit
bd8c1d2e4d
|
@ -257,8 +257,8 @@ set(
|
|||
${LIBMAMBA_SOURCE_DIR}/api/info.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/install.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/list.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/pip_utils.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/pip_utils.hpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/utils.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/utils.hpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/remove.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/repoquery.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/api/shell.cpp
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// The full license is in the file LICENSE, distributed with this software.
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "mamba/api/channel_loader.hpp"
|
||||
|
@ -26,7 +27,7 @@
|
|||
#include "mamba/util/path_manip.hpp"
|
||||
#include "mamba/util/string.hpp"
|
||||
|
||||
#include "pip_utils.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
||||
|
@ -377,7 +378,7 @@ namespace mamba
|
|||
Context& ctx,
|
||||
ChannelContext& channel_context,
|
||||
const Configuration& config,
|
||||
const std::vector<std::string>& specs,
|
||||
const std::vector<std::string>& raw_specs,
|
||||
bool create_env,
|
||||
bool remove_prefix_on_failure,
|
||||
bool is_retry
|
||||
|
@ -404,14 +405,7 @@ namespace mamba
|
|||
|
||||
MultiPackageCache package_caches{ ctx.pkgs_dirs, ctx.validation_params };
|
||||
|
||||
// add channels from specs
|
||||
for (const auto& s : specs)
|
||||
{
|
||||
if (auto ms = specs::MatchSpec::parse(s); ms && ms->channel().has_value())
|
||||
{
|
||||
ctx.channels.push_back(ms->channel()->str());
|
||||
}
|
||||
}
|
||||
populate_context_channels_from_specs(raw_specs, ctx);
|
||||
|
||||
if (ctx.channels.empty() && !ctx.offline)
|
||||
{
|
||||
|
@ -443,8 +437,8 @@ namespace mamba
|
|||
load_installed_packages_in_database(ctx, db, prefix_data);
|
||||
|
||||
|
||||
auto request = create_install_request(prefix_data, specs, freeze_installed);
|
||||
add_pins_to_request(request, ctx, prefix_data, specs, no_pin, no_py_pin);
|
||||
auto request = create_install_request(prefix_data, raw_specs, freeze_installed);
|
||||
add_pins_to_request(request, ctx, prefix_data, raw_specs, no_pin, no_py_pin);
|
||||
request.flags = ctx.solver_flags;
|
||||
|
||||
{
|
||||
|
@ -472,7 +466,7 @@ namespace mamba
|
|||
ctx,
|
||||
channel_context,
|
||||
config,
|
||||
specs,
|
||||
raw_specs,
|
||||
create_env,
|
||||
remove_prefix_on_failure,
|
||||
true
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "mamba/solver/libsolv/solver.hpp"
|
||||
#include "mamba/solver/request.hpp"
|
||||
|
||||
#include "pip_utils.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
||||
|
@ -150,14 +150,7 @@ namespace mamba
|
|||
|
||||
auto channel_context = ChannelContext::make_conda_compatible(ctx);
|
||||
|
||||
// add channels from specs
|
||||
for (const auto& s : raw_update_specs)
|
||||
{
|
||||
if (auto ms = specs::MatchSpec::parse(s); ms && ms->channel().has_value())
|
||||
{
|
||||
ctx.channels.push_back(ms->channel()->str());
|
||||
}
|
||||
}
|
||||
populate_context_channels_from_specs(raw_update_specs, ctx);
|
||||
|
||||
solver::libsolv::Database db{ channel_context.params() };
|
||||
add_spdlog_logger_to_database(db);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mamba/fs/filesystem.hpp"
|
||||
#include "mamba/util/environment.hpp"
|
||||
|
||||
#include "pip_utils.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
||||
|
@ -184,4 +184,26 @@ namespace mamba
|
|||
|
||||
return command;
|
||||
}
|
||||
|
||||
void
|
||||
populate_context_channels_from_specs(const std::vector<std::string>& raw_matchspecs, Context& context)
|
||||
{
|
||||
for (const auto& s : raw_matchspecs)
|
||||
{
|
||||
if (auto ms = specs::MatchSpec::parse(s); ms && ms->channel().has_value())
|
||||
{
|
||||
auto channel_name = ms->channel()->str();
|
||||
auto channel_is_absent = std::find(
|
||||
context.channels.begin(),
|
||||
context.channels.end(),
|
||||
channel_name
|
||||
)
|
||||
== context.channels.end();
|
||||
if (channel_is_absent)
|
||||
{
|
||||
context.channels.push_back(channel_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
//
|
||||
// The full license is in the file LICENSE, distributed with this software.
|
||||
|
||||
#ifndef MAMBA_PIP_UTILS_HPP
|
||||
#define MAMBA_PIP_UTILS_HPP
|
||||
#ifndef MAMBA_UTILS_HPP
|
||||
#define MAMBA_UTILS_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -39,6 +39,9 @@ namespace mamba
|
|||
pip::Update update
|
||||
);
|
||||
|
||||
void
|
||||
populate_context_channels_from_specs(const std::vector<std::string>& raw_matchspecs, Context& context);
|
||||
|
||||
}
|
||||
|
||||
#endif // MAMBA_PIP_UTILS_HPP
|
||||
#endif // MAMBA_UTILS_HPP
|
Loading…
Reference in New Issue