2727#include " mamba/core/repo_checker_store.hpp"
2828#include " mamba/core/thread_utils.hpp"
2929#include " mamba/core/transaction.hpp"
30- #include " mamba/core/util_os.hpp"
3130#include " mamba/solver/libsolv/database.hpp"
3231#include " mamba/specs/match_spec.hpp"
33- #include " mamba/util/environment.hpp"
3432#include " mamba/util/variant_cmp.hpp"
3533
36- #include " ./link.hpp"
37- #include " ./transaction_context.hpp"
3834#include " solver/helpers.hpp"
3935
36+ #include " link.hpp"
4037#include " progress_bar_impl.hpp"
38+ #include " transaction_context.hpp"
4139
4240namespace mamba
4341{
@@ -110,19 +108,22 @@ namespace mamba
110108 return out;
111109 }
112110
113- auto
114- find_python_version (const solver::Solution& solution, const solver::libsolv::Database& database)
115- -> std::pair<std::string, std::string>
111+ auto find_python_versions_and_site_packages (
112+ const solver::Solution& solution,
113+ const solver::libsolv::Database& database
114+ ) -> std::pair<std::pair<std::string, std::string>, std::string>
116115 {
117116 // We need to find the python version that will be there after this
118117 // Transaction is finished in order to compile the noarch packages correctly,
119118
120119 // We need to look into installed packages in case we are not installing a new python
121120 // version but keeping the current one.
122121 // Could also be written in term of PrefixData.
122+ std::string python_site_packages_path = {};
123123 std::string installed_py_ver = {};
124124 if (auto pkg = installed_python (database))
125125 {
126+ python_site_packages_path = pkg->python_site_packages_path ;
126127 installed_py_ver = pkg->version ;
127128 LOG_INFO << " Found python in installed packages " << installed_py_ver;
128129 }
@@ -131,9 +132,13 @@ namespace mamba
131132 if (auto py = solver::find_new_python_in_solution (solution))
132133 {
133134 new_py_ver = py->get ().version ;
135+ python_site_packages_path = py->get ().python_site_packages_path ;
134136 }
135137
136- return { std::move (new_py_ver), std::move (installed_py_ver) };
138+ return {
139+ { std::move (new_py_ver), std::move (installed_py_ver) },
140+ std::move (python_site_packages_path),
141+ };
137142 }
138143 }
139144
@@ -213,7 +218,10 @@ namespace mamba
213218 Console::instance ().json_write ({ { " PREFIX" , ctx.prefix_params .target_prefix .string () } });
214219 }
215220
216- m_py_versions = find_python_version (m_solution, database);
221+ std::tie (
222+ m_py_versions,
223+ m_python_site_packages_path
224+ ) = find_python_versions_and_site_packages (m_solution, database);
217225 }
218226
219227 MTransaction::MTransaction (
@@ -258,7 +266,10 @@ namespace mamba
258266 [&](const auto & item) { m_requested_specs.push_back (item.spec ); }
259267 );
260268
261- m_py_versions = find_python_version (m_solution, database);
269+ std::tie (
270+ m_py_versions,
271+ m_python_site_packages_path
272+ ) = find_python_versions_and_site_packages (m_solution, database);
262273
263274 // if no action required, don't even start logging them
264275 if (!empty ())
@@ -303,7 +314,10 @@ namespace mamba
303314 [](specs::PackageInfo&& pkg) { return solver::Solution::Install{ std::move (pkg) }; }
304315 );
305316
306- m_py_versions = find_python_version (m_solution, database);
317+ std::tie (
318+ m_py_versions,
319+ m_python_site_packages_path
320+ ) = find_python_versions_and_site_packages (m_solution, database);
307321 }
308322
309323 class TransactionRollback
@@ -395,7 +409,12 @@ namespace mamba
395409 };
396410
397411 TransactionRollback rollback;
398- TransactionContext transaction_context (ctx.transaction_params (), m_py_versions, m_requested_specs);
412+ TransactionContext transaction_context (
413+ ctx.transaction_params (),
414+ m_py_versions,
415+ m_python_site_packages_path,
416+ m_requested_specs
417+ );
399418
400419 for (const specs::PackageInfo& pkg : m_solution.packages_to_remove ())
401420 {
0 commit comments