Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9a5caa9
inject channels+mirrors coming from mambajs env-lockfiles
Klaim Dec 19, 2025
9822718
c++ tests
Klaim Dec 22, 2025
4e7e517
debug info from ci
Klaim Dec 22, 2025
957eb64
workaround incorrect compilers
Klaim Dec 22, 2025
7b4fcc4
debug info ci
Klaim Dec 22, 2025
542d4a9
channels urls/mirrors coming from the env-lockfile have higher priority
Klaim Dec 22, 2025
7e7b443
tweak url priority logic
Klaim Dec 22, 2025
2e6e11a
tweak ci debug info
Klaim Dec 22, 2025
eec22d4
fix wrong debug info
Klaim Dec 22, 2025
bbd62c0
fix attempt
Klaim Dec 23, 2025
1e7a721
fix attempt
Klaim Dec 23, 2025
cc33b17
fixup
Klaim Dec 23, 2025
f03eea2
attempt to figure out what's happening
Klaim Dec 23, 2025
127d543
workaround annoying warnings as error
Klaim Dec 23, 2025
19b4f15
attempt mirror added on top + no unicity filter
Klaim Dec 23, 2025
9f5e696
attempt to gather more data
Klaim Dec 23, 2025
cdd437d
tweak
Klaim Dec 23, 2025
b406463
experiment: valid prefix url
Klaim Dec 23, 2025
f3c3a02
tweak debug log
Klaim Jan 6, 2026
e3d78e5
tweak to confirm issue
Klaim Jan 6, 2026
61777ce
revert to correct behavior
Klaim Jan 6, 2026
576cc9f
Revert "experiment: valid prefix url"
Klaim Jan 6, 2026
4291726
tests: dont force default channel when testing env-lockfiles
Klaim Jan 6, 2026
0455438
improved error reports
Klaim Jan 6, 2026
4497b37
reactivated correct channel mirrors injection logic
Klaim Jan 6, 2026
6752936
attempt to fix failure with `--json` because packages info dont have …
Klaim Jan 8, 2026
8de30d4
fix attempt variation for --json
Klaim Jan 8, 2026
6464c70
add more context information for ci errors reports
Klaim Jan 9, 2026
cfa724d
added missing json log if dryrun
Klaim Jan 9, 2026
e8a7880
experiment: comment channel injection from mambajs lockfiles
Klaim Jan 9, 2026
58fbfe5
warning tweak
Klaim Jan 9, 2026
7be95fc
woops
Klaim Jan 9, 2026
04b665c
experiment; reactivate lockfile channels injection code but put the u…
Klaim Jan 9, 2026
c321596
restore intended code (fails on ci)
Klaim Jan 9, 2026
9fab071
make sure injected channels are taken into account through context an…
Klaim Jan 12, 2026
eefe9c4
removed test code impacting correctness in mambajs lockfile case
Klaim Jan 14, 2026
c494b0d
removed test assertion
Klaim Feb 3, 2026
0842dbd
experiment: deactivate the feature added here
Klaim Feb 5, 2026
99d0589
still experiment, remove warning
Klaim Feb 5, 2026
a686437
revert experiment, reenable feature
Klaim Feb 5, 2026
04e05fb
experiment please remove
Klaim Feb 6, 2026
c0acdb5
Revert "experiment please remove"
Klaim Feb 6, 2026
cb7e7a6
experiment more info
Klaim Feb 6, 2026
c75bb4c
tweaks might not be necessary
Klaim Feb 10, 2026
9a3d0bf
transaction: replace channel name resolution by looking into channels…
Klaim Feb 10, 2026
f7461cc
tests: added logs
Klaim Feb 10, 2026
1974ecb
test log tweak
Klaim Feb 10, 2026
207d85e
partial cleanup
Klaim Feb 11, 2026
8818faa
temporary experiment
Klaim Feb 11, 2026
d5163df
fixed typo
Klaim Feb 11, 2026
880adfb
formatting
Klaim Feb 11, 2026
4fd4b88
removed temporary experiment
Klaim Feb 11, 2026
8d763b6
formatting
Klaim Feb 11, 2026
3b2628e
wip
Klaim Feb 17, 2026
017ace8
back to using channel::resolve
Klaim Mar 16, 2026
b074b1c
formatting
Klaim Mar 16, 2026
e9fd889
determine env-lockfile packages missing urls before earlier
Klaim Mar 18, 2026
66b8e92
Lint
jjerphan May 12, 2026
a06274f
Move default parameter value from header to translation unit
jjerphan May 12, 2026
4c8c692
Merge remote-tracking branch 'origin/main' into env-lockfile-channels
Klaim Jun 17, 2026
36b10df
Merge remote-tracking branch 'origin/main' into env-lockfile-channels
Klaim Jun 23, 2026
3f533da
Merge remote-tracking branch 'origin/main' into env-lockfile-channels
Klaim Jun 30, 2026
90c2cf8
fixed: missing pacakge info channel url determination
Klaim Jul 1, 2026
714b51d
Merge remote-tracking branch 'origin/main' into env-lockfile-channels
Klaim Jul 1, 2026
b815459
attempt to fix history vs channel name ci issue
Klaim Jul 3, 2026
383401b
fixup "long_str()` needs to return a desc not an url
Klaim Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libmamba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ set(
# Filesystem library
${LIBMAMBA_INCLUDE_DIR}/mamba/fs/filesystem.hpp
# Utility library
${LIBMAMBA_INCLUDE_DIR}/mamba/util/algorithm.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/util/build.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/util/cast.hpp
${LIBMAMBA_INCLUDE_DIR}/mamba/util/cfile.hpp
Expand Down
7 changes: 6 additions & 1 deletion libmamba/include/mamba/api/channel_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vector>

#include "mamba/core/error_handling.hpp"
#include "mamba/specs/channel.hpp"
#include "mamba/solver/libsolv/repo_info.hpp"
#include "mamba/specs/package_info.hpp"
#include "mamba/specs/version.hpp"
Expand Down Expand Up @@ -113,7 +114,11 @@ namespace mamba
* Creates and stores channels in the ChannelContext,
* and mirrors objects in the Context object.
*/
void init_channels(Context& context, ChannelContext& channel_context);
void init_channels(
Context& context,
ChannelContext& channel_context,
specs::Channel::UrlPriority priority = specs::Channel::UrlPriority::low
);
void init_channels_from_package_urls(
Context& context,
ChannelContext& channel_context,
Expand Down
1 change: 1 addition & 0 deletions libmamba/include/mamba/core/channel_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace mamba
-> const channel_list&;

[[nodiscard]] auto params() const -> const specs::ChannelResolveParams&;
[[nodiscard]] auto zst_channels() const -> const std::vector<Channel>&;

[[nodiscard]] auto has_zst(const Channel& chan) const -> bool;

Expand Down
2 changes: 2 additions & 0 deletions libmamba/include/mamba/core/env_lockfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace mamba
std::vector<Channel> channels;
std::vector<std::string> platforms;
std::vector<std::string> sources;
bool enable_channels = true; ///< `true` if we need to take into account the specified
///< channels, `false` if we should ignore them.
};

struct Package
Expand Down
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ namespace mamba
);

MTransaction create_explicit_transaction_from_lockfile(
const Context& ctx,
Context& ctx,
ChannelContext& channel_context,
solver::libsolv::Database& database,
const fs::u8path& env_lockfile_path,
const std::vector<std::string>& categories,
Expand Down
7 changes: 6 additions & 1 deletion libmamba/include/mamba/download/mirror_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <unordered_map>

#include "mamba/download/mirror.hpp"
#include "mamba/specs/channel.hpp"
#include "mamba/util/iterator.hpp"

namespace mamba::download
Expand Down Expand Up @@ -47,7 +48,11 @@ namespace mamba::download

// Stores a provided Mirror IFF no other mirror is already registered with the same id for
// the specified mirror name. Returns true if the mirror has been stored, false otherwise.
bool add_unique_mirror(std::string_view mirror_name, mirror_ptr mirror);
bool add_unique_mirror(
std::string_view mirror_name,
mirror_ptr mirror,
specs::Channel::UrlPriority priority = specs::Channel::UrlPriority::low
);

// Copy mirrors for a given mirror name from another map. Used when building extended
// mirror maps (e.g. for shard downloads) that need to include channel mirrors.
Expand Down
23 changes: 18 additions & 5 deletions libmamba/include/mamba/specs/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ namespace mamba::specs
using platform_list = util::flat_set<std::string>;
using channel_list = std::vector<Channel>;

enum class UrlPriority
{
high, ///< associated urls will be placed in the front the list of urls
low ///< associated urls will be placed in the back the list of urls
};

[[nodiscard]] static auto resolve( //
UnresolvedChannel uc,
const ChannelResolveParams& params
Expand Down Expand Up @@ -74,6 +80,13 @@ namespace mamba::specs
auto clear_display_name() -> std::string;
void set_display_name(std::string display_name);

// Adds mirror urls if not already recorded, by default added at the end of the mirrors
// list.
void add_mirror_urls(
const std::vector<CondaURL>& additional_mirrors,
UrlPriority priority = UrlPriority::low
);

Comment on lines +83 to +89

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have the full context here, but if possible it would be best if these could be part of ChannelParams/resolve workflow.

The general idea of specs::Channel is that with resolve you always obtain what you want, (pure functional no mutable changes). This is because currently with libsolv hacks etc, specs::Channel are rather short-lived, converted back and forth to strings. I believe functions like set_platforms are use for only local reasoning.

enum struct Match
{
No,
Expand Down Expand Up @@ -137,11 +150,11 @@ namespace mamba::specs

struct ChannelResolveParamsView
{
const ChannelResolveParams::platform_list& platforms = {};
const CondaURL& channel_alias = {};
const ChannelResolveParams::channel_map& custom_channels = {};
const ChannelResolveParams::multichannel_map& custom_multichannels = {};
const AuthenticationDataBase& authentication_db = {};
const ChannelResolveParams::platform_list& platforms;
const CondaURL& channel_alias;
const ChannelResolveParams::channel_map& custom_channels;
const ChannelResolveParams::multichannel_map& custom_multichannels;
const AuthenticationDataBase& authentication_db;
std::string_view home_dir = {};
std::string_view current_working_dir = {};
};
Expand Down
24 changes: 24 additions & 0 deletions libmamba/include/mamba/specs/conda_url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef MAMBA_SPECS_CONDA_URL_HPP
#define MAMBA_SPECS_CONDA_URL_HPP

#include <concepts>
#include <functional>
#include <string_view>

Expand Down Expand Up @@ -251,6 +252,29 @@ namespace mamba::specs
{
auto operator""_cu(const char* str, std::size_t len) -> CondaURL;
}

/** Converts any range of `URL` into a view-range of `CondaURL` values. */
template <std::ranges::input_range URLRange>
requires std::same_as<std::ranges::range_value_t<URLRange>, util::URL>
auto as_conda_urls(URLRange&& values)
{
return std::views::transform(
std::forward<URLRange>(values),
[](const util::URL& url) { return CondaURL{ url }; }
);
}

/** Converts any range of string-like values into a view-range of `CondaURL` values based on
* it's constructor. */
template <std::ranges::input_range StringRange>
requires(
not std::same_as<std::ranges::range_value_t<StringRange>, util::URL>
) // TODO: or only string-like types?
auto as_conda_urls(StringRange&& values)
{
return as_conda_urls(util::as_urls(std::forward<StringRange>(values)));
}

}

template <>
Expand Down
57 changes: 57 additions & 0 deletions libmamba/include/mamba/util/algorithm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) 2025, QuantStack and Mamba Contributors
//
// Distributed under the terms of the BSD 3-Clause License.
//
// The full license is in the file LICENSE, distributed with this software.

//////////////////////////////////////////////////////////////////////////////
// This file provides implementations to generic algorithms which are not yet
// available in our current C++ version and/or implementations.
//
// TODO: replace these implementations by standard implementations
// once available.
//

#ifndef MAMBA_UTIL_ALGORITHM_HPP
#define MAMBA_UTIL_ALGORITHM_HPP

#include <algorithm>
#include <concepts>
#include <iterator>
#include <ranges>

namespace mamba::stdext // not using mamba::util because of potential conflicts with existing
// tooling
{
///////////////////////////////////////////////////////////////////////////////////////////////
// see https://en.cppreference.com/w/cpp/algorithm/ranges/contains.html
namespace details
{
struct contains_fn
{
template <std::input_iterator I, std::sentinel_for<I> S, class Proj = std::identity, class T>
requires std::indirect_binary_predicate<std::ranges::equal_to, std::projected<I, Proj>, const T*>
constexpr bool operator()(I first, S last, const T& value, Proj proj = {}) const
{
return std::ranges::find(std::move(first), last, value, proj) != last;
}

template <std::ranges::input_range R, class Proj = std::identity, class T>
requires std::indirect_binary_predicate<
std::ranges::equal_to,
std::projected<std::ranges::iterator_t<R>, Proj>,
const T*>
constexpr bool operator()(R&& r, const T& value, Proj proj = {}) const
{
return std::ranges::find(std::ranges::begin(r), std::ranges::end(r), value, proj)
!= std::ranges::end(r);
}
};
}

inline constexpr details::contains_fn contains{};

/////////////////////////////////////////////////////////////////////////////////////////////////

}
#endif
12 changes: 12 additions & 0 deletions libmamba/include/mamba/util/url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <array>
#include <functional>
#include <ranges>
#include <string>
#include <string_view>

Expand Down Expand Up @@ -293,6 +294,17 @@ namespace mamba::util
/** A functional equivalent to ``URL::append_path``. */
auto operator/(URL const& url, std::string_view subpath) -> URL;
auto operator/(URL&& url, std::string_view subpath) -> URL;

/** Converts any range of string-like values into a view-range of `URL` values. */
template <std::ranges::input_range StringRange>
auto as_urls(StringRange&& values)
{
return std::views::transform(
std::forward<StringRange>(values),
[](const auto& url) { return *URL::parse(url); }
);
}

}

template <>
Expand Down
33 changes: 20 additions & 13 deletions libmamba/src/api/channel_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ namespace mamba
}

// Forward declarations for helpers defined later in this namespace.
void create_mirrors(const specs::Channel& channel, download::mirror_map& mirrors);
void create_mirrors(
const specs::Channel& channel,
download::mirror_map& mirrors,
specs::Channel::UrlPriority priority = specs::Channel::UrlPriority::low
);

void create_subdirs(
Context& ctx,
Expand Down Expand Up @@ -1037,17 +1041,19 @@ namespace mamba
}
}

void create_mirrors(const specs::Channel& channel, download::mirror_map& mirrors)
void create_mirrors(
const specs::Channel& channel,
download::mirror_map& mirrors,
specs::Channel::UrlPriority priority
)
{
if (!mirrors.has_mirrors(channel.id()))
for (const specs::CondaURL& url : channel.mirror_urls())
{
for (const specs::CondaURL& url : channel.mirror_urls())
{
mirrors.add_unique_mirror(
channel.id(),
download::make_mirror(url.str(specs::CondaURL::Credentials::Show))
);
}
mirrors.add_unique_mirror(
channel.id(),
download::make_mirror(url.str(specs::CondaURL::Credentials::Show)),
priority
);
}
}

Expand Down Expand Up @@ -1164,14 +1170,15 @@ namespace mamba
);
}

void init_channels(Context& context, ChannelContext& channel_context)
void
init_channels(Context& context, ChannelContext& channel_context, specs::Channel::UrlPriority priority)
{
for (const auto& mirror : context.mirrored_channels)
{
for (const specs::Channel& channel :
channel_context.make_channel(mirror.first, mirror.second))
{
create_mirrors(channel, context.mirrors);
create_mirrors(channel, context.mirrors, priority);
}
}

Expand All @@ -1181,7 +1188,7 @@ namespace mamba
{
for (const specs::Channel& channel : channel_context.make_channel(location))
{
create_mirrors(channel, context.mirrors);
create_mirrors(channel, context.mirrors, priority);
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ namespace mamba
{
return create_explicit_transaction_from_lockfile(
ctx,
channel_context,
db,
file,
categories,
Expand Down Expand Up @@ -1254,15 +1255,18 @@ namespace mamba

auto execute_transaction = [&](MTransaction& transaction)
{
if (ctx.output_params.json)
{
transaction.log_json();
}

auto prompt_entry = transaction.prompt(ctx, channel_context);
if (prompt_entry)
{
transaction.execute(ctx, channel_context, prefix_data);
if (ctx.output_params.json)
{
transaction.log_json();
}
}
else if (ctx.output_params.json)
{
transaction.log_json();
}
return prompt_entry;
};
Expand Down
19 changes: 13 additions & 6 deletions libmamba/src/api/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,6 @@ namespace mamba
const std::function<void()>& on_abort
)
{
if (ctx.output_params.json)
{
transaction.log_json();
}
const auto should_execute = transaction.prompt(ctx, channel_context);
if (should_execute)
{
Expand All @@ -744,14 +740,25 @@ namespace mamba
before_execute();
}
transaction.execute(ctx, channel_context, prefix_data);
if (ctx.output_params.json)
{
transaction.log_json();
}
if (after_execute)
{
after_execute();
}
}
else if (on_abort)
else
{
on_abort();
if (ctx.output_params.json)
{
transaction.log_json();
}
if (on_abort)
{
on_abort();
}
}
return should_execute;
}
Expand Down
Loading
Loading