mirror of https://github.com/mamba-org/mamba.git
Out of context (#3952)
This commit is contained in:
parent
7e6435c605
commit
aeb417f617
|
@ -228,6 +228,7 @@ set(
|
|||
${LIBMAMBA_SOURCE_DIR}/core/fsutil.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/history.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/link.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/link.hpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/menuinst.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/output.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/package_cache.cpp
|
||||
|
@ -248,6 +249,7 @@ set(
|
|||
${LIBMAMBA_SOURCE_DIR}/core/thread_utils.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/timeref.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/transaction_context.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/transaction_context.hpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/transaction.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/util_os.cpp
|
||||
${LIBMAMBA_SOURCE_DIR}/core/util.cpp
|
||||
|
@ -376,7 +378,6 @@ set(
|
|||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/fsutil.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/history.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/invoke.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/link.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/menuinst.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/output.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/package_cache.hpp
|
||||
|
@ -396,7 +397,6 @@ set(
|
|||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/tasksync.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/thread_utils.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/timeref.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/transaction_context.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/transaction.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/util_os.hpp
|
||||
${LIBMAMBA_INCLUDE_DIR}/mamba/core/util_scope.hpp
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#include "mamba/core/history.hpp"
|
||||
#include "mamba/core/util.hpp"
|
||||
#include "mamba/fs/filesystem.hpp"
|
||||
#include "mamba/solver/request.hpp"
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mamba/fs/filesystem.hpp"
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mamba/api/install.hpp"
|
||||
#include "mamba/core/package_cache.hpp"
|
||||
#include "mamba/core/prefix_data.hpp"
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
#include "mamba/fs/filesystem.hpp"
|
||||
#include "mamba/solver/libsolv/database.hpp"
|
||||
#include "mamba/solver/solution.hpp"
|
||||
|
@ -79,16 +78,14 @@ namespace mamba
|
|||
|
||||
private:
|
||||
|
||||
TransactionContext m_transaction_context;
|
||||
MultiPackageCache m_multi_cache;
|
||||
const fs::u8path m_cache_path;
|
||||
History::UserRequest m_history_entry;
|
||||
solver::Solution m_solution;
|
||||
|
||||
History::UserRequest m_history_entry;
|
||||
|
||||
std::pair<std::string, std::string> m_py_versions;
|
||||
std::vector<specs::MatchSpec> m_requested_specs;
|
||||
|
||||
MTransaction(const Context& ctx, MultiPackageCache&);
|
||||
MTransaction(const CommandParams& command_params, MultiPackageCache&);
|
||||
};
|
||||
|
||||
MTransaction create_explicit_transaction_from_urls(
|
||||
|
|
|
@ -13,16 +13,17 @@
|
|||
#include <reproc++/reproc.hpp>
|
||||
#include <reproc++/run.hpp>
|
||||
|
||||
#include "mamba/core/link.hpp"
|
||||
#include "./link.hpp"
|
||||
#include "mamba/core/menuinst.hpp"
|
||||
#include "mamba/core/output.hpp"
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
#include "mamba/specs/match_spec.hpp"
|
||||
#include "mamba/util/build.hpp"
|
||||
#include "mamba/util/environment.hpp"
|
||||
#include "mamba/util/string.hpp"
|
||||
#include "mamba/validation/tools.hpp"
|
||||
|
||||
#include "./transaction_context.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "mamba/core/util_os.hpp"
|
||||
#endif
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
#include <vector>
|
||||
|
||||
#include "mamba/core/package_paths.hpp"
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
#include "mamba/fs/filesystem.hpp"
|
||||
#include "mamba/specs/package_info.hpp"
|
||||
#include "mamba/util/build.hpp"
|
||||
|
||||
#include "./transaction_context.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
||||
std::string replace_long_shebang(const std::string& shebang);
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "mamba/util/path_manip.hpp"
|
||||
|
||||
#include "./transaction_context.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <shlobj.h>
|
||||
#include <windows.h>
|
||||
|
@ -18,7 +20,6 @@
|
|||
#include "mamba/core/context.hpp"
|
||||
#include "mamba/core/environments_manager.hpp"
|
||||
#include "mamba/core/output.hpp"
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
#include "mamba/util/string.hpp"
|
||||
|
||||
namespace mamba
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "mamba/core/download_progress_bar.hpp"
|
||||
#include "mamba/core/env_lockfile.hpp"
|
||||
#include "mamba/core/execution.hpp"
|
||||
#include "mamba/core/link.hpp"
|
||||
#include "mamba/core/output.hpp"
|
||||
#include "mamba/core/package_fetcher.hpp"
|
||||
#include "mamba/core/repo_checker_store.hpp"
|
||||
|
@ -33,6 +32,8 @@
|
|||
#include "mamba/util/environment.hpp"
|
||||
#include "mamba/util/variant_cmp.hpp"
|
||||
|
||||
#include "./link.hpp"
|
||||
#include "./transaction_context.hpp"
|
||||
#include "solver/helpers.hpp"
|
||||
|
||||
#include "progress_bar_impl.hpp"
|
||||
|
@ -135,9 +136,9 @@ namespace mamba
|
|||
}
|
||||
}
|
||||
|
||||
MTransaction::MTransaction(const Context& ctx, MultiPackageCache& caches)
|
||||
MTransaction::MTransaction(const CommandParams& command_params, MultiPackageCache& caches)
|
||||
: m_multi_cache(caches)
|
||||
, m_history_entry(History::UserRequest::prefilled(ctx.command_params))
|
||||
, m_history_entry(History::UserRequest::prefilled(command_params))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,7 @@ namespace mamba
|
|||
std::vector<specs::PackageInfo> pkgs_to_install,
|
||||
MultiPackageCache& caches
|
||||
)
|
||||
: MTransaction(ctx, caches)
|
||||
: MTransaction(ctx.command_params, caches)
|
||||
{
|
||||
auto not_found = std::stringstream();
|
||||
for (const auto& pkg : pkgs_to_remove)
|
||||
|
@ -169,12 +170,11 @@ namespace mamba
|
|||
|
||||
Console::instance().json_write({ { "success", true } });
|
||||
|
||||
auto specs_to_install = std::vector<specs::MatchSpec>();
|
||||
specs_to_install.reserve(pkgs_to_install.size());
|
||||
m_requested_specs.reserve(pkgs_to_install.size());
|
||||
std::transform(
|
||||
pkgs_to_install.begin(),
|
||||
pkgs_to_install.end(),
|
||||
std::back_insert_iterator(specs_to_install),
|
||||
std::back_insert_iterator(m_requested_specs),
|
||||
[](const auto& pkg) { return explicit_spec(pkg); }
|
||||
);
|
||||
|
||||
|
@ -212,11 +212,7 @@ namespace mamba
|
|||
Console::instance().json_write({ { "PREFIX", ctx.prefix_params.target_prefix.string() } });
|
||||
}
|
||||
|
||||
m_transaction_context = TransactionContext(
|
||||
ctx.transaction_params(),
|
||||
find_python_version(m_solution, database),
|
||||
specs_to_install
|
||||
);
|
||||
m_py_versions = find_python_version(m_solution, database);
|
||||
}
|
||||
|
||||
MTransaction::MTransaction(
|
||||
|
@ -226,7 +222,7 @@ namespace mamba
|
|||
solver::Solution solution,
|
||||
MultiPackageCache& caches
|
||||
)
|
||||
: MTransaction(ctx, caches)
|
||||
: MTransaction(ctx.command_params, caches)
|
||||
{
|
||||
const auto& flags = request.flags;
|
||||
m_solution = std::move(solution);
|
||||
|
@ -258,18 +254,14 @@ namespace mamba
|
|||
);
|
||||
}
|
||||
|
||||
auto requested_specs = std::vector<specs::MatchSpec>();
|
||||
using Request = solver::Request;
|
||||
solver::for_each_of<Request::Install, Request::Update>(
|
||||
request,
|
||||
[&](const auto& item) { requested_specs.push_back(item.spec); }
|
||||
);
|
||||
m_transaction_context = TransactionContext(
|
||||
ctx.transaction_params(),
|
||||
find_python_version(m_solution, database),
|
||||
std::move(requested_specs)
|
||||
[&](const auto& item) { m_requested_specs.push_back(item.spec); }
|
||||
);
|
||||
|
||||
m_py_versions = find_python_version(m_solution, database);
|
||||
|
||||
// if no action required, don't even start logging them
|
||||
if (!empty())
|
||||
{
|
||||
|
@ -286,16 +278,15 @@ namespace mamba
|
|||
std::vector<specs::PackageInfo> packages,
|
||||
MultiPackageCache& caches
|
||||
)
|
||||
: MTransaction(ctx, caches)
|
||||
: MTransaction(ctx.command_params, caches)
|
||||
{
|
||||
LOG_INFO << "MTransaction::MTransaction - packages already resolved (lockfile)";
|
||||
|
||||
auto specs_to_install = std::vector<specs::MatchSpec>();
|
||||
specs_to_install.reserve(packages.size());
|
||||
m_requested_specs.reserve(packages.size());
|
||||
std::transform(
|
||||
packages.cbegin(),
|
||||
packages.cend(),
|
||||
std::back_insert_iterator(specs_to_install),
|
||||
std::back_insert_iterator(m_requested_specs),
|
||||
[](const auto& pkg)
|
||||
{
|
||||
return specs::MatchSpec::parse(
|
||||
|
@ -314,11 +305,7 @@ namespace mamba
|
|||
[](specs::PackageInfo&& pkg) { return solver::Solution::Install{ std::move(pkg) }; }
|
||||
);
|
||||
|
||||
m_transaction_context = TransactionContext(
|
||||
ctx.transaction_params(),
|
||||
find_python_version(m_solution, database),
|
||||
std::move(specs_to_install)
|
||||
);
|
||||
m_py_versions = find_python_version(m_solution, database);
|
||||
}
|
||||
|
||||
class TransactionRollback
|
||||
|
@ -394,6 +381,8 @@ namespace mamba
|
|||
|
||||
TransactionRollback rollback;
|
||||
|
||||
TransactionContext transaction_context(ctx.transaction_params(), m_py_versions, m_requested_specs);
|
||||
|
||||
const auto link = [&](const specs::PackageInfo& pkg)
|
||||
{
|
||||
if (is_sig_interrupted())
|
||||
|
@ -402,7 +391,7 @@ namespace mamba
|
|||
}
|
||||
Console::stream() << "Linking " << pkg.str();
|
||||
const fs::u8path cache_path(m_multi_cache.get_extracted_dir_path(pkg, false));
|
||||
LinkPackage lp(pkg, cache_path, &m_transaction_context);
|
||||
LinkPackage lp(pkg, cache_path, &transaction_context);
|
||||
lp.execute();
|
||||
rollback.record(lp);
|
||||
m_history_entry.link_dists.push_back(pkg.long_str());
|
||||
|
@ -416,7 +405,7 @@ namespace mamba
|
|||
}
|
||||
Console::stream() << "Unlinking " << pkg.str();
|
||||
const fs::u8path cache_path(m_multi_cache.get_extracted_dir_path(pkg));
|
||||
UnlinkPackage up(pkg, cache_path, &m_transaction_context);
|
||||
UnlinkPackage up(pkg, cache_path, &transaction_context);
|
||||
up.execute();
|
||||
rollback.record(up);
|
||||
m_history_entry.unlink_dists.push_back(pkg.long_str());
|
||||
|
@ -433,7 +422,7 @@ namespace mamba
|
|||
return false;
|
||||
}
|
||||
LOG_INFO << "Waiting for pyc compilation to finish";
|
||||
m_transaction_context.wait_for_pyc_compilation();
|
||||
transaction_context.wait_for_pyc_compilation();
|
||||
|
||||
Console::stream() << "\nTransaction finished\n";
|
||||
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
|
||||
#include "mamba/core/error_handling.hpp"
|
||||
#include "mamba/core/output.hpp"
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
#include "mamba/util/environment.hpp"
|
||||
#include "mamba/util/string.hpp"
|
||||
|
||||
#include "./transaction_context.hpp"
|
||||
|
||||
extern const char data_compile_pyc_py[];
|
||||
|
||||
namespace mamba
|
||||
|
|
|
@ -42,10 +42,6 @@ namespace mamba
|
|||
fs::u8path site_packages_path;
|
||||
};
|
||||
|
||||
// TODO: remove this constructor when refactoring
|
||||
// the MTransaction class.
|
||||
TransactionContext() = default;
|
||||
|
||||
TransactionContext(
|
||||
TransactionParams transaction_params,
|
||||
std::pair<std::string, std::string> py_versions,
|
|
@ -15,12 +15,14 @@
|
|||
#include "mamba/core/environments_manager.hpp"
|
||||
#include "mamba/core/fsutil.hpp"
|
||||
#include "mamba/core/history.hpp"
|
||||
#include "mamba/core/link.hpp"
|
||||
#include "mamba/core/output.hpp"
|
||||
#include "mamba/core/subdir_index.hpp"
|
||||
#include "mamba/util/build.hpp"
|
||||
#include "mamba/util/path_manip.hpp"
|
||||
|
||||
// Private mamba header
|
||||
#include "core/link.hpp"
|
||||
|
||||
#include "mambatests.hpp"
|
||||
|
||||
namespace mamba
|
||||
|
@ -33,20 +35,6 @@ namespace mamba
|
|||
REQUIRE(cache_name_from_url("http://test.com/1234/current_repodata.json") == "78a8cce9");
|
||||
}
|
||||
|
||||
// TEST(cpp_install, install)
|
||||
// {
|
||||
// mambatests::context().output_params.verbosity = 3;
|
||||
// PackageInfo pkg("wheel", "0.34.2", "py_1", 1);
|
||||
// fs::u8path prefix = "C:\\Users\\wolfv\\miniconda3\\";
|
||||
// TransactionContext tc(prefix, "3.8.x");
|
||||
// // try {
|
||||
// UnlinkPackage up(pkg, &tc);
|
||||
// up.execute();
|
||||
// // } catch (...) { std::cout << "Nothing to delete ... \n"; }
|
||||
// LinkPackage lp(pkg, prefix / "pkgs" , &tc);
|
||||
// lp.execute();
|
||||
// }
|
||||
|
||||
namespace
|
||||
{
|
||||
TEST_CASE("user_request")
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "mamba/core/transaction_context.hpp"
|
||||
// Private libmamba header
|
||||
#include "core/transaction_context.hpp"
|
||||
|
||||
namespace mamba
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue