Skip to content

Commit

Permalink
Fragile fix of MPool::create_whatprovides call
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Apr 3, 2023
1 parent 26c67a9 commit ed94f5f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
7 changes: 5 additions & 2 deletions libmamba/src/api/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,6 @@ namespace mamba
solver.add_jobs(prefix_pkgs, SOLVER_LOCK);
}

solver.add_jobs(specs, solver_flag);

if (!no_pin)
{
solver.add_pins(file_pins(prefix_data.path() / "conda-meta" / "pinned"));
Expand All @@ -536,6 +534,11 @@ namespace mamba
Console::instance().print("\nPinned packages:\n" + join("", pinned_str));
}

// FRAGILE this must be called after pins be before jobs in current ``MPool``
pool.create_whatprovides();

solver.add_jobs(specs, solver_flag);

bool success = solver.try_solve();
if (!success)
{
Expand Down
46 changes: 25 additions & 21 deletions libmamba/src/api/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ namespace mamba
}
);

if (update_all)
{
auto hist_map = prefix_data.history().get_requested_specs_map();
std::vector<std::string> keep_specs;
for (auto& it : hist_map)
{
keep_specs.push_back(it.second.name);
}
solver_flag |= SOLVER_SOLVABLE_ALL;
if (prune)
{
solver_flag |= SOLVER_CLEANDEPS;
}
solver.add_jobs(keep_specs, SOLVER_USERINSTALLED);
solver.add_global_job(solver_flag);
}
else
{
solver.add_jobs(update_specs, solver_flag);
}

auto& no_pin = config.at("no_pin").value<bool>();
auto& no_py_pin = config.at("no_py_pin").value<bool>();

Expand Down Expand Up @@ -125,6 +104,31 @@ namespace mamba
Console::instance().print("\nPinned packages:\n" + join("", pinned_str));
}

// FRAGILE this must be called after pins be before jobs in current ``MPool``
pool.create_whatprovides();

if (update_all)
{
auto hist_map = prefix_data.history().get_requested_specs_map();
std::vector<std::string> keep_specs;
for (auto& it : hist_map)
{
keep_specs.push_back(it.second.name);
}
solver_flag |= SOLVER_SOLVABLE_ALL;
if (prune)
{
solver_flag |= SOLVER_CLEANDEPS;
}
solver.add_jobs(keep_specs, SOLVER_USERINSTALLED);
solver.add_global_job(solver_flag);
}
else
{
solver.add_jobs(update_specs, solver_flag);
}


solver.must_solve();

auto execute_transaction = [&](MTransaction& transaction)
Expand Down
3 changes: 3 additions & 0 deletions libmamba/src/core/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ namespace mamba
}
::Id const repr_id = pool_str2id(pool, repr.c_str(), /* .create= */ true);
::Id const offset = pool_queuetowhatprovides(pool, selected_pkgs.raw());
// FRAGILE This get deleted when calling ``pool_createwhatprovides`` so care
// must be taken to do it before
// TODO investigate namespace providers
pool_set_whatprovides(pool, repr_id, offset);
return repr_id;
}
Expand Down
2 changes: 0 additions & 2 deletions libmamba/src/core/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,6 @@ namespace mamba

bool MSolver::try_solve()
{
m_pool.create_whatprovides();

m_solver.reset(solver_create(m_pool));
set_flags(m_flags);

Expand Down

0 comments on commit ed94f5f

Please sign in to comment.