From dc6f1e0a2f7178b821d18870980cc13dfcf7d0bd Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 18 Dec 2023 11:20:40 +0530 Subject: [PATCH] Add conda_build_local_paths to Context to set conda-bld paths --- libmamba/include/mamba/core/context.hpp | 3 +++ libmamba/src/api/configuration.cpp | 10 ++++++++++ libmamba/src/core/channel.cpp | 7 +------ libmamba/src/core/context.cpp | 14 ++++++++++++++ libmambapy/libmambapy/__init__.pyi | 8 ++++++++ libmambapy/src/main.cpp | 1 + 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/libmamba/include/mamba/core/context.hpp b/libmamba/include/mamba/core/context.hpp index 79b7473db7..0bca620e56 100644 --- a/libmamba/include/mamba/core/context.hpp +++ b/libmamba/include/mamba/core/context.hpp @@ -248,6 +248,9 @@ namespace mamba void set_verbosity(int lvl); void set_log_level(log_level level); + std::vector conda_build_local_paths; + std::vector get_conda_build_local_paths() const; + protected: Context(); diff --git a/libmamba/src/api/configuration.cpp b/libmamba/src/api/configuration.cpp index a3b34337d1..5a79afd901 100644 --- a/libmamba/src/api/configuration.cpp +++ b/libmamba/src/api/configuration.cpp @@ -1225,6 +1225,16 @@ namespace mamba The list of channel names and/or urls used for the 'defaults' multichannel.)"))); + insert(Configurable("conda_build_local_paths", &ctx.conda_build_local_paths) + .group("Channels") + .description("Locations of conda-bld artifacts") + .long_description(unindent(R"( + The list of locations where conda-bld artifacts may be located. + This list will create a multichannel with the name 'local'. + This is configurable only from the API and is intended to be + used by applications to configure conda-bld paths and not by + users of mamba.)"))); + insert(Configurable("custom_channels", &ctx.custom_channels) .group("Channels") .set_rc_configurable() diff --git a/libmamba/src/core/channel.cpp b/libmamba/src/core/channel.cpp index 20a07eb3f7..64642daf1c 100644 --- a/libmamba/src/core/channel.cpp +++ b/libmamba/src/core/channel.cpp @@ -736,12 +736,7 @@ namespace mamba m_custom_multichannels.emplace(DEFAULT_CHANNELS_NAME, std::move(default_names)); // Local channels - std::vector local_channels = { - Context::instance().prefix_params.target_prefix.string() + "/conda-bld", - Context::instance().prefix_params.root_prefix.string() + "/conda-bld", - "~/conda-bld" - }; - + std::vector local_channels = Context::instance().get_conda_build_local_paths(); std::vector local_names; local_names.reserve(local_channels.size()); for (const auto& p : local_channels) diff --git a/libmamba/src/core/context.cpp b/libmamba/src/core/context.cpp index bc6254976f..3a7cd9ee3e 100644 --- a/libmamba/src/core/context.cpp +++ b/libmamba/src/core/context.cpp @@ -366,4 +366,18 @@ namespace mamba logger->dump_backtrace_no_guards(); } + std::vector Context::get_conda_build_local_paths() const + { + if (conda_build_local_paths.empty()) + { + return { prefix_params.target_prefix.string() + "/conda-bld", + prefix_params.root_prefix.string() + "/conda-bld", + "~/conda-bld" }; + } + else + { + return conda_build_local_paths; + } + } + } // namespace mamba diff --git a/libmambapy/libmambapy/__init__.pyi b/libmambapy/libmambapy/__init__.pyi index d4bd5a303f..2f701afa95 100644 --- a/libmambapy/libmambapy/__init__.pyi +++ b/libmambapy/libmambapy/__init__.pyi @@ -564,6 +564,14 @@ class Context: def channels(self, arg0: typing.List[str]) -> None: pass @property + def conda_build_local_paths(self) -> typing.List[str]: + """ + :type: typing.List[str] + """ + @conda_build_local_paths.setter + def conda_build_local_paths(self, arg0: typing.List[str]) -> None: + pass + @property def conda_prefix(self) -> Path: """ :type: Path diff --git a/libmambapy/src/main.cpp b/libmambapy/src/main.cpp index c4a5afab3e..bb11397874 100644 --- a/libmambapy/src/main.cpp +++ b/libmambapy/src/main.cpp @@ -543,6 +543,7 @@ PYBIND11_MODULE(bindings, m) .def_readwrite("custom_channels", &Context::custom_channels) .def_readwrite("custom_multichannels", &Context::custom_multichannels) .def_readwrite("default_channels", &Context::default_channels) + .def_readwrite("conda_build_local_paths", &Context::conda_build_local_paths) .def_readwrite("channel_alias", &Context::channel_alias) .def_readwrite("use_only_tar_bz2", &Context::use_only_tar_bz2) .def_readwrite("channel_priority", &Context::channel_priority)