Skip to content

Conversation

@pmattsso
Copy link
Contributor

@pmattsso pmattsso commented Oct 2, 2025

Enable fine-grained control over prebuilt vs source builds within variants by allowing per-version overrides. This resolves conflicts where different collections need different build methods for the same package version.

  • Add VersionSpecificSettings model with pre_built and wheel_server_url
  • Extend VariantInfo with versions mapping for version-specific overrides
  • Update PackageBuildInfo with version-aware methods (is_pre_built, get_wheel_server_url)
  • Modify bootstrapper, wheels, and build commands to use version-specific logic
  • Add comprehensive tests validating precedence and backward compatibility
  • Create detailed how-to documentation with examples and migration guide

Maintains full backward compatibility with existing variant-wide settings. Version-specific settings take precedence over variant defaults when present.

Fixes #801

@pmattsso pmattsso requested a review from a team as a code owner October 2, 2025 10:27
@mergify mergify bot added the ci label Oct 2, 2025
Enable fine-grained control over prebuilt vs source builds within variants
by allowing per-version overrides. This resolves conflicts where different
collections need different build methods for the same package version.

- Add VersionSpecificSettings model with pre_built and wheel_server_url
- Extend VariantInfo with versions mapping for version-specific overrides
- Update PackageBuildInfo with version-aware methods (is_pre_built, get_wheel_server_url)
- Modify bootstrapper, wheels, and build commands to use version-specific logic
- Add comprehensive tests validating precedence and backward compatibility
- Create detailed how-to documentation with examples and migration guide

Maintains full backward compatibility with existing variant-wide settings.
Version-specific settings take precedence over variant defaults when present.

Fixes python-wheel-build#801

# Check if package has version-specific settings (any version-specific config)
variant_info = pbi._ps.variants.get(pbi._variant)
has_version_specific_prebuilt = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is going to be messier than I thought.

The _ps field really should be private to the PBI. We could at least wrap this logic in a method, but it's odd to need to know about the version-specific prebuilt flags before we resolve the version we're going to bootstrapping.

I don't remember why we have different logic for resolving versions of prebuilt wheels. How different is that logic from the other flow? Does it skip some steps or are there completely different steps?

@tiran
Copy link
Collaborator

tiran commented Oct 2, 2025

Can we have a discussion about the design before we move forward? This approach is going to make the package settings more complex and will require API breaking chances. It's also not very flexible, because you'll have to add an entry for every version.

I think a hook function would give is more flexibility and is easier to implement.

Comment on lines +332 to +333
env: EnvVars = Field(default_factory=dict)
"""Version-specific env vars (override variant env vars)"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really, really need this? There is update_extra_environ to add conditional and dynamic env vars.

Comment on lines +329 to +330
annotations: RawAnnotations | None = None
"""Version-specific annotations (override variant annotations)"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where version-specific annotations are added to annotations.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add version-specific prebuilt wheel configuration support

3 participants