From f9dea4a222a6b3382255a39d917f3262157d5268 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 24 Oct 2024 10:57:01 +0200 Subject: [PATCH 1/6] pip packages support with `list` --- libmamba/include/mamba/core/activation.hpp | 2 - libmamba/include/mamba/core/prefix_data.hpp | 2 + libmamba/include/mamba/specs/package_info.hpp | 1 + libmamba/include/mamba/util/environment.hpp | 6 ++ libmamba/src/api/install.cpp | 2 +- libmamba/src/api/list.cpp | 37 ++++++++--- libmamba/src/api/utils.cpp | 3 +- libmamba/src/core/activation.cpp | 23 +------ libmamba/src/core/prefix_data.cpp | 61 ++++++++++++++++++- libmamba/src/specs/package_info.cpp | 8 +++ libmamba/src/util/environment.cpp | 17 ++++++ micromamba/tests/test_list.py | 33 ++++++++++ 12 files changed, 159 insertions(+), 36 deletions(-) diff --git a/libmamba/include/mamba/core/activation.hpp b/libmamba/include/mamba/core/activation.hpp index fc6569b4bd..e2ad98ab20 100644 --- a/libmamba/include/mamba/core/activation.hpp +++ b/libmamba/include/mamba/core/activation.hpp @@ -258,8 +258,6 @@ namespace mamba fs::u8path hook_source_path() override; }; - std::vector get_path_dirs(const fs::u8path& prefix); - } // namespace mamba #endif diff --git a/libmamba/include/mamba/core/prefix_data.hpp b/libmamba/include/mamba/core/prefix_data.hpp index ce9919351d..4ada7c30bb 100644 --- a/libmamba/include/mamba/core/prefix_data.hpp +++ b/libmamba/include/mamba/core/prefix_data.hpp @@ -44,6 +44,8 @@ namespace mamba PrefixData(const fs::u8path& prefix_path, ChannelContext& channel_context); + void load_site_packages(); + History m_history; package_map m_package_records; fs::u8path m_prefix_path; diff --git a/libmamba/include/mamba/specs/package_info.hpp b/libmamba/include/mamba/specs/package_info.hpp index 9ee9fd783b..d1afbe4bc4 100644 --- a/libmamba/include/mamba/specs/package_info.hpp +++ b/libmamba/include/mamba/specs/package_info.hpp @@ -68,6 +68,7 @@ namespace mamba::specs PackageInfo() = default; explicit PackageInfo(std::string name); PackageInfo(std::string name, std::string version, std::string build_string, std::size_t build_number); + PackageInfo(std::string name, std::string version, std::string build_string, std::string channel); [[nodiscard]] auto json_signable() const -> nlohmann::json; [[nodiscard]] auto str() const -> std::string; diff --git a/libmamba/include/mamba/util/environment.hpp b/libmamba/include/mamba/util/environment.hpp index 483af92a79..dc54646060 100644 --- a/libmamba/include/mamba/util/environment.hpp +++ b/libmamba/include/mamba/util/environment.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "mamba/fs/filesystem.hpp" #include "mamba/util/build.hpp" @@ -93,6 +94,11 @@ namespace mamba::util */ [[nodiscard]] constexpr auto pathsep() -> char; + /** + * Return directories of the given prefix path. + */ + [[nodiscard]] auto get_path_dirs(const fs::u8path& prefix) -> std::vector; + /** * Return the full path of a program from its name. */ diff --git a/libmamba/src/api/install.cpp b/libmamba/src/api/install.cpp index 083f42dbc0..70e921ad5e 100644 --- a/libmamba/src/api/install.cpp +++ b/libmamba/src/api/install.cpp @@ -10,7 +10,6 @@ #include "mamba/api/channel_loader.hpp" #include "mamba/api/configuration.hpp" #include "mamba/api/install.hpp" -#include "mamba/core/activation.hpp" #include "mamba/core/channel_context.hpp" #include "mamba/core/context.hpp" #include "mamba/core/env_lockfile.hpp" @@ -24,6 +23,7 @@ #include "mamba/download/downloader.hpp" #include "mamba/fs/filesystem.hpp" #include "mamba/solver/libsolv/solver.hpp" +#include "mamba/util/environment.hpp" #include "mamba/util/path_manip.hpp" #include "mamba/util/string.hpp" diff --git a/libmamba/src/api/list.cpp b/libmamba/src/api/list.cpp index 470555d9e5..ca5910f1d2 100644 --- a/libmamba/src/api/list.cpp +++ b/libmamba/src/api/list.cpp @@ -89,18 +89,31 @@ namespace mamba { auto channels = channel_context.make_channel(pkg_info.package_url); assert(channels.size() == 1); // A URL can only resolve to one channel - obj["base_url"] = strip_from_filename_and_platform( - channels.front().url().str(specs::CondaURL::Credentials::Remove), - pkg_info.filename, - pkg_info.platform - ); + + if (pkg_info.package_url.empty() && (pkg_info.channel == "pypi")) + { + // TODO Need to correctly set `platform`, which is empty in PyPI case + // Note that this is only a problem when using `--json` + // (otherwise, the missing info is not needed/used) + // cf. `formatted_pkgs` below + obj["base_url"] = "https://pypi.org/"; + obj["channel"] = pkg_info.channel; + } + else + { + obj["base_url"] = strip_from_filename_and_platform( + channels.front().url().str(specs::CondaURL::Credentials::Remove), + pkg_info.filename, + pkg_info.platform + ); + obj["channel"] = strip_from_filename_and_platform( + channels.front().display_name(), + pkg_info.filename, + pkg_info.platform + ); + } obj["build_number"] = pkg_info.build_number; obj["build_string"] = pkg_info.build_string; - obj["channel"] = strip_from_filename_and_platform( - channels.front().display_name(), - pkg_info.filename, - pkg_info.platform - ); obj["dist_name"] = pkg_info.str(); obj["name"] = pkg_info.name; obj["platform"] = pkg_info.platform; @@ -132,6 +145,10 @@ namespace mamba { formatted_pkgs.channel = ""; } + else if (package.second.channel == "pypi") + { + formatted_pkgs.channel = package.second.channel; + } else { auto channels = channel_context.make_channel(package.second.channel); diff --git a/libmamba/src/api/utils.cpp b/libmamba/src/api/utils.cpp index 8e3fc2fe3f..13642f08e7 100644 --- a/libmamba/src/api/utils.cpp +++ b/libmamba/src/api/utils.cpp @@ -13,7 +13,6 @@ // TODO includes to be removed after moving some functions/structs around #include "mamba/api/install.hpp" // other_pkg_mgr_spec -#include "mamba/core/activation.hpp" // get_path_dirs #include "mamba/core/context.hpp" #include "mamba/core/util.hpp" #include "mamba/fs/filesystem.hpp" @@ -33,7 +32,7 @@ namespace mamba ) { const auto get_python_path = [&] - { return util::which_in("python", get_path_dirs(target_prefix)).string(); }; + { return util::which_in("python", util::get_path_dirs(target_prefix)).string(); }; command_args cmd = { get_python_path(), "-m", "pip", "install" }; command_args cmd_extension = { "-r", spec_file, "--no-input", "--quiet" }; diff --git a/libmamba/src/core/activation.cpp b/libmamba/src/core/activation.cpp index f18485bab3..46169e7fbb 100644 --- a/libmamba/src/core/activation.cpp +++ b/libmamba/src/core/activation.cpp @@ -208,23 +208,6 @@ namespace mamba } } - std::vector get_path_dirs(const fs::u8path& prefix) - { - if (util::on_win) - { - return { prefix, - prefix / "Library" / "mingw-w64" / "bin", - prefix / "Library" / "usr" / "bin", - prefix / "Library" / "bin", - prefix / "Scripts", - prefix / "bin" }; - } - else - { - return { prefix / "bin" }; - } - } - std::vector Activator::get_PATH() { std::vector path; @@ -271,7 +254,7 @@ namespace mamba // TODO check if path_conversion does something useful here. // path_list[0:0] = list(self.path_conversion(self._get_path_dirs(prefix))) - std::vector final_path = get_path_dirs(prefix); + std::vector final_path = util::get_path_dirs(prefix); final_path.insert(final_path.end(), path_list.begin(), path_list.end()); final_path.erase(std::unique(final_path.begin(), final_path.end()), final_path.end()); std::string result = util::join(util::pathsep(), final_path).string(); @@ -285,7 +268,7 @@ namespace mamba std::vector current_path = get_PATH(); assert(!old_prefix.empty()); - std::vector old_prefix_dirs = get_path_dirs(old_prefix); + std::vector old_prefix_dirs = util::get_path_dirs(old_prefix); // remove all old paths std::vector cleaned_path; @@ -312,7 +295,7 @@ namespace mamba std::vector final_path; if (!new_prefix.empty()) { - final_path = get_path_dirs(new_prefix); + final_path = util::get_path_dirs(new_prefix); final_path.insert(final_path.end(), current_path.begin(), current_path.end()); // remove duplicates diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index 9c1b8c7c9b..db6647fd66 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -9,11 +9,14 @@ #include #include +#include + #include "mamba/core/channel_context.hpp" #include "mamba/core/output.hpp" #include "mamba/core/prefix_data.hpp" #include "mamba/core/util.hpp" #include "mamba/specs/conda_url.hpp" +#include "mamba/util/environment.hpp" #include "mamba/util/graph.hpp" #include "mamba/util/string.hpp" @@ -56,6 +59,8 @@ namespace mamba } } } + // Load packages installed with pip + load_site_packages(); } void PrefixData::add_packages(const std::vector& packages) @@ -166,10 +171,64 @@ namespace mamba auto channels = m_channel_context.make_channel(prec.channel); // If someone wrote multichannel names in repodata_record, we don't know which one is the - // correct URL. This is must never happen! + // correct URL. This must never happen! assert(channels.size() == 1); using Credentials = specs::CondaURL::Credentials; prec.channel = channels.front().platform_url(prec.platform).str(Credentials::Remove); m_package_records.insert({ prec.name, std::move(prec) }); } + + // Load python packages installed with pip in the site-packages of the prefix. + void PrefixData::load_site_packages() + { + LOG_INFO << "Loading site packages"; + + // Look for `pip` package and return if it doesn't exist + auto python_pkg_record = m_package_records.find("pip"); + if (python_pkg_record == m_package_records.end()) + { + LOG_DEBUG << "`pip` not found"; + return; + } + + // Run `pip freeze` + std::string out, err; + + const auto get_python_path = [&] + { return util::which_in("python", util::get_path_dirs(m_prefix_path)).string(); }; + + const auto args = std::array{ get_python_path(), + "-m", + "pip", + "freeze", + "--local" }; + auto [status, ec] = reproc::run( + args, + reproc::options{}, + reproc::sink::string(out), + reproc::sink::string(err) + ); + if (ec) + { + throw std::runtime_error(ec.message()); + } + + // Nothing installed with `pip` + if (out.empty()) + { + LOG_DEBUG << "Nothing installed with `pip`"; + return; + } + + auto pkgs_info_list = mamba::util::split(mamba::util::strip(out), "\n"); + for (auto& pkg_info_line : pkgs_info_list) + { + if (pkg_info_line.find("==") != std::string::npos) + { + auto pkg_info = mamba::util::split(mamba::util::strip(pkg_info_line), "=="); + auto prec = specs::PackageInfo(pkg_info[0], pkg_info[1], "pypi_0", "pypi"); + m_package_records.insert({ prec.name, std::move(prec) }); + } + } + } } // namespace mamba diff --git a/libmamba/src/specs/package_info.cpp b/libmamba/src/specs/package_info.cpp index dd4003bc33..527956bd1c 100644 --- a/libmamba/src/specs/package_info.cpp +++ b/libmamba/src/specs/package_info.cpp @@ -156,6 +156,14 @@ namespace mamba::specs { } + PackageInfo::PackageInfo(std::string n, std::string v, std::string b, std::string c) + : name(std::move(n)) + , version(std::move(v)) + , build_string(std::move(b)) + , channel(std::move(c)) + { + } + namespace { template diff --git a/libmamba/src/util/environment.cpp b/libmamba/src/util/environment.cpp index c6e2daa29b..f5046eade4 100644 --- a/libmamba/src/util/environment.cpp +++ b/libmamba/src/util/environment.cpp @@ -408,6 +408,23 @@ namespace mamba::util } } + auto get_path_dirs(const fs::u8path& prefix) -> std::vector + { + if (on_win) + { + return { prefix, + prefix / "Library" / "mingw-w64" / "bin", + prefix / "Library" / "usr" / "bin", + prefix / "Library" / "bin", + prefix / "Scripts", + prefix / "bin" }; + } + else + { + return { prefix / "bin" }; + } + } + auto which(std::string_view exe) -> fs::u8path { if (auto paths = get_env("PATH")) diff --git a/micromamba/tests/test_list.py b/micromamba/tests/test_list.py index 1865ed7dab..5a1f587755 100644 --- a/micromamba/tests/test_list.py +++ b/micromamba/tests/test_list.py @@ -40,6 +40,39 @@ def test_list_name(tmp_home, tmp_root_prefix, tmp_xtensor_env, quiet_flag): assert full_names == ["xtensor"] +env_yaml_content_to_install_numpy_with_pip = """ +channels: +- conda-forge +dependencies: +- pip +- pip: + - numpy==1.26.4 +""" + + +@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True) +def test_list_with_pip(tmp_home, tmp_root_prefix, tmp_path): + env_name = "env-list_with_pip" + tmp_root_prefix / "envs" / env_name + + env_file_yml = tmp_path / "test_env_yaml_content_to_install_numpy_with_pip.yaml" + env_file_yml.write_text(env_yaml_content_to_install_numpy_with_pip) + + helpers.create("-n", env_name, "python=3.12", "--json", no_dry_run=True) + helpers.install("-n", env_name, "-f", env_file_yml, "--json", no_dry_run=True) + + res = helpers.umamba_list("-n", env_name, "--json") + assert any( + package["name"] == "numpy" + and package["version"] == "1.26.4" + and package["base_url"] == "https://pypi.org/" + and package["build_string"] == "pypi_0" + and package["channel"] == "pypi" + and package["platform"] == "" + for package in res + ) + + @pytest.mark.parametrize("env_selector", ["name", "prefix"]) @pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True) def test_not_existing(tmp_home, tmp_root_prefix, tmp_xtensor_env, env_selector): From 2edb0228f1090b148b757df92267792e67906963 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 24 Oct 2024 11:57:21 +0200 Subject: [PATCH 2/6] Fix linter --- libmamba/src/api/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmamba/src/api/utils.cpp b/libmamba/src/api/utils.cpp index 13642f08e7..3500da7c68 100644 --- a/libmamba/src/api/utils.cpp +++ b/libmamba/src/api/utils.cpp @@ -12,7 +12,7 @@ #include // TODO includes to be removed after moving some functions/structs around -#include "mamba/api/install.hpp" // other_pkg_mgr_spec +#include "mamba/api/install.hpp" // other_pkg_mgr_spec #include "mamba/core/context.hpp" #include "mamba/core/util.hpp" #include "mamba/fs/filesystem.hpp" From c35c17441b1ecc62bfb41ecb8f3b55dde914fa70 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 24 Oct 2024 12:03:39 +0200 Subject: [PATCH 3/6] Remove unnecessary include --- libmamba/src/api/install.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libmamba/src/api/install.cpp b/libmamba/src/api/install.cpp index 70e921ad5e..ea996377c8 100644 --- a/libmamba/src/api/install.cpp +++ b/libmamba/src/api/install.cpp @@ -23,7 +23,6 @@ #include "mamba/download/downloader.hpp" #include "mamba/fs/filesystem.hpp" #include "mamba/solver/libsolv/solver.hpp" -#include "mamba/util/environment.hpp" #include "mamba/util/path_manip.hpp" #include "mamba/util/string.hpp" From fb6f116e78592c5f545846a482ff4f1390d084c4 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 24 Oct 2024 16:38:34 +0200 Subject: [PATCH 4/6] Separate pip records from conda-forge --- libmamba/include/mamba/core/prefix_data.hpp | 6 +++++- libmamba/src/api/list.cpp | 8 +++++--- libmamba/src/core/prefix_data.cpp | 18 +++++++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libmamba/include/mamba/core/prefix_data.hpp b/libmamba/include/mamba/core/prefix_data.hpp index 4ada7c30bb..3caacb6838 100644 --- a/libmamba/include/mamba/core/prefix_data.hpp +++ b/libmamba/include/mamba/core/prefix_data.hpp @@ -28,9 +28,12 @@ namespace mamba create(const fs::u8path& prefix_path, ChannelContext& channel_context); void add_packages(const std::vector& packages); - const package_map& records() const; void load_single_record(const fs::u8path& path); + const package_map& records() const; + const package_map& pip_records() const; + package_map all_pkg_mgr_records() const; + History& history(); const fs::u8path& path() const; std::vector sorted_records() const; @@ -48,6 +51,7 @@ namespace mamba History m_history; package_map m_package_records; + package_map m_pip_package_records; fs::u8path m_prefix_path; ChannelContext& m_channel_context; diff --git a/libmamba/src/api/list.cpp b/libmamba/src/api/list.cpp index ca5910f1d2..5ba4740402 100644 --- a/libmamba/src/api/list.cpp +++ b/libmamba/src/api/list.cpp @@ -67,14 +67,16 @@ namespace mamba { regex = '^' + regex + '$'; } + std::regex spec_pat(regex); + auto all_records = std::move(prefix_data.all_pkg_mgr_records()); if (ctx.output_params.json) { auto jout = nlohmann::json::array(); std::vector keys; - for (const auto& pkg : prefix_data.records()) + for (const auto& pkg : all_records) { keys.push_back(pkg.first); } @@ -83,7 +85,7 @@ namespace mamba for (const auto& key : keys) { auto obj = nlohmann::json(); - const auto& pkg_info = prefix_data.records().find(key)->second; + const auto& pkg_info = all_records.find(key)->second; if (regex.empty() || std::regex_search(pkg_info.name, spec_pat)) { @@ -134,7 +136,7 @@ namespace mamba auto requested_specs = prefix_data.history().get_requested_specs_map(); // order list of packages from prefix_data by alphabetical order - for (const auto& package : prefix_data.records()) + for (const auto& package : all_records) { if (regex.empty() || std::regex_search(package.second.name, spec_pat)) { diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index db6647fd66..ebfedfd28f 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -78,6 +78,22 @@ namespace mamba return m_package_records; } + const PrefixData::package_map& PrefixData::pip_records() const + { + return m_pip_package_records; + } + + PrefixData::package_map PrefixData::all_pkg_mgr_records() const + { + PrefixData::package_map merged_records = m_package_records; + // Note that if the same key (pkg name) is present in both `m_package_records` and + // `m_pip_package_records`, the latter is not considered - and that's exactly what we want + // (this may be modified to be completely independent in the future) + merged_records.insert(m_pip_package_records.begin(), m_pip_package_records.end()); + + return merged_records; + } + std::vector PrefixData::sorted_records() const { // TODO add_pip_as_python_dependency @@ -227,7 +243,7 @@ namespace mamba { auto pkg_info = mamba::util::split(mamba::util::strip(pkg_info_line), "=="); auto prec = specs::PackageInfo(pkg_info[0], pkg_info[1], "pypi_0", "pypi"); - m_package_records.insert({ prec.name, std::move(prec) }); + m_pip_package_records.insert({ prec.name, std::move(prec) }); } } } From e5bf9d187faae31990f24f4ff58c112dc676a8d8 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 24 Oct 2024 17:16:39 +0200 Subject: [PATCH 5/6] Remove unused alias --- libmamba/src/core/transaction.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmamba/src/core/transaction.cpp b/libmamba/src/core/transaction.cpp index cf89256f7f..e0f22dce41 100644 --- a/libmamba/src/core/transaction.cpp +++ b/libmamba/src/core/transaction.cpp @@ -362,8 +362,6 @@ namespace mamba bool MTransaction::execute(const Context& ctx, ChannelContext& channel_context, PrefixData& prefix) { - using Solution = solver::Solution; - // JSON output // back to the top level if any action was required if (!empty()) From 5ff6a0fda15c543f06393b38bef26a9030788597 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Mon, 28 Oct 2024 10:58:17 +0100 Subject: [PATCH 6/6] Use inspect instead of freeze and set platform --- libmamba/src/api/list.cpp | 4 --- libmamba/src/core/prefix_data.cpp | 41 +++++++++++++++++++++++++------ micromamba/tests/test_list.py | 4 ++- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/libmamba/src/api/list.cpp b/libmamba/src/api/list.cpp index 5ba4740402..35e762bd77 100644 --- a/libmamba/src/api/list.cpp +++ b/libmamba/src/api/list.cpp @@ -94,10 +94,6 @@ namespace mamba if (pkg_info.package_url.empty() && (pkg_info.channel == "pypi")) { - // TODO Need to correctly set `platform`, which is empty in PyPI case - // Note that this is only a problem when using `--json` - // (otherwise, the missing info is not needed/used) - // cf. `formatted_pkgs` below obj["base_url"] = "https://pypi.org/"; obj["channel"] = pkg_info.channel; } diff --git a/libmamba/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp index ebfedfd28f..8e5b6ad525 100644 --- a/libmamba/src/core/prefix_data.cpp +++ b/libmamba/src/core/prefix_data.cpp @@ -87,7 +87,7 @@ namespace mamba { PrefixData::package_map merged_records = m_package_records; // Note that if the same key (pkg name) is present in both `m_package_records` and - // `m_pip_package_records`, the latter is not considered - and that's exactly what we want + // `m_pip_package_records`, the latter is not considered // (this may be modified to be completely independent in the future) merged_records.insert(m_pip_package_records.begin(), m_pip_package_records.end()); @@ -216,7 +216,7 @@ namespace mamba const auto args = std::array{ get_python_path(), "-m", "pip", - "freeze", + "inspect", "--local" }; auto [status, ec] = reproc::run( args, @@ -236,14 +236,39 @@ namespace mamba return; } - auto pkgs_info_list = mamba::util::split(mamba::util::strip(out), "\n"); - for (auto& pkg_info_line : pkgs_info_list) + nlohmann::json j = nlohmann::json::parse(out); + + if (j.contains("installed") && j["installed"].is_array()) { - if (pkg_info_line.find("==") != std::string::npos) + for (const auto& package : j["installed"]) { - auto pkg_info = mamba::util::split(mamba::util::strip(pkg_info_line), "=="); - auto prec = specs::PackageInfo(pkg_info[0], pkg_info[1], "pypi_0", "pypi"); - m_pip_package_records.insert({ prec.name, std::move(prec) }); + // Get the package metadata, if requested and installed with `pip` + if (package.contains("requested") && package.contains("installer") + && package["requested"] == true && package["installer"] == "pip") + { + if (package.contains("metadata")) + { + // NOTE As checking the presence of all used keys in the json object can be + // cumbersome and might affect the code readability, the elements where the + // check with `contains` is skipped are considered mandatory. If a bug is + // ever to occur in the future, checking the relevant key with `contains` + // should be introduced then. + auto prec = specs::PackageInfo( + package["metadata"]["name"], + package["metadata"]["version"], + "pypi_0", + "pypi" + ); + // Set platform by concatenating `sys_platform` and `platform_machine` to + // have something equivalent to `conda-forge` + if (j.contains("environment")) + { + prec.platform = j["environment"]["sys_platform"].get() + "-" + + j["environment"]["platform_machine"].get(); + } + m_pip_package_records.insert({ prec.name, std::move(prec) }); + } + } } } } diff --git a/micromamba/tests/test_list.py b/micromamba/tests/test_list.py index 5a1f587755..bc6e8bf37e 100644 --- a/micromamba/tests/test_list.py +++ b/micromamba/tests/test_list.py @@ -1,4 +1,6 @@ +import platform import subprocess +import sys import pytest @@ -68,7 +70,7 @@ def test_list_with_pip(tmp_home, tmp_root_prefix, tmp_path): and package["base_url"] == "https://pypi.org/" and package["build_string"] == "pypi_0" and package["channel"] == "pypi" - and package["platform"] == "" + and package["platform"] == sys.platform + "-" + platform.machine() for package in res )