-
Notifications
You must be signed in to change notification settings - Fork 439
feat: Sharded Repodata Support for repoquery
#4226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,28 @@ namespace mamba | |
| return names; | ||
| } | ||
|
|
||
| std::vector<std::string> | ||
| extract_exact_package_names_from_specs(const std::vector<std::string>& specs) | ||
| { | ||
| std::vector<std::string> names; | ||
| names.reserve(specs.size()); | ||
| for (const auto& s : specs) | ||
| { | ||
| auto parsed = specs::MatchSpec::parse(s); | ||
| if (!parsed || parsed->name().is_free() || !parsed->name().is_exact()) | ||
| { | ||
| return {}; | ||
| } | ||
| auto name = parsed->name().to_string(); | ||
| if (name.empty()) | ||
| { | ||
| return {}; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark here. |
||
| names.push_back(std::move(name)); | ||
| } | ||
| return names; | ||
| } | ||
|
|
||
| void add_pip_if_python(std::vector<std::string>& root_packages) | ||
| { | ||
| bool has_python = false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) 2026, QuantStack and Mamba Contributors | ||
| // | ||
| // Distributed under the terms of the BSD 3-Clause License. | ||
| // | ||
| // The full license is in the file LICENSE, distributed with this software. | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include <catch2/catch_all.hpp> | ||
|
|
||
| namespace mamba | ||
| { | ||
| std::vector<std::string> extract_package_names_from_specs(const std::vector<std::string>& specs); | ||
| std::vector<std::string> | ||
| extract_exact_package_names_from_specs(const std::vector<std::string>& specs); | ||
| } | ||
|
|
||
| using namespace mamba; | ||
|
|
||
| TEST_CASE("repoquery sharded roots extraction", "[mamba::api][repoquery]") | ||
| { | ||
| SECTION("extract names from valid MatchSpecs") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| "xtensor=0.24.5", | ||
| "conda-forge::python>=3.11", | ||
| "xsimd[version='>=13']", | ||
| }; | ||
|
|
||
| const auto names = extract_package_names_from_specs(specs); | ||
| REQUIRE(names == std::vector<std::string>{ "xtensor", "python", "xsimd" }); | ||
| } | ||
|
|
||
| SECTION("ignore name-free specs and keep valid names") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| "numpy<2", | ||
| ">=1.0", | ||
| }; | ||
|
|
||
| const auto names = extract_package_names_from_specs(specs); | ||
| REQUIRE(names == std::vector<std::string>{ "numpy" }); | ||
| } | ||
|
|
||
| SECTION("empty when all specs are name-free") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| ">=1.0", | ||
| "<2", | ||
| }; | ||
|
|
||
| const auto names = extract_package_names_from_specs(specs); | ||
| REQUIRE(names.empty()); | ||
| } | ||
| } | ||
|
|
||
| TEST_CASE("repoquery search exact roots extraction", "[mamba::api][repoquery]") | ||
| { | ||
| SECTION("extract exact names") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| "xtensor", | ||
| "python=3.12", | ||
| }; | ||
|
|
||
| const auto names = extract_exact_package_names_from_specs(specs); | ||
| REQUIRE(names == std::vector<std::string>{ "xtensor", "python" }); | ||
| } | ||
|
|
||
| SECTION("reject glob queries") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| "xtensor*", | ||
| }; | ||
|
|
||
| const auto names = extract_exact_package_names_from_specs(specs); | ||
| REQUIRE(names.empty()); | ||
| } | ||
|
|
||
| SECTION("reject mixed exact and glob queries") | ||
| { | ||
| const std::vector<std::string> specs = { | ||
| "xtensor", | ||
| "xsimd*", | ||
| }; | ||
|
|
||
| const auto names = extract_exact_package_names_from_specs(specs); | ||
| REQUIRE(names.empty()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -261,7 +261,10 @@ def test_remote_search_python_site_packages_path(yaml_env: Path): | |||||||||||||||
| assert package_info["name"] == "python" | ||||||||||||||||
| assert package_info["version"] == "3.13.1" | ||||||||||||||||
| assert package_info["track_features"] == "py_freethreading" | ||||||||||||||||
| assert package_info["python_site_packages_path"] == "lib/python3.13t/site-packages" | ||||||||||||||||
| if platform.system() == "Windows": | ||||||||||||||||
| assert package_info["python_site_packages_path"] == "Lib/site-packages" | ||||||||||||||||
| else: | ||||||||||||||||
| assert package_info["python_site_packages_path"] == "lib/python3.13t/site-packages" | ||||||||||||||||
|
Comment on lines
+264
to
+267
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct? This is based on: mamba/libmamba/src/core/transaction.cpp Lines 132 to 138 in f7d6d8e
which is based on what I have observed. |
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| @pytest.mark.parametrize("wildcard", [False, True]) | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to log the failing parsing and continue?