Skip to content

Implement wheel_build_tag hook for unique wheel file names #1181

Description

@rd4398

Summary

Implement the accepted proposal from PR #1066 (docs/proposals/wheel-build-tag-hook.md).
Tracking issue: #1059

Requirements

  1. Global settings: Add a wheels section to the global settings file with a build_tag_hook field (ImportString via Pydantic) that points to a callable.

    wheels:
      build_tag_hook: "mypackage.hooks:build_tag_hook"
  2. Hook signature: The configured callable receives ctx, req, version, and wheel_tags (all keyword-only) and returns Sequence[str] — ordered suffix segments like ["el9.6", "rocm7.1", "torch2.10.0"].

    def build_tag_hook(
        *,
        ctx: context.WorkContext,
        req: Requirement,
        version: Version,
        wheel_tags: frozenset[Tag],
    ) -> typing.Sequence[str]:
        ...
  3. Suffix construction: Join returned segments with _ and append to the existing numeric build tag (e.g. 88_el9.6_rocm7.1).

  4. Validation: Each segment must match [a-zA-Z0-9.] only. Fail the build on invalid characters or hook exceptions.

  5. No-op default: When build_tag_hook is unset, no suffix is appended (current behavior preserved).

  6. No wheel content access: The hook must not depend on wheel content, build env, or ELF info — it must produce the same result whether building fresh or retrieving from cache.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions