tflite-micro/tflite_micro.py
Esun Kim 807c35d6a9
Bazel Module (#3364)
* Work

* Review update

* Enabled tests

* Bazel: Suppress warnings from external repositories

* Fixed whl_test

* Formatted

* More format
2026-02-11 14:11:47 -08:00

21 lines
No EOL
691 B
Python

import sys
import os
import types
# Shim to expose 'tflite_micro' submodules pointing to the repo root directories.
# This allows legacy imports like 'from tflite_micro.tensorflow...' to work in Bzlmod runfiles structure.
repo_root = os.path.dirname(os.path.abspath(__file__))
def create_namespace_module(name, relative_path):
m = types.ModuleType(name)
m.__path__ = [os.path.join(repo_root, relative_path)]
return m
# Inject submodules for all top-level directories
for name in ["tensorflow", "python", "tools", "signal", "third_party"]:
full_name = __name__ + "." + name
if full_name not in sys.modules:
sys.modules[full_name] = create_namespace_module(full_name, name)