-
-
Notifications
You must be signed in to change notification settings - Fork 636
fix: delete BUILD et al files from pypi sourced dependencies #3029
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
rickeylev
merged 9 commits into
bazel-contrib:main
from
rickeylev:fix.pypi.rm.build.files
Jun 27, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
23cb11d
fix: delete BUILD et al files from pypi sourced dependencies
rickeylev 34a3090
add test
rickeylev 7cceefc
skip workspace, windows
rickeylev 3369453
fix bzlmod_unixy import
rickeylev 0a8c2fd
ignore test data files, format test, fixup bzl code
rickeylev 62f05ec
fixup package refs
rickeylev f982303
comment why its just import statements
rickeylev 9840ca1
update changelog
rickeylev 1be226b
Merge branch 'main' of https://github.com/bazel-contrib/rules_python …
rickeylev 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
Empty file.
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,50 @@ | ||
| """Creates a whl file from a directory tree. | ||
| Used to test wheels. Avoids checking in prebuilt files and their associated | ||
| security risks. | ||
| """ | ||
|
|
||
| load("//python/private:repo_utils.bzl", "repo_utils") # buildifier: disable=bzl-visibility | ||
|
|
||
| def _whl_from_dir_repo(rctx): | ||
| root = rctx.path(rctx.attr.root).dirname | ||
| repo_utils.watch_tree(rctx, root) | ||
|
|
||
| output = rctx.path(rctx.attr.output) | ||
| repo_utils.execute_checked( | ||
| rctx, | ||
| # cd to root so zip recursively takes everything there. | ||
| working_directory = str(root), | ||
| op = "WhlFromDir", | ||
| arguments = [ | ||
| "zip", | ||
| "-0", # Skip compressing | ||
| "-X", # Don't store file time or metadata | ||
| str(output), | ||
| "-r", | ||
| ".", | ||
| ], | ||
| ) | ||
| rctx.file("BUILD.bazel", 'exports_files(glob(["*"]))') | ||
|
|
||
| whl_from_dir_repo = repository_rule( | ||
rickeylev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| implementation = _whl_from_dir_repo, | ||
| attrs = { | ||
| "output": attr.string( | ||
| doc = """ | ||
| Output file name to write. Should match the wheel filename format: | ||
| `pkg-version-pyversion-abi-platform.whl`. Typically a value like | ||
| `mypkg-1.0-any-none-any.whl` is whats used for testing. | ||
| For the full format, see | ||
| https://packaging.python.org/en/latest/specifications/binary-distribution-format/#file-name-convention | ||
| """, | ||
| ), | ||
| "root": attr.label( | ||
| doc = """ | ||
| A file whose directory will be put into the output wheel. All files | ||
| are included verbatim. | ||
| """, | ||
| ), | ||
| }, | ||
| ) | ||
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,9 @@ | ||
| load("//python:py_test.bzl", "py_test") | ||
| load("//tests/support:support.bzl", "SUPPORTS_BZLMOD_UNIXY") | ||
|
|
||
| py_test( | ||
| name = "verify_files_test", | ||
| srcs = ["verify_files_test.py"], | ||
| target_compatible_with = SUPPORTS_BZLMOD_UNIXY, | ||
| deps = ["@somepkg_with_build_files//:pkg"], | ||
| ) |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
tests/whl_with_build_files/testdata/somepkg-1.0.dist-info/WHEEL
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 @@ | ||
| Wheel-Version: 1.0 |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,17 @@ | ||
| import unittest | ||
|
|
||
|
|
||
| class VerifyFilestest(unittest.TestCase): | ||
|
|
||
| def test_wheel_with_build_files_importable(self): | ||
| # If the BUILD files are present, then these imports should fail | ||
| # because globs won't pass package boundaries, and the necessary | ||
| # py files end up missing in runfiles. | ||
| import somepkg | ||
| import somepkg.a | ||
| import somepkg.subpkg | ||
| import somepkg.subpkg.b | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.