diff --git a/libmamba/ext/solv-cpp/include/solv-cpp/solvable.hpp b/libmamba/ext/solv-cpp/include/solv-cpp/solvable.hpp index 97125721df..ed15aae6e0 100644 --- a/libmamba/ext/solv-cpp/include/solv-cpp/solvable.hpp +++ b/libmamba/ext/solv-cpp/include/solv-cpp/solvable.hpp @@ -53,6 +53,7 @@ namespace solv auto build_string() const -> std::string_view; auto file_name() const -> std::string_view; auto license() const -> std::string_view; + auto python_site_packages_path() const -> std::string_view; auto md5() const -> std::string_view; auto noarch() const -> std::string_view; auto sha256() const -> std::string_view; @@ -168,6 +169,17 @@ namespace solv void set_license(raw_str_view str) const; void set_license(const std::string& str) const; + /** + * Set the python_site_packages_path of the solvable. + * + * This is not used by libsolv and is purely for data storing. + * + * @note A call to @ref ObjRepoView::internalize is required for this attribute to + * be available for lookup. + */ + void set_python_site_packages_path(raw_str_view str) const; + void set_python_site_packages_path(const std::string& str) const; + /** * Set the md5 hash of the solvable file. * diff --git a/libmamba/ext/solv-cpp/src/solvable.cpp b/libmamba/ext/solv-cpp/src/solvable.cpp index 9c445ff67b..112cdbbc8d 100644 --- a/libmamba/ext/solv-cpp/src/solvable.cpp +++ b/libmamba/ext/solv-cpp/src/solvable.cpp @@ -206,6 +206,21 @@ namespace solv return set_license(str.c_str()); } + auto ObjSolvableViewConst::python_site_packages_path() const -> std::string_view + { + return ptr_to_strview(::solvable_lookup_str(const_cast<::Solvable*>(raw()), SOLVABLE_MEDIABASE)); + } + + void ObjSolvableView::set_python_site_packages_path(raw_str_view str) const + { + ::solvable_set_str(raw(), SOLVABLE_MEDIABASE, str); + } + + void ObjSolvableView::set_python_site_packages_path(const std::string& str) const + { + return set_python_site_packages_path(str.c_str()); + } + auto ObjSolvableViewConst::md5() const -> std::string_view { ::Id type = 0; diff --git a/libmamba/include/mamba/specs/package_info.hpp b/libmamba/include/mamba/specs/package_info.hpp index d1afbe4bc4..71114c6199 100644 --- a/libmamba/include/mamba/specs/package_info.hpp +++ b/libmamba/include/mamba/specs/package_info.hpp @@ -46,6 +46,7 @@ namespace mamba::specs std::string license = {}; std::string md5 = {}; std::string sha256 = {}; + std::string python_site_packages_path = {}; std::string signatures = {}; std::vector track_features = {}; std::vector dependencies = {}; diff --git a/libmamba/include/mamba/specs/repo_data.hpp b/libmamba/include/mamba/specs/repo_data.hpp index 985dc4dfce..4573ed0472 100644 --- a/libmamba/include/mamba/specs/repo_data.hpp +++ b/libmamba/include/mamba/specs/repo_data.hpp @@ -63,6 +63,9 @@ namespace mamba::specs /** Optionally a SHA256 hash of the package archive. */ std::optional sha256 = {}; + /** Optionally a path to the site-packages directory. */ + std::optional python_site_packages_path = {}; + /** A deprecated md5 hash. */ std::optional legacy_bz2_md5 = {}; diff --git a/libmamba/src/solver/libsolv/helpers.cpp b/libmamba/src/solver/libsolv/helpers.cpp index 59bfca15ab..a275d5c5ad 100644 --- a/libmamba/src/solver/libsolv/helpers.cpp +++ b/libmamba/src/solver/libsolv/helpers.cpp @@ -69,6 +69,7 @@ namespace mamba::solver::libsolv ); solv.set_md5(pkg.md5); solv.set_sha256(pkg.sha256); + solv.set_python_site_packages_path(pkg.python_site_packages_path); for (const auto& dep : pkg.dependencies) { @@ -110,6 +111,7 @@ namespace mamba::solver::libsolv out.timestamp = s.timestamp(); out.md5 = s.md5(); out.sha256 = s.sha256(); + out.python_site_packages_path = s.python_site_packages_path(); out.signatures = s.signatures(); const auto dep_to_str = [&pool](solv::DependencyId id) @@ -265,6 +267,11 @@ namespace mamba::solver::libsolv solv.set_sha256(sha256.value_unsafe()); } + if (auto python_site_packages_path = pkg["python_site_packages_path"].get_c_str(); !python_site_packages_path.error()) + { + solv.set_python_site_packages_path(python_site_packages_path.value_unsafe()); + } + if (auto elem = pkg["noarch"]; !elem.error()) { if (auto val = elem.get_bool(); !val.error() && val.value_unsafe()) diff --git a/libmamba/src/specs/package_info.cpp b/libmamba/src/specs/package_info.cpp index 527956bd1c..5662078b3e 100644 --- a/libmamba/src/specs/package_info.cpp +++ b/libmamba/src/specs/package_info.cpp @@ -337,6 +337,7 @@ namespace mamba::specs p.dependencies, p.constrains, p.signatures, + p.python_site_packages_path, p.defaulted_keys ); } @@ -383,6 +384,10 @@ namespace mamba::specs { j["signatures"] = pkg.signatures; } + if (!pkg.python_site_packages_path.empty()) + { + j["python_site_packages_path"] = pkg.python_site_packages_path; + } if (pkg.dependencies.empty()) { j["depends"] = nlohmann::json::array(); @@ -425,6 +430,7 @@ namespace mamba::specs pkg.md5 = j.value("md5", ""); pkg.sha256 = j.value("sha256", ""); pkg.signatures = j.value("signatures", ""); + pkg.python_site_packages_path = j.value("python_site_packages_path", ""); if (auto it = j.find("track_features"); it != j.end()) { if (it->is_string() && !it->get().empty()) diff --git a/libmamba/src/specs/repo_data.cpp b/libmamba/src/specs/repo_data.cpp index 735f96e995..ec51002ba8 100644 --- a/libmamba/src/specs/repo_data.cpp +++ b/libmamba/src/specs/repo_data.cpp @@ -22,6 +22,7 @@ namespace mamba::specs j["subdir"] = p.subdir; j["md5"] = p.md5; j["sha256"] = p.sha256; + j["python_site_packages_path"] = p.python_site_packages_path; j["legacy_bz2_md5"] = p.legacy_bz2_md5; j["legacy_bz2_size"] = p.legacy_bz2_size; j["size"] = p.size; @@ -50,6 +51,7 @@ namespace mamba::specs deserialize_maybe_missing(j, "subdir", p.subdir); deserialize_maybe_missing(j, "md5", p.md5); deserialize_maybe_missing(j, "sha256", p.sha256); + deserialize_maybe_missing(j, "python_site_packages_path", p.python_site_packages_path); deserialize_maybe_missing(j, "legacy_bz2_md5", p.legacy_bz2_md5); deserialize_maybe_missing(j, "legacy_bz2_size", p.legacy_bz2_size); deserialize_maybe_missing(j, "size", p.size);