-
-
Notifications
You must be signed in to change notification settings - Fork 700
perf(pypi): extract wheels once and reuse #3856
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
aignas
wants to merge
10
commits into
bazel-contrib:main
Choose a base branch
from
aignas:aignas.refactor.single_dep_whl_library
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
10 commits
Select commit
Hold shift + click to select a range
67b804a
add a spike
aignas 2d39bd1
wip
aignas ec99735
wip
aignas 08fc8f8
wip
aignas b6d69a8
wip
aignas a249844
wip
aignas b6973b8
wip
aignas 82bf47d
fixup
aignas 8cc7bf9
wip
aignas db1494b
wip
aignas 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Plan: Split whl BUILD.bazel generation into srcs + deps phases | ||
|
|
||
| ## Overview | ||
|
|
||
| The spike commit (67b804a0) restructured `whl_library_targets.bzl` into two macros: | ||
| - `whl_library_srcs` — creates filegroup/py_library targets **without** dependencies | ||
| - `whl_library_targets` — creates public `pkg`/`whl` targets that depend on the inner `_srcs`/`_whl_file` targets **plus** deps | ||
|
|
||
| This plan builds on that work to: | ||
| 1. Make the generated BUILD.bazel call both macros | ||
| 2. Add `whl_library_deps` as a companion repo rule that reads METADATA from an extracted wheel and generates deps-only targets | ||
| 3. Wire it all through `hub_builder.bzl` so that wheels can be split into a srcs-only phase and a deps phase | ||
|
|
||
| --- | ||
|
|
||
| ## Step 1: Rename `whl_library_targets_from_requires` → `whl_library_from_requires_dist` | ||
|
|
||
| **Status**: ✅ Completed | ||
|
|
||
| **File**: `python/private/pypi/whl_library_targets.bzl` | ||
|
|
||
| - Renamed function and updated the single call site. | ||
|
|
||
| --- | ||
|
|
||
| ## Step 2: Restructure `generate_whl_library_build_bazel.bzl` | ||
|
|
||
| **Status**: ✅ Completed | ||
|
|
||
| **File**: `python/private/pypi/generate_whl_library_build_bazel.bzl` | ||
|
|
||
| The generated BUILD.bazel now contains **two** macro calls (`whl_library_srcs` + `whl_library_from_requires_dist`). All explicit keyword args are accepted and split into `srcs_kwargs` vs `from_requires_kwargs` dicts. `whl_library_from_requires_dist` is only emitted when `config_load` is specified or `requires_dist` is non-empty. | ||
|
|
||
| --- | ||
|
|
||
| ## Step 3: Build verification | ||
|
|
||
| **Status**: ✅ Completed — `bazel build //docs:sphinx-build --config=fast-tests` passes | ||
|
|
||
| --- | ||
|
|
||
| ## Step 4: Implement `whl_library_deps` repository rule | ||
|
|
||
| **Status**: ✅ Completed | ||
|
|
||
| **File**: `python/private/pypi/whl_library.bzl` | ||
|
|
||
| The `_whl_library_deps_impl` now contains real logic: it accepts a `whl_library` label, finds and parses the METADATA file from the extracted wheel, and generates a BUILD.bazel that calls `whl_library_from_requires_dist` with the parsed metadata. The generated BUILD does NOT call `whl_library_srcs`. | ||
|
|
||
| --- | ||
|
|
||
| ## Step 5: Wire into `hub_builder.bzl` and `extension.bzl` | ||
|
|
||
| **Status**: ✅ Completed | ||
|
|
||
| **File**: `python/private/pypi/hub_builder.bzl`, `python/private/pypi/extension.bzl` | ||
|
|
||
| In `_create_whl_repos`, each `whl_library` is created **without** `config_load` (srcs-only), and a corresponding `whl_library_deps` repo is created that references the extracted `whl_library` to provide the deps. Wired through `extension.bzl` as well. | ||
|
|
||
| --- | ||
|
|
||
| ## Next Steps | ||
|
|
||
| All steps completed successfully. Build verified with `bazel build //docs:sphinx-build --config=fast-tests` | ||
|
|
||
| ## Final Status | ||
|
|
||
| | Step | Description | Status | | ||
| |------|-------------|--------| | ||
| | 1 | Rename `whl_library_targets_from_requires` → `whl_library_from_requires_dist` | ✅ Complete | | ||
| | 2 | Restructure `generate_whl_library_build_bazel.bzl` to emit two macros | ✅ Complete | | ||
| | 3 | Build verification (`bazel build //docs:sphinx-build --config=fast-tests`) | ✅ Passes | | ||
| | 4 | Implement `whl_library_deps` repository rule | ✅ Complete | | ||
| | 5 | Wire through `hub_builder.bzl` and `extension.bzl` | ✅ Complete | | ||
|
|
||
| All five steps of the plan are implemented and verified. The wheel BUILD.bazel generation is now split into separate srcs and deps phases. |
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.
TODO: add back the fail.