Skip to content

Commit cb4f6bd

Browse files
authored
Merge branch 'main' into fix-etc/profile.d
2 parents fb3ee20 + 2e0ac1a commit cb4f6bd

File tree

17 files changed

+344
-264
lines changed

17 files changed

+344
-264
lines changed

dev/environment-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies:
5353
- scikit-build-core
5454
# libmambapy dependencies
5555
- python
56-
- pybind11<3.0.0
56+
- pybind11>=3.0.0
5757
# libmambapy-stubs build dependencies
5858
- mypy # For stubgen
5959
- setuptools

libmamba/ext/solv-cpp/src/repo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace solv
101101
{
102102
return tl::unexpected(std::string(str));
103103
}
104-
return tl::unexpected("Unknow error");
104+
return tl::unexpected("Unknown error");
105105
}
106106

107107
/***********************************
@@ -135,7 +135,7 @@ namespace solv
135135
{
136136
return tl::unexpected(std::string(str));
137137
}
138-
return tl::unexpected("Unknow error");
138+
return tl::unexpected("Unknown error");
139139
}
140140

141141
auto ObjRepoView::legacy_read_conda_repodata(std::FILE* repodata_file, int flags) const
@@ -150,7 +150,7 @@ namespace solv
150150
{
151151
return tl::unexpected(std::string(str));
152152
}
153-
return tl::unexpected("Unknow error");
153+
return tl::unexpected("Unknown error");
154154
}
155155

156156
auto ObjRepoView::add_solvable() const -> std::pair<SolvableId, ObjSolvableView>

libmamba/src/api/channel_loader.cpp

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -269,31 +269,25 @@ namespace mamba
269269
continue;
270270
}
271271

272-
load_subdir_in_database(ctx, database, subdir)
273-
.transform([&](solver::libsolv::RepoInfo&& repo)
274-
{ database.set_repo_priority(repo, priorities[i]); })
275-
.or_else(
276-
[&](const auto&)
277-
{
278-
if (is_retry)
279-
{
280-
std::stringstream ss;
281-
ss << "Could not load repodata.json for " << subdir.name()
282-
<< " after retry." << "Please check repodata source. Exiting."
283-
<< std::endl;
284-
error_list.push_back(
285-
mamba_error(ss.str(), mamba_error_code::repodata_not_loaded)
286-
);
287-
}
288-
else
289-
{
290-
LOG_WARNING << "Could not load repodata.json for " << subdir.name()
291-
<< ". Deleting cache, and retrying.";
292-
subdir.clear_valid_cache_files();
293-
loading_failed = true;
294-
}
295-
}
296-
);
272+
auto result = load_subdir_in_database(ctx, database, subdir);
273+
if (result)
274+
{
275+
database.set_repo_priority(std::move(result).value(), priorities[i]);
276+
}
277+
else if (is_retry)
278+
{
279+
std::stringstream ss;
280+
ss << "Could not load repodata.json for " << subdir.name() << " after retry."
281+
<< "Please check repodata source. Exiting." << std::endl;
282+
error_list.push_back(mamba_error(ss.str(), mamba_error_code::repodata_not_loaded));
283+
}
284+
else
285+
{
286+
LOG_WARNING << "Could not load repodata.json for " << subdir.name()
287+
<< ". Deleting cache, and retrying.";
288+
subdir.clear_valid_cache_files();
289+
loading_failed = true;
290+
}
297291
}
298292

299293
if (loading_failed)

libmamba/src/api/configuration.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <algorithm>
88
#include <iostream>
9-
#include <regex>
109
#include <stdexcept>
1110

1211
#include <nlohmann/json.hpp>
@@ -746,11 +745,17 @@ namespace mamba
746745
// and ``micromamba``, as well as consistency with ``MAMBA_`` environment variables.
747746
const fs::u8path default_root_prefix_v2 = fs::u8path(util::user_data_dir()) / "mamba";
748747

749-
validate_existing_root_prefix(default_root_prefix_v1)
750-
.or_else([&default_root_prefix_v2](const auto& /* error */)
751-
{ return validate_root_prefix(default_root_prefix_v2); })
752-
.transform([&](fs::u8path&& p) { root_prefix = std::move(p); })
753-
.or_else([](mamba_error&& error) { throw std::move(error); });
748+
auto result = validate_existing_root_prefix(default_root_prefix_v1)
749+
.or_else([&default_root_prefix_v2](const auto& /* error */)
750+
{ return validate_root_prefix(default_root_prefix_v2); });
751+
if (result)
752+
{
753+
root_prefix = std::move(result).value();
754+
}
755+
else
756+
{
757+
throw std::move(result).value();
758+
}
754759

755760
LOG_TRACE << "Using default root prefix for micromamba: " << root_prefix;
756761
#endif

libmamba/src/api/install.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,12 @@ namespace mamba
694694
for (auto other_spec : config.at("others_pkg_mgrs_specs")
695695
.value<std::vector<detail::other_pkg_mgr_spec>>())
696696
{
697-
install_for_other_pkgmgr(ctx, other_spec, pip::Update::No);
697+
auto result = install_for_other_pkgmgr(ctx, other_spec, pip::Update::No);
698+
if (!result)
699+
{
700+
static_assert(std::is_base_of_v<std::exception, decltype(result)::error_type>);
701+
throw std::move(result).error();
702+
}
698703
}
699704
}
700705
}
@@ -808,7 +813,12 @@ namespace mamba
808813

809814
for (auto other_spec : others)
810815
{
811-
install_for_other_pkgmgr(ctx, other_spec, pip::Update::No);
816+
auto result = install_for_other_pkgmgr(ctx, other_spec, pip::Update::No);
817+
if (!result.has_value())
818+
{
819+
static_assert(std::is_base_of_v<std::exception, decltype(result)::error_type>);
820+
throw std::move(result).error();
821+
}
812822
}
813823
}
814824
else

libmamba/src/api/update.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ namespace mamba
259259
for (auto other_spec :
260260
config.at("others_pkg_mgrs_specs").value<std::vector<detail::other_pkg_mgr_spec>>())
261261
{
262-
install_for_other_pkgmgr(ctx, other_spec, pip::Update::Yes);
262+
auto result = install_for_other_pkgmgr(ctx, other_spec, pip::Update::Yes);
263+
if (!result.has_value())
264+
{
265+
static_assert(std::is_base_of_v<std::exception, decltype(result)::error_type>);
266+
throw std::move(result).error();
267+
}
263268
}
264269
}
265270
}

libmamba/src/core/package_database_loader.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,18 @@ namespace mamba
116116
{
117117
if (!util::on_win)
118118
{
119-
database
120-
.native_serialize_repo(
121-
repo,
122-
subdir.writable_libsolv_cache_path(),
123-
expected_cache_origin
124-
)
125-
.or_else(
126-
[&](const auto& err)
127-
{
128-
LOG_WARNING << R"(Fail to write native serialization to file ")"
129-
<< subdir.writable_libsolv_cache_path()
130-
<< R"(" for repo ")" << subdir.name() << ": "
131-
<< err.what();
132-
;
133-
}
134-
);
119+
auto result = database.native_serialize_repo(
120+
repo,
121+
subdir.writable_libsolv_cache_path(),
122+
expected_cache_origin
123+
);
124+
if (!result)
125+
{
126+
LOG_WARNING << R"(Fail to write native serialization to file ")"
127+
<< subdir.writable_libsolv_cache_path() << R"(" for repo ")"
128+
<< subdir.name() << ": " << std::move(result).error().what();
129+
;
130+
}
135131
}
136132
return std::move(repo);
137133
}

libmamba/src/core/package_fetcher.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ namespace mamba
468468
{
469469
if (cb)
470470
{
471-
safe_invoke(*cb, event);
471+
// We dont want to propagate errors coming from user's callbacks
472+
[[maybe_unused]] auto result = safe_invoke(*cb, event);
472473
}
473474
}
474475

libmamba/src/core/util.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,11 @@ namespace mamba
782782
std::move(error_message)
783783
);
784784
LOG_ERROR << error_message;
785-
safe_invoke(before_throw_task)
786-
.map_error([](const auto& error)
787-
{ LOG_ERROR << "While handling LockFile failure: " << error.what(); });
785+
auto result = safe_invoke(before_throw_task);
786+
if (!result)
787+
{
788+
LOG_ERROR << "While handling LockFile failure: " << std::move(result).error().what();
789+
}
788790
throw mamba_error(complete_error_message, mamba_error_code::lockfile_failure);
789791
}
790792
};

libmamba/src/core/virtual_packages.cpp

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515

1616
#include <reproc++/run.hpp>
1717

18-
#include "mamba/core/context.hpp"
1918
#include "mamba/core/output.hpp"
2019
#include "mamba/core/util.hpp"
21-
#include "mamba/core/util_os.hpp"
2220
#include "mamba/core/virtual_packages.hpp"
2321
#include "mamba/util/build.hpp"
2422
#include "mamba/util/environment.hpp"
@@ -373,49 +371,39 @@ namespace mamba
373371

374372
if (os == "win")
375373
{
376-
overridable_windows_version()
377-
.transform(
378-
[&](std::string&& version)
379-
{
380-
res.push_back(make_virtual_package("__win", platform, std::move(version)));
381-
}
382-
)
383-
.or_else(
384-
[&](util::OSError err)
385-
{
386-
res.push_back(make_virtual_package("__win", platform, "0"));
387-
LOG_WARNING
388-
<< "Windows version not found, defaulting virtual package version to 0."
374+
auto result = overridable_windows_version();
375+
if (result)
376+
{
377+
res.push_back(make_virtual_package("__win", platform, std::move(result).value()));
378+
}
379+
else
380+
{
381+
res.push_back(make_virtual_package("__win", platform, "0"));
382+
LOG_WARNING << "Windows version not found, defaulting virtual package version to 0."
389383
" Try setting CONDA_OVERRIDE_WIN environment variable to the"
390384
" desired version.";
391-
LOG_DEBUG << err.message;
392-
}
393-
);
385+
LOG_DEBUG << std::move(result).error().message;
386+
}
394387
}
388+
395389
if (os == "linux")
396390
{
397391
res.push_back(make_virtual_package("__unix", platform));
398392

399-
overridable_linux_version()
400-
.transform(
401-
[&](std::string&& version)
402-
{
403-
res.push_back(
404-
make_virtual_package("__linux", platform, std::move(version))
405-
);
406-
}
407-
)
408-
.or_else(
409-
[&](util::OSError err)
410-
{
411-
res.push_back(make_virtual_package("__linux", platform, "0"));
412-
LOG_WARNING
413-
<< "Linux version not found, defaulting virtual package version to 0."
393+
auto result = overridable_linux_version();
394+
if (result)
395+
{
396+
res.push_back(make_virtual_package("__linux", platform, std::move(result).value())
397+
);
398+
}
399+
else
400+
{
401+
res.push_back(make_virtual_package("__linux", platform, "0"));
402+
LOG_WARNING << "Linux version not found, defaulting virtual package version to 0."
414403
" Try setting CONDA_OVERRIDE_LINUX environment variable to the"
415404
" desired version.";
416-
LOG_DEBUG << err.message;
417-
}
418-
);
405+
LOG_DEBUG << std::move(result).error().message;
406+
}
419407

420408
std::string libc_ver = detail::glibc_version();
421409
if (!libc_ver.empty())
@@ -427,28 +415,24 @@ namespace mamba
427415
LOG_WARNING << "glibc version not found (virtual package skipped)";
428416
}
429417
}
418+
430419
if (os == "osx")
431420
{
432421
res.push_back(make_virtual_package("__unix", platform));
433422

434-
overridable_osx_version()
435-
.transform(
436-
[&](std::string&& version)
437-
{
438-
res.push_back(make_virtual_package("__osx", platform, std::move(version)));
439-
}
440-
)
441-
.or_else(
442-
[&](util::OSError err)
443-
{
444-
res.push_back(make_virtual_package("__osx", platform, "0"));
445-
LOG_WARNING
446-
<< "OSX version not found, defaulting virtual package version to 0."
423+
auto result = overridable_osx_version();
424+
if (result)
425+
{
426+
res.push_back(make_virtual_package("__osx", platform, std::move(result).value()));
427+
}
428+
else
429+
{
430+
res.push_back(make_virtual_package("__osx", platform, "0"));
431+
LOG_WARNING << "OSX version not found, defaulting virtual package version to 0."
447432
" Try setting CONDA_OVERRIDE_OSX environment variable to the"
448433
" desired version.";
449-
LOG_DEBUG << err.message;
450-
}
451-
);
434+
LOG_DEBUG << std::move(result).error().message;
435+
}
452436
}
453437

454438
res.push_back(make_virtual_package("__archspec", platform, "1", get_archspec(arch)));

0 commit comments

Comments
 (0)