-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace dependency on pre-built wheels with
py_import
dependency.
PiperOrigin-RevId: 693088159
- Loading branch information
1 parent
88dcf65
commit 51f7820
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,24 @@ | ||
""" Repository rule to generate a file with python wheel version. """ | ||
|
||
def _python_wheel_version_repository_impl(repository_ctx): | ||
file_content = repository_ctx.read( | ||
repository_ctx.path(repository_ctx.attr.file_with_version), | ||
) | ||
version_line_start_index = file_content.find(repository_ctx.attr.version_key) | ||
version_line_end_index = version_line_start_index + file_content[version_line_start_index:].find("\n") | ||
repository_ctx.file( | ||
"wheel_version.bzl", | ||
file_content[version_line_start_index:version_line_end_index].replace( | ||
repository_ctx.attr.version_key, | ||
"WHEEL_VERSION", | ||
), | ||
) | ||
repository_ctx.file("BUILD", "") | ||
|
||
python_wheel_version_repository = repository_rule( | ||
implementation = _python_wheel_version_repository_impl, | ||
attrs = { | ||
"file_with_version": attr.label(mandatory = True, allow_single_file = True), | ||
"version_key": attr.string(mandatory = True), | ||
}, | ||
) |