diff --git a/codegen/parse.py b/codegen/parse.py index b36dd6f77e7..465d154fef9 100644 --- a/codegen/parse.py +++ b/codegen/parse.py @@ -5,7 +5,12 @@ import yaml -from executorch.codegen.model import ETKernelIndex, ETKernelKey +try: + from executorch.codegen.model import ETKernelIndex, ETKernelKey +except ImportError: + # If we build from source, executorch.codegen is not available. + # We can use relative import instead. + from .model import ETKernelIndex, ETKernelKey # type: ignore[assignment] from torchgen.gen import LineLoader, parse_native_yaml from torchgen.model import ( BackendMetadata, diff --git a/codegen/tools/gen_oplist.py b/codegen/tools/gen_oplist.py index dc591defda8..b1f4af02889 100644 --- a/codegen/tools/gen_oplist.py +++ b/codegen/tools/gen_oplist.py @@ -12,7 +12,13 @@ from typing import Any, Dict, List, Optional, Set import yaml -from torchgen.executorch.parse import strip_et_fields + +try: + from executorch.codegen.parse import strip_et_fields +except ImportError: + # If we build from source, executorch.codegen is not available. + # We can use relative import instead. + from ..parse import strip_et_fields from torchgen.gen import LineLoader, parse_native_yaml_struct from torchgen.selective_build.operator import SelectiveBuildOperator diff --git a/codegen/tools/targets.bzl b/codegen/tools/targets.bzl index c37c77459df..bf298a76d44 100644 --- a/codegen/tools/targets.bzl +++ b/codegen/tools/targets.bzl @@ -15,8 +15,9 @@ def define_common_targets(is_fbcode = False): visibility = [ "//executorch/...", ], - external_deps = ["torchgen"], - deps = select({ + deps = [ + "//executorch/codegen:gen_lib", + ] + select({ "DEFAULT": [], "ovr_config//os:linux": [] if runtime.is_oss else ["//executorch/codegen/tools/fb:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet }), diff --git a/install_requirements.py b/install_requirements.py index 4c468b979d1..567dca4ebf1 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -71,7 +71,7 @@ def python_is_compatible(): # # NOTE: If you're changing, make the corresponding change in .ci/docker/ci_commit_pins/pytorch.txt # by picking the hash from the same date in https://hud.pytorch.org/hud/pytorch/pytorch/nightly/ -NIGHTLY_VERSION = "dev20250325" +NIGHTLY_VERSION = "dev20250524" def install_requirements(use_pytorch_nightly):