Skip to content

refactor: make extras and conditionals runtime-configurable#1816

Merged
wolfv merged 12 commits intoconda:mainfrom
baszalmstra:claude/rattler-extras-conditions-011CUtD25vzEQ9Zc6vDXcoMK
Nov 20, 2025
Merged

refactor: make extras and conditionals runtime-configurable#1816
wolfv merged 12 commits intoconda:mainfrom
baszalmstra:claude/rattler-extras-conditions-011CUtD25vzEQ9Zc6vDXcoMK

Conversation

@baszalmstra
Copy link
Collaborator

Replace compile-time feature flags with runtime parsing options for experimental extras and conditionals syntax in matchspecs. Conditions and extras are not yet parsed from repodata.json.

Core Changes

  • Replace ParseStrictness parameter with ParseMatchSpecOptions struct
  • Add ParseMatchSpecOptions with:
    • ::strict() and ::lenient() constructors
    • allow_experimental_extras and allow_experimental_conditionals fields
  • Remove experimental_extras and experimental_conditionals cargo features
  • Remove all cfg feature guards from extras and conditionals code
  • Extras and conditionals are now always available but controlled via options

Rattler Binary

  • Enable experimental features by default in rattler-bin create command

Python Bindings

  • Add optional experimental_extras and experimental_conditionals parameters to MatchSpec and NamelessMatchSpec constructors (default: False)
  • Expose extras and condition fields via getter methods
  • Add comprehensive test suite for experimental features

AI Disclosure

Written by Claude Code Web

@baszalmstra baszalmstra requested a review from wolfv November 7, 2025 10:19
@baszalmstra baszalmstra changed the title refactor: make extras and conditionals runtime-configurable refactor: make extras and conditionals runtime-configurable Nov 7, 2025
@baszalmstra
Copy link
Collaborator Author

@jaimergp Once this is merged, the python bindings also expose conditionals and extras.

@baszalmstra baszalmstra force-pushed the claude/rattler-extras-conditions-011CUtD25vzEQ9Zc6vDXcoMK branch 6 times, most recently from e4b05a5 to 810a2fe Compare November 7, 2025 12:07
Replace compile-time feature flags with runtime parsing options for
experimental extras and conditionals syntax in matchspecs.

## Core Changes

- Replace ParseStrictness parameter with ParseMatchSpecOptions struct
- Add ParseMatchSpecOptions with:
  - ::strict() and ::lenient() constructors
  - allow_experimental_extras and allow_experimental_conditionals fields
  - with_* and set_* builder methods for configuration
- Remove experimental_extras and experimental_conditionals cargo features
- Remove all cfg feature guards from extras and conditionals code
- Extras and conditionals are now always available but controlled via options

## Rattler Binary

- Enable experimental features by default in rattler-bin create command

## Python Bindings

- Add optional experimental_extras and experimental_conditionals parameters
  to MatchSpec and NamelessMatchSpec constructors (default: False)
- Expose extras and condition fields via getter methods
- Add comprehensive test suite for experimental features

## Benefits

- Runtime configuration instead of compile-time features
- Better flexibility for users to enable features per-call
- Backward compatible - features disabled by default
- Python bindings maintain compatibility while adding new functionality
@baszalmstra baszalmstra force-pushed the claude/rattler-extras-conditions-011CUtD25vzEQ9Zc6vDXcoMK branch from 6de7637 to d592fb1 Compare November 7, 2025 13:07
Resolved conflicts by integrating both changes:
- Kept ParseMatchSpecOptions with experimental features (extras, conditionals)
- Added exact_names_only parameter from upstream
- Updated all import statements to include both old and new types
- Updated Python bindings to support all parameters
- Accepted upstream Cargo.lock and will regenerate if needed

All conflicts resolved in:
- crates/rattler_conda_types/src/lib.rs
- crates/rattler_conda_types/src/match_spec/mod.rs
- crates/rattler_conda_types/src/match_spec/parse.rs
- crates/rattler_solve/src/resolvo/mod.rs
- crates/rattler_solve/tests/backends.rs
- py-rattler/Cargo.lock
- py-rattler/rattler/match_spec/match_spec.py
- py-rattler/src/match_spec.rs
- Added exact_names_only field to ParseMatchSpecOptions
- Added with_exact_names_only() and exact_names_only() methods
- Removed experimental_conditionals feature gates (now runtime config)
- Cleaned up unused imports in parse.rs
- MatchSpecCondition is now always available (not feature-gated)
claude and others added 7 commits November 18, 2025 08:24
…pecOptions

This adds the missing From implementation to convert ParseStrictnessWithNameMatcher
to ParseMatchSpecOptions, which was causing compilation errors in tests.
Removed unused ParseStrictness and ParseStrictnessWithNameMatcher imports
from py-rattler match_spec.rs.
This adds the missing `normalized` property to PyPackageNameMatcher
that returns the normalized string representation. For exact matches,
it returns the normalized package name. For glob and regex patterns,
it returns the pattern string.

This fixes the Python test failures where tests were accessing
`m.name.normalized`.
This adds the normalized property to the Python wrapper class for
PackageNameMatcher, which delegates to the underlying Rust
PyPackageNameMatcher.normalized property. This allows Python code
and type checkers (mypy) to access the normalized attribute.
@wolfv
Copy link
Contributor

wolfv commented Nov 20, 2025

Nice clean up!

@wolfv wolfv merged commit dfc9946 into conda:main Nov 20, 2025
19 checks passed
@github-actions github-actions bot mentioned this pull request Nov 20, 2025
baszalmstra pushed a commit to baszalmstra/rattler that referenced this pull request Nov 20, 2025
Integrate changes from main where feature flags for experimental_extras
and experimental_conditionals have been removed in favor of runtime
configuration through ParseMatchSpecOptions.

**Changes:**

- Remove all `#[cfg(feature = "experimental_conditionals")]` and
  `#[cfg(feature = "experimental_extras")]` feature gates
- Update MatchSpec parsing to use `ParseMatchSpecOptions::lenient()`
  with `.with_experimental_conditionals(true)` and
  `.with_experimental_extras(true)`
- Update libsolv_c to work with new `PackageNameMatcher` type instead
  of `PackageName` (use `as_exact()` to get exact package names for extras)
- Remove conditional compilation from test helpers and test modules
- All extras and conditionals support is now always compiled and enabled
  at runtime through parse options

**Testing:**
- All extras tests pass for both libsolv_c and resolvo backends
- All conditional tests pass for both backends
- Tests updated to enable experimental features through parse options

This aligns the codebase with the refactoring done in PR conda#1816 which
made these features runtime-configurable instead of compile-time gated.
@jaimergp
Copy link
Contributor

Thank you!!

@baszalmstra
Copy link
Collaborator Author

Your welcome! And as always, let me know if you run into issues!

@jaimergp
Copy link
Contributor

Trying this in conda-incubator/conda-rattler-solver#19, but I'm not sure it works. I do see the conditional dependencies being passed, but I'm not obtaining errors where I thought I would. Do I need to pass a flag to the solver too? I don't see any 🤔

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants