Skip to content

Conversation

@danyeaw
Copy link

@danyeaw danyeaw commented Nov 20, 2025

Description

Partially closes #4089 by adding conditional support based on the draft CEP. This will need to be updated once we agree on the syntax, if we use the bracket style of passing in a conditional key it will require less parsing for this implementation.

I do not have experience with the mamba code base - this was my first time contributing and setting up a development environment. I also only limited experience with C++ - so all feedback is greatly appreciated.

This PR was assisted by a LLM in order to help gauge the amount of work this would be. The initial prompt was "What changes would be needed to support repodata v3, similar to how Rattler supports the implementation?" Follow-up context using the following steps:

  1. Create MatchSpecCondition data structure (header and implementation) with tests
  2. Update MatchSpec to include condition field and parsing
  3. Update repodata parsing to handle conditional dependencies (parse only, no evaluation)
  4. Integrate conditional dependencies into solver with condition evaluation against pool

A follow-up change could also add support for extras and flags.

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@github-actions github-actions bot added the release::enhancements For enhancements PRs or implementing features label Nov 20, 2025
@danyeaw
Copy link
Author

danyeaw commented Nov 24, 2025

Hey @baszalmstra, since you are very familiar with the Rattler implementation, would you have a few minutes to review this?

@baszalmstra
Copy link

Wow, this is quite the PR! A thorough review is definitely required!

I checked the codebase a little bit, and I think this method is fundamentally flawed. Although it will handle cases with virtual packages because they are known upfront, it will not work with version checks. E.g. numpy >=2; if python >=3.12 & numpy <2; if python <3.12. Or even just numpy; if foobar, the solution might not even contain foobar even though it is available in the pool. These cases can only be solved at solve time. And they are used plenty in the Python ecosystem. But I'm sure you are aware of this.

I think the code around checking these "static" virtual packages could also be improved a lot. There is a custom check in there now but you could also just match the condition against prebuild virtual packages.

On the C++ front there are also definitely some things to improve. Although my C++ is very Rusty (pun intended), I think the use of raw pointers and unique_ptrs, could use some tweaking. There were multiple = default implementations added in places that werent really touched, and in some functions it was removed where I think it isnt necessary.

Regardless, libsolv actually does already support conditional dependencies, and I think it's just a matter of wiring them up properly. Rattler also has a libsolv implementation where I am experimenting with this, see this pr.

If I were a maintainer of mamba (which, to be clear, I am not), I would first try to split this PR up into more individualized components before merging. Start with the parsing, potentially make conditionals optional initially, and then work on integrating the solver. I would definitely not merge this PR with the current functionality because it contains a lot of unhandled edge cases.

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 90.89332% with 105 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.34%. Comparing base (3d958ca) to head (f13c6e6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
libmamba/src/specs/match_spec_condition.cpp 78.24% 47 Missing ⚠️
libmamba/src/solver/libsolv/helpers.cpp 75.67% 27 Missing ⚠️
...ibmamba/tests/src/solver/libsolv/test_database.cpp 95.41% 6 Missing and 5 partials ⚠️
libmamba/src/specs/match_spec.cpp 85.71% 8 Missing ⚠️
libmamba/tests/src/solver/libsolv/test_solver.cpp 97.20% 5 Missing ⚠️
...amba/tests/src/specs/test_match_spec_condition.cpp 98.04% 2 Missing and 2 partials ⚠️
libmamba/src/api/configuration.cpp 0.00% 2 Missing ⚠️
libmamba/include/mamba/specs/match_spec.hpp 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4098      +/-   ##
==========================================
+ Coverage   63.57%   64.34%   +0.76%     
==========================================
  Files         315      318       +3     
  Lines       38562    39685    +1123     
  Branches     2950     3026      +76     
==========================================
+ Hits        24517    25535    +1018     
- Misses      13976    14074      +98     
- Partials       69       76       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::enhancements For enhancements PRs or implementing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for repodata and MatchSpec for conditional / extra / flags

2 participants