MCPcopy Create free account
hub / github.com/apache/tvm-ffi / generate_export

Function generate_export

python/tvm_ffi/stub/codegen.py:223–240  ·  view source on GitHub ↗

Generate an `__all__` variable for the given names.

(code: CodeBlock)

Source from the content-addressed store, hash-verified

221
222
223def generate_export(code: CodeBlock) -> None:
224 """Generate an `__all__` variable for the given names."""
225 assert len(code.lines) >= 2
226
227 mod = code.param
228 code.lines = [
229 code.lines[0],
230 "# fmt: off",
231 "# isort: off",
232 f"from .{mod} import * # noqa: F403",
233 f"from .{mod} import __all__ as {mod}__all__",
234 'if "__all__" not in globals():',
235 " __all__ = []",
236 f"__all__.extend({mod}__all__)",
237 "# isort: on",
238 "# fmt: on",
239 code.lines[-1],
240 ]
241
242
243def generate_ffi_api(

Calls

no outgoing calls