-
Notifications
You must be signed in to change notification settings - Fork 50
docs(proposal): add iterative bootstrap proposal #1097
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
Merged
LalatenduMohanty
merged 1 commit into
python-wheel-build:main
from
rd4398:iterative-bootstrap-proposal
Apr 30, 2026
+61
−0
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| Proposal: Convert Bootstrapper from Recursive to Iterative | ||
| ========================================================== | ||
|
|
||
| Problem | ||
| ------- | ||
|
|
||
| The ``Bootstrapper`` class processes dependency trees using recursive calls. | ||
| When bootstrapping packages with deep or wide dependency graphs — especially | ||
| with ``--multiple-versions`` enabled — this hits Python's recursion depth limit | ||
| and causes stack overflow errors. The recursion occurs at two points: processing | ||
| install dependencies after building a package, and processing build | ||
| dependencies before building. | ||
|
|
||
| Proposed Solution | ||
| ----------------- | ||
|
|
||
| Replace the recursive depth-first traversal with an iterative approach using an | ||
| explicit work stack. Each package version to bootstrap is represented as a | ||
| ``BootstrapWorkItem`` dataclass that flows through five linear phases: | ||
|
|
||
| 1. **START** — Add to dependency graph and check if already seen (early exit if so) | ||
| 2. **EXTRACT_BUILD_DEPS** — Collect build dependencies and push them onto the stack | ||
| 3. **BUILD_PACKAGE** — Build sdist and/or wheel, record in build order | ||
| 4. **EXTRACT_INSTALL_DEPS** — Extract install dependencies and push onto the stack | ||
| 5. **COMPLETE** — Clean up build directories | ||
|
|
||
| The LIFO stack ensures depth-first traversal order is preserved. Build | ||
| dependencies are pushed in reverse order so they pop in the correct sequence | ||
| (BUILD_SYSTEM before BUILD_BACKEND before BUILD_SDIST). Each dependency | ||
| completes all five phases before its parent continues to the next phase. | ||
|
rd4398 marked this conversation as resolved.
|
||
|
|
||
| This pattern already exists in the codebase: ``dependency_graph.py`` and | ||
| ``commands/graph.py`` both use stack-based DFS traversals. | ||
|
|
||
| Scope | ||
| ----- | ||
|
|
||
| This is a pure refactoring — no behavior changes. The external interface | ||
| (``bootstrap()`` method signature, CLI flags, output files) remains identical. | ||
| All existing error handling modes (normal fail-fast, ``--test-mode``, | ||
| ``--multiple-versions``) are preserved. Progress bar semantics are unchanged. | ||
|
|
||
|
rd4398 marked this conversation as resolved.
|
||
| The change is limited to ``src/fromager/bootstrapper.py``. No other files | ||
| require modification. All existing tests must pass without changes. | ||
|
|
||
| Benefits | ||
| -------- | ||
|
|
||
| - Eliminates recursion depth limits entirely (work stack lives on the heap) | ||
| - Handles arbitrarily deep and wide dependency graphs | ||
| - Improves debuggability with explicit state in work items | ||
| - Follows proven patterns already established in the codebase | ||
|
|
||
| Verification | ||
| ------------ | ||
|
|
||
| - All existing unit and e2e tests must pass unchanged | ||
| - Bootstrap output for the same inputs must be identical | ||
| - Performance should remain within 10% of the recursive version | ||
| - Rollback via ``git revert`` if issues are discovered post-merge | ||
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.
Uh oh!
There was an error while loading. Please reload this page.