diff --git a/setup.py b/setup.py index 41170f09c9..dc61b1cc5d 100644 --- a/setup.py +++ b/setup.py @@ -216,8 +216,13 @@ def src_path(self, installer: "InstallerBuildExt") -> Path: file. """ # Share the cmake-out location with CustomBuild. - cmake_cache_dir = Path(installer.get_finalized_command("build").cmake_cache_dir) - + build_cmd = installer.get_finalized_command("build") + if hasattr(build_cmd, "cmake_cache_dir"): + cmake_cache_dir = Path(build_cmd.cmake_cache_dir) + else: + # If we're in editable mode, use a default or fallback value for cmake_cache_dir + # This could be a hardcoded path, or a path derived from the current working directory + cmake_cache_dir = Path(".") cfg = get_build_type(installer.debug) if os.name == "nt": @@ -232,7 +237,14 @@ def src_path(self, installer: "InstallerBuildExt") -> Path: srcs = tuple(cmake_cache_dir.glob(self.src)) if len(srcs) != 1: raise ValueError( - f"Expected exactly one file matching '{self.src}'; found {repr(srcs)}" + f"""Expected exactly one file matching '{self.src}'; found {repr(srcs)}. + +If that file is a CMake-built extension module file, and we are installing in editable mode, please disable the corresponding build option since it's not supported yet. + +Try: + +EXECUTORCH_BUILD_FLATC=OFF EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT=OFF pip install -e . +""" ) return srcs[0] @@ -401,7 +413,11 @@ def run(self): # package, and will look like `pip-out/lib`. It can contain multiple # python packages, so be sure to copy the files into the `executorch` # package subdirectory. - dst_root = os.path.join(self.build_lib, self.get_package_dir("executorch")) + if self.editable_mode: + # In editable mode, the package directory is the original source directory + dst_root = self.get_package_dir(".") + else: + dst_root = os.path.join(self.build_lib, self.get_package_dir("executorch")) # Create the version file. Version.write_to_python_file(os.path.join(dst_root, "version.py"))