Skip to content

Commit

Permalink
Replace dependency on pre-built wheels with py_import dependency.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 693088159
  • Loading branch information
tensorflower-gardener authored and copybara-github committed Dec 3, 2024
1 parent 88dcf65 commit 51f7820
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions opensource_only.files
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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/py/verify_manylinux_compliance.py:
third_party/pybind11.BUILD:
third_party/pybind11_bazel/BUILD:
Expand Down
24 changes: 24 additions & 0 deletions 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),
},
)

0 comments on commit 51f7820

Please sign in to comment.