mirror of https://github.com/mamba-org/mamba.git
Remove ChannelContext ctor (#3002)
This commit is contained in:
parent
1ee4893eeb
commit
acd357df95
|
@ -7,6 +7,7 @@
|
||||||
#ifndef MAMBA_CORE_CHANNEL_HPP
|
#ifndef MAMBA_CORE_CHANNEL_HPP
|
||||||
#define MAMBA_CORE_CHANNEL_HPP
|
#define MAMBA_CORE_CHANNEL_HPP
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
@ -38,8 +39,6 @@ namespace mamba
|
||||||
*/
|
*/
|
||||||
ChannelContext(Context& ctx, ChannelResolveParams params);
|
ChannelContext(Context& ctx, ChannelResolveParams params);
|
||||||
|
|
||||||
explicit ChannelContext(Context& ctx);
|
|
||||||
|
|
||||||
auto make_channel(std::string_view name) -> const channel_list&;
|
auto make_channel(std::string_view name) -> const channel_list&;
|
||||||
|
|
||||||
[[nodiscard]] auto params() const -> const specs::ChannelResolveParams&;
|
[[nodiscard]] auto params() const -> const specs::ChannelResolveParams&;
|
||||||
|
@ -52,7 +51,7 @@ namespace mamba
|
||||||
|
|
||||||
ChannelResolveParams m_channel_params;
|
ChannelResolveParams m_channel_params;
|
||||||
ChannelCache m_channel_cache;
|
ChannelCache m_channel_cache;
|
||||||
const Context& m_context;
|
std::reference_wrapper<const Context> m_context;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -96,14 +96,6 @@ namespace mamba
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelContext::ChannelContext(Context& context)
|
|
||||||
: m_channel_params(make_simple_params_base(context))
|
|
||||||
, m_context(context)
|
|
||||||
{
|
|
||||||
add_conda_params_custom_channel(m_channel_params, m_context);
|
|
||||||
add_simple_params_custom_multichannel(m_channel_params, m_context);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelContext::ChannelContext(Context& context, ChannelResolveParams params)
|
ChannelContext::ChannelContext(Context& context, ChannelResolveParams params)
|
||||||
: m_channel_params(std::move(params))
|
: m_channel_params(std::move(params))
|
||||||
, m_context(context)
|
, m_context(context)
|
||||||
|
|
|
@ -126,7 +126,10 @@ namespace mambapy
|
||||||
}
|
}
|
||||||
mamba::ChannelContext& channel_context()
|
mamba::ChannelContext& channel_context()
|
||||||
{
|
{
|
||||||
return init_once(p_channel_context, m_context);
|
return init_once(
|
||||||
|
p_channel_context,
|
||||||
|
[&]() { return mamba::ChannelContext::make_conda_compatible(m_context); }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
mamba::Configuration& config()
|
mamba::Configuration& config()
|
||||||
|
@ -136,11 +139,11 @@ namespace mambapy
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template <class T, class D>
|
template <class T, class D, class Factory>
|
||||||
T& init_once(std::unique_ptr<T, D>& ptr, mamba::Context& context)
|
T& init_once(std::unique_ptr<T, D>& ptr, Factory&& factory)
|
||||||
{
|
{
|
||||||
static std::once_flag init_flag;
|
static std::once_flag init_flag;
|
||||||
std::call_once(init_flag, [&] { ptr = std::make_unique<T>(context); });
|
std::call_once(init_flag, [&] { ptr = std::make_unique<T>(factory()); });
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
throw mamba::mamba_error(
|
throw mamba::mamba_error(
|
||||||
|
|
Loading…
Reference in New Issue