diff --git a/backends/apple/coreml/TARGETS b/backends/apple/coreml/TARGETS index 444e886b4e6..2f3494b6004 100644 --- a/backends/apple/coreml/TARGETS +++ b/backends/apple/coreml/TARGETS @@ -82,6 +82,7 @@ runtime.python_library( "//executorch/exir/backend:partitioner", "//executorch/exir/backend:utils", "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual ], ) diff --git a/backends/qualcomm/recipes/TARGETS b/backends/qualcomm/recipes/TARGETS index 12d1bac6f12..6a7abfd61c6 100644 --- a/backends/qualcomm/recipes/TARGETS +++ b/backends/qualcomm/recipes/TARGETS @@ -30,6 +30,7 @@ runtime.python_library( deps = [ "//caffe2:torch", "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual "//executorch/backends/qualcomm/partition:partition", "//executorch/backends/qualcomm/serialization:serialization", "//executorch/backends/qualcomm/utils:utils", diff --git a/backends/xnnpack/recipes/TARGETS b/backends/xnnpack/recipes/TARGETS index 6b6c1ddfe82..5d452b4a4b7 100644 --- a/backends/xnnpack/recipes/TARGETS +++ b/backends/xnnpack/recipes/TARGETS @@ -30,6 +30,7 @@ runtime.python_library( deps = [ "//caffe2:torch", "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", "//executorch/backends/xnnpack/partition:xnnpack_partitioner", ":xnnpack_recipe_types", diff --git a/backends/xnnpack/test/TARGETS b/backends/xnnpack/test/TARGETS index d20a6003f3f..1729a893ff4 100644 --- a/backends/xnnpack/test/TARGETS +++ b/backends/xnnpack/test/TARGETS @@ -107,6 +107,7 @@ runtime.python_test( deps = [ "//executorch/backends/xnnpack/recipes:xnnpack_recipes", "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual "//pytorch/vision:torchvision", # @manual "//executorch/backends/xnnpack/test/tester:tester", "//executorch/examples/models:models", # @manual diff --git a/devtools/etrecord/tests/TARGETS b/devtools/etrecord/tests/TARGETS index f25f0464c9e..59f73bdb406 100644 --- a/devtools/etrecord/tests/TARGETS +++ b/devtools/etrecord/tests/TARGETS @@ -23,5 +23,6 @@ runtime.python_library( "//executorch/exir/tests:models", "//executorch/backends/xnnpack/partition:xnnpack_partitioner", "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual ], ) diff --git a/export/TARGETS b/export/TARGETS index 50afa6db6ed..9f6cb37950c 100644 --- a/export/TARGETS +++ b/export/TARGETS @@ -32,7 +32,6 @@ runtime.python_library( ":recipe", ":stages", ":types", - "//executorch/runtime:runtime", ":recipe_registry" ] ) diff --git a/export/export.py b/export/export.py index dc7916ad21f..03ac2c3194d 100644 --- a/export/export.py +++ b/export/export.py @@ -631,8 +631,15 @@ def run_method( Raises: RuntimeError: If the method cannot be loaded """ - # Lazy import to avoid forcing portable_lib dependency at module load time - from executorch.runtime import Runtime, Verification + # Lazy import to avoid forcing portable_lib dependency at module load time. + try: + from executorch.runtime import Runtime, Verification + except ModuleNotFoundError as e: + raise ModuleNotFoundError( + "executorch.runtime is not available. " + "In OSS: Please ensure executorch is properly installed via pip. " + "In fbcode: Please add //executorch/runtime:runtime to your dependencies." + ) from e et_runtime = Runtime.get() program = et_runtime.load_program(