Skip to content
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

Refactor TF build wheel rule. #21007

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions third_party/tsl/opensource_only.files
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ third_party/py/python_init_repositories.bzl:
third_party/py/python_init_rules.bzl:
third_party/py/python_init_toolchains.bzl:
third_party/py/python_repo.bzl:
third_party/py/python_wheel_version.bzl:
third_party/pybind11.BUILD:
third_party/pybind11_bazel/BUILD:
third_party/python_runtime/BUILD:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def verify_manylinux_compliance(
Raises:
RuntimeError: if the wheel is not manyLinux compliant.
"""
regex = 'following platform tag: "{}"'.format(compliance_tag)
regex = 'following platform tag:\s+"{}"'.format(compliance_tag)
if not re.search(regex, auditwheel_log):
raise RuntimeError(
("The wheel is not compliant with the tag {tag}.\n{result}").format(
Expand Down
24 changes: 24 additions & 0 deletions third_party/tsl/third_party/py/python_wheel_version.bzl
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),
},
)