Skip to content

Commit e642591

Browse files
committed
Update on "[BE] Remind users to update submodule"
Summary: Fixing #7243 As titled. This PR adds 2 things: 1. `check_and_update_submodule()` check if required submodule folders exist and at least contains a CMakeLists.txt file. 2. Give useful error when the submodule is corrupted (most likely missing a file, caused by submodule out of sync). Test Plan: 1. Test if we can still install, if submodule is not updated ``` rm -rf third-party/prelude ./install_executorch.sh ``` See the following log ``` ... Processing /data/users/larryliu/executorch Preparing metadata (pyproject.toml): started Running command Preparing metadata (pyproject.toml) 2025-02-05 11:28:46,430 [ExecuTorch] WARNING: Some required submodules are missing. Updating submodules... Submodule path 'third-party/prelude': checked out '851d3f09c452937fc5adef27e2c50f7f304f1646' 2025-02-05 11:28:46,748 [ExecuTorch] INFO: All required submodules are present. 2025-02-05 11:28:47,018 [ExecuTorch] INFO: running dist_info ... ``` This proves that we can update submodule for the user. 2. Test if we can give useful error message, if we are missing a file. ``` rm third-party/gflags/src/gflags.cc ./install_executorch.sh --clean ./install_executorch.sh ``` See the following error: ``` 2025-02-05 12:08:56,889 [ExecuTorch] ERROR: Failed to query buck for sources. Failed command: buck2 cquery inputs(deps('//runtime/executor:program')) This is likely due to missing git submodules or outdated CMake cache. Please run the following before retry: ./install_executorch.sh --clean git submodule update --init --recursive ``` Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D69156975](https://our.internmc.facebook.com/intern/diff/D69156975) [ghstack-poisoned]
1 parent 117ae6e commit e642591

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import subprocess
6060

6161
from distutils import log
62-
from distutils.errors import DistutilsExecError
6362
from distutils.sysconfig import get_python_lib
6463
from pathlib import Path
6564
from typing import List, Optional
@@ -140,9 +139,8 @@ def check_folder(folder: str, file: str) -> bool:
140139
if missing_submodules:
141140
logger.warning("Some required submodules are missing. Updating submodules...")
142141
try:
143-
subprocess.check_call(
144-
["git", "submodule", "update", "--init", "--recursive"]
145-
)
142+
subprocess.check_call(["git", "submodule", "sync"])
143+
subprocess.check_call(["git", "submodule", "update", "--init"])
146144
except subprocess.CalledProcessError as e:
147145
logger.error(f"Error updating submodules: {e}")
148146
exit(1)
@@ -151,7 +149,7 @@ def check_folder(folder: str, file: str) -> bool:
151149
for path, file in missing_submodules.items():
152150
if not check_folder(path, file):
153151
logger.error(f"{file} not found in {path}.")
154-
logger.error("Please run `git submodule update --init --recursive`.")
152+
logger.error("Please run `git submodule update --init`.")
155153
exit(1)
156154
logger.info("All required submodules are present.")
157155

0 commit comments

Comments
 (0)