Skip to content

build(bazel): inject tflite_micro shim via tflm_py_* wrappers#3573

Merged
veblush merged 1 commit into
tensorflow:mainfrom
rkuester:feat-py-shim-macro
May 26, 2026
Merged

build(bazel): inject tflite_micro shim via tflm_py_* wrappers#3573
veblush merged 1 commit into
tensorflow:mainfrom
rkuester:feat-py-shim-macro

Conversation

@rkuester
Copy link
Copy Markdown
Contributor

Python targets in this repository import one another under the
"tflite_micro" package namespace, which //:tflite_micro_shim synthesizes
at import time. The shim is required under Bzlmod, where the main
repository's runfiles root is the fixed name "_main" rather than the
module name, so the "tflite_micro" prefix no longer resolves on its own.
Every such target therefore had to list //:tflite_micro_shim in its
deps, which was repetitive and easy to forget.

Add tflm_py_library, tflm_py_test, and tflm_py_binary wrappers in a new
//python:py_rules.bzl that inject the shim dependency automatically,
following the naming convention of the existing tflm_cc_* wrappers, and
document the shim's rationale there. Convert every target that
previously listed the shim to the corresponding wrapper and drop the
explicit dependency. The dependency graph is unchanged; only the means
by which the shim is attached differs.

BUG=part of #3128

@rkuester rkuester requested a review from a team as a code owner May 26, 2026 03:10
@veblush veblush added the ci:full Triggers the comprehensive cross-platform test suite. label May 26, 2026
@veblush veblush self-requested a review May 26, 2026 14:17
@veblush veblush temporarily deployed to integration-test May 26, 2026 14:17 — with GitHub Actions Inactive
veblush
veblush previously approved these changes May 26, 2026
@rkuester
Copy link
Copy Markdown
Contributor Author

It looks like the buildifier in the latest tflm-ci image (as of September 2025) has stronger opinions on the ordering of load statements than did older buildifier versions. I'll fix the ordering, and update my local tools to match CI.

Python targets in this repository import one another under the
"tflite_micro" package namespace, which //:tflite_micro_shim synthesizes
at import time. The shim is required under Bzlmod, where the main
repository's runfiles root is the fixed name "_main" rather than the
module name, so the "tflite_micro" prefix no longer resolves on its own.
Every such target therefore had to list //:tflite_micro_shim in its
deps, which was repetitive and easy to forget.

Add tflm_py_library, tflm_py_test, and tflm_py_binary wrappers in a new
//python:py_rules.bzl that inject the shim dependency automatically,
following the naming convention of the existing tflm_cc_* wrappers, and
document the shim's rationale there. Convert every target that
previously listed the shim to the corresponding wrapper and drop the
explicit dependency. The dependency graph is unchanged; only the means
by which the shim is attached differs.
@veblush veblush added this pull request to the merge queue May 26, 2026
Merged via the queue into tensorflow:main with commit 068c6a5 May 26, 2026
44 checks passed
@rkuester rkuester deleted the feat-py-shim-macro branch May 26, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Triggers the comprehensive cross-platform test suite.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants