Skip to content

Commit

Permalink
Add conda_build_local_paths to Context to set conda-bld paths
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Dec 18, 2023
1 parent 0cb1fb6 commit dc6f1e0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
3 changes: 3 additions & 0 deletions libmamba/include/mamba/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ namespace mamba
void set_verbosity(int lvl);
void set_log_level(log_level level);

std::vector<std::string> conda_build_local_paths;
std::vector<std::string> get_conda_build_local_paths() const;

protected:

Context();
Expand Down
10 changes: 10 additions & 0 deletions libmamba/src/api/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 1 addition & 6 deletions libmamba/src/core/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,7 @@ namespace mamba
m_custom_multichannels.emplace(DEFAULT_CHANNELS_NAME, std::move(default_names));

// Local channels
std::vector<std::string> local_channels = {
Context::instance().prefix_params.target_prefix.string() + "/conda-bld",
Context::instance().prefix_params.root_prefix.string() + "/conda-bld",
"~/conda-bld"
};

std::vector<std::string> local_channels = Context::instance().get_conda_build_local_paths();
std::vector<std::string> local_names;
local_names.reserve(local_channels.size());
for (const auto& p : local_channels)
Expand Down
14 changes: 14 additions & 0 deletions libmamba/src/core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,18 @@ namespace mamba
logger->dump_backtrace_no_guards();
}

std::vector<std::string> 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
8 changes: 8 additions & 0 deletions libmambapy/libmambapy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions libmambapy/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc6f1e0

Please sign in to comment.