Repository navigation
Conversation
messense
force-pushed
the
feature/conditional-feature-python-implementation
branch
2 times, most recently
from
February 24, 2026 11:45
b52c94a to
4944733
Compare
Allow conditional cargo features to also filter on the Python
implementation (cpython, pypy, graalpy) in addition to python-version.
Both fields are now optional — at least one must be present for a
conditional entry. Matching is case-insensitive.
Example:
features = [
{ feature = "pyo3/abi3-py311", python-version = ">=3.11", python-implementation = "cpython" },
{ feature = "pypy-compat", python-implementation = "pypy" },
]
Closes PyO3#3037
messense
force-pushed
the
feature/conditional-feature-python-implementation
branch
from
February 24, 2026 11:54
4944733 to
56933d4
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for conditioning Cargo features on the Python implementation (cpython/pypy/graalpy) in addition to Python version, making conditional matching case-insensitive.
Changes:
- Extend
FeatureSpec::Conditionalto accept optionalpython-versionand optionalpython-implementation. - Update conditional feature resolution to filter by both version and implementation.
- Update JSON schema and add tests for implementation-based matching/deserialization.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pyproject_toml.rs | Adds python-implementation support, introduces ConditionalFeature + FeatureConditionEnv, updates resolution logic, and expands tests. |
| src/compile.rs | Builds a condition environment (version + implementation) and updates logging for resolved conditional features. |
| src/build_options.rs | Refactors extraction of pyo3 features to ignore plain specs while handling conditional specs uniformly. |
| src/build_context.rs | Replaces (String, VersionSpecifiers) with ConditionalFeature in build context. |
| maturin.schema.json | Documents python-implementation and relaxes required fields for conditional feature entries. |
Comments suppressed due to low confidence (1)
maturin.schema.json:1
- The schema currently allows a conditional object with only
featureand neitherpython-versionnorpython-implementation, but the PR description states at least one of those must be present. To align the schema with the documented contract, add a constraint (e.g.,anyOfrequiringpython-versionor requiringpython-implementation) so invalid conditional entries are rejected by schema validation.
{
messense
enabled auto-merge (squash)
February 24, 2026 12:16
messense
deleted the
feature/conditional-feature-python-implementation
branch
February 24, 2026 13:29
bmwiedemann
pushed a commit
to bmwiedemann/openSUSE
that referenced
this pull request
Mar 31, 2026
https://build.opensuse.org/request/show/1343551 by user mia + anag_factory - Drop CVE-2026-25727.patch (handled in _service) - Update to 1.12.6 * Sync legacy_py.rs with upstream PyPI warehouse legacy.py gh#PyO3/maturin#3053 * Keep cargo build artifact at original path after staging gh#PyO3/maturin#3054 - Update to 1.12.5 * feat: include debug info files (.pdb, .dSYM, .dwp) in wheels gh#PyO3/maturin#3024 * Fix wrong abi3 tag for conditional cargo features enabled pyo3 abi3 feature gh#PyO3/maturin#3029 * fix: maturin build --sdist wheel name/layout for excluded workspace crates gh#PyO3/maturin#3031 * fix: preserve wheel output dir when building from unpacked sdist gh#PyO3/maturin#3036 * feat: add python-implementation condition to conditional features gh#PyO3/maturin#3038 * Fix non-existent comment tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allow conditional cargo features to also filter on the Python implementation (cpython, pypy, graalpy) in addition to python-version.
Both fields are now optional — at least one must be present for a conditional entry, otherwise treated as a plain entry. Matching is case-insensitive.
Example:
Closes #3037