-
Notifications
You must be signed in to change notification settings - Fork 44
WIP: [proposal] New patcher config #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
tiran
wants to merge
2
commits into
python-wheel-build:main
Choose a base branch
from
tiran:proposal-new-patcher-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Fromager Enhancement Proposals | ||
| ============================== | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
|
|
||
| new-patcher-config |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # New patcher configuration | ||
|
|
||
| - Author: Christian Heimes | ||
| - Created: 2026-02-26 | ||
| - Status: Open | ||
|
|
||
| ## What | ||
|
|
||
| This enhancement document proposal a new approach to patch sources and wheel | ||
| metadata through declarative configuration. | ||
|
|
||
| ## Why | ||
|
|
||
| TODO | ||
|
|
||
| ## Goals | ||
|
|
||
| - provide simple patching facilities with a declarative configuration approach | ||
| - support version-specific patching (e.g. patch build system requirements for | ||
| `>=1.0,<1.0`). | ||
| - make common tasks like fixing sdist metadata (`PKG-INFO`) easier | ||
| - add patching of wheel and sdist package metadata to remove or modify | ||
| installation requirements (`requires-dist` field). | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Patch files will not be deprecated and removed. Patches are still useful | ||
| and will be supported in the future. | ||
| - CPU architecture-specific patches won't be supported, because they are a | ||
| misfeature. Patches will be | ||
|
|
||
| ## How | ||
|
|
||
| The new system will use a new top-level configuration key `patch`, which is | ||
| an array of patch operations. Each patch operation has a title, optional | ||
| version specifier, and an action like `replace-line`, `fix-pkg-info`, or | ||
| `pyproject-build-system`. | ||
|
|
||
| - The action name acts as a tag ([discriminated union](https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions)). | ||
| - The `title` is a human-readable description that explains the purpose of | ||
| the operation. | ||
| - The optional field `when_version` can be used to limit the action, | ||
| e.g. `>=1.0,<1.0`. | ||
| > **NOTE**: `when_version` is not compatible with nightly builds. | ||
| - Some actions have a `ignore_missing` boolean flag. If an action has no | ||
| effect, then it fails and stops the build unless `ignore_missing` is set. | ||
|
|
||
| Example: | ||
|
|
||
| ```yaml | ||
| patch: | ||
| - title: Comment out 'foo' requirement for version >= 1.2 | ||
| action: replace-line | ||
| files: | ||
| - 'requirements.txt' | ||
| search: '^(foo.*)$' | ||
| replace: '# \\1' | ||
| when_version: '>=1.2' | ||
| ignore_missing: true | ||
|
|
||
| - title: Remove 'bar' from constraints.txt | ||
| action: delete-line | ||
| files: | ||
| - 'constraints.txt' | ||
| search: 'bar.*' | ||
|
|
||
| - title: Remove 'somepackage' installation requirement | ||
| action: remove-install-requires | ||
| requirement: somepackage | ||
|
|
||
| - title: Fix PKG-INFO metadata version | ||
| action: fix-pkg-info | ||
| metadata_version: '2.4' | ||
| when_version: '<1.0' | ||
|
|
||
| - title: Add missing setuptools to pyproject.toml | ||
| action: pyproject-build-system | ||
| update_build_requires: | ||
| - setuptools | ||
|
|
||
| - title: Update Torch install requirement to version in build env | ||
| action: pin-install-requires-to-build | ||
| requirement: torch | ||
| ``` | ||
|
|
||
| ### Actions | ||
|
|
||
| All file names are relative to `sdist_root_dir`. | ||
|
|
||
| - The `replace-line` action replaces lines in one or more files. | ||
|
|
||
| - The `delete-line` action removes a line from one or more files. | ||
|
|
||
| - The `pyproject-build-system` action replaces the old `project_override` | ||
| settings `update_build_requires` and `remove_build_requires`. | ||
|
|
||
| - The `remove-install-requires` action removes a `requires-dist` entry from | ||
| sdist and wheel installation requirements. The requirement is matched by | ||
| name-only or by full requirement (including specifier set and markers). | ||
|
|
||
| - The `pin-install-requires-to-build` pins `requires-dist` in sdist | ||
| and wheel metadata to the exact version in the build environment. The | ||
| primary use case is Torch. If a package is build with Torch 2.9.1, then | ||
| we want the wheel to depend on exactly `torch==2.9.1`. | ||
|
|
||
| ### Deprecations | ||
|
|
||
| The old settings `project_override.update_build_requires` and | ||
| `project_override.remove_build_requires` will be deprecated and eventually | ||
| removed. | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| args | ||
| backend | ||
| backends | ||
| backoff | ||
| canonicalize | ||
| canonicalized | ||
| changelog | ||
| changelogs | ||
| cheeseshop | ||
| cn | ||
| codebase | ||
| config | ||
| containerfile | ||
| cpu | ||
| csv | ||
| customizations | ||
| cython | ||
| deprecations | ||
| dir | ||
| downloader | ||
| env | ||
| environ | ||
| filesystem | ||
| fromager | ||
| frontend | ||
| frontends | ||
| graphviz | ||
| gz | ||
| installability | ||
| iterable | ||
| iteratively | ||
| json | ||
| lexicographically | ||
| linter | ||
| localhost | ||
| matcher | ||
| mypy | ||
| namespace | ||
| numpy | ||
| openssl | ||
| platlib | ||
| podman | ||
| pre | ||
| prebuilt | ||
| purelib | ||
| py | ||
| pydantic | ||
| pypi | ||
| pyproject | ||
| recurses | ||
| repo | ||
| scm | ||
| sdist | ||
| sdists | ||
| setuptools | ||
| statelessly | ||
| stderr | ||
| stdin | ||
| stdout | ||
| subcommands | ||
| subdirectory | ||
| submodule | ||
| submodules | ||
| subprocesses | ||
| templating | ||
| toml | ||
| toplevel | ||
| tos | ||
| traceback | ||
| tracebacks | ||
| txt | ||
| unshare | ||
| url | ||
| urls | ||
| vendored | ||
| vendoring | ||
| versionless | ||
| virtualenv | ||
| walkthrough | ||
| whitespace | ||
| yaml |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this sentence got cut-off?