From ca31e4cddfcaf4ee573ff1652cd14bbbd76b269d Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Fri, 7 Nov 2025 13:28:25 -0800 Subject: [PATCH 1/2] Fix windows build cannot find versions.py When I install executorch on windows I run into this error: error: [Errno 2] No such file or directory: 'pip-out\\lib.win-amd64-cpython-312\\executorch\\version.py' It turns out sometimes the dst directory (in this case pip-out\lib.win-amd64-cpython-312\executorch) is not installed before we write version.py into it. This PR adds a mkpath call to make sure it's always there. --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 45b69b8b828..62eed183cae 100644 --- a/setup.py +++ b/setup.py @@ -635,6 +635,9 @@ def run(self): dst_root = self.get_package_dir(".") else: dst_root = os.path.join(self.build_lib, "executorch") + # On Windows the package directory might not exist yet when building from a + # clean tree. Ensure it is created before we attempt to write version.py. + self.mkpath(dst_root) # Create the version file. Version.write_to_python_file(os.path.join(dst_root, "version.py")) From 2ebc280333e26bf4a2eeb377f63c6f9c60e1ae1f Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Fri, 7 Nov 2025 14:53:37 -0800 Subject: [PATCH 2/2] Exit if symlink is not enabled on Windows --- install_executorch.bat | 18 +++++++++++++++++- setup.py | 3 --- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/install_executorch.bat b/install_executorch.bat index e6d5c5db363..50fb6fd9b77 100644 --- a/install_executorch.bat +++ b/install_executorch.bat @@ -1,4 +1,5 @@ @ECHO OFF +setlocal EnableDelayedExpansion rem Copyright (c) Meta Platforms, Inc. and affiliates. rem All rights reserved. @@ -7,9 +8,24 @@ rem This batch file provides a basic functionality similar to the bash script. cd /d "%~dp0" +rem Verify that Git checked out symlinks correctly. Without this the Python install +rem will fail when attempting to copy files from src\executorch. +where git >NUL 2>&1 +if not errorlevel 1 ( + set "GIT_SYMLINKS=" + for /f "usebackq delims=" %%i in (`git config --get core.symlinks 2^>nul`) do set "GIT_SYMLINKS=%%i" + if /I not "!GIT_SYMLINKS!"=="true" ( + echo ExecuTorch requires Git symlink support on Windows. + echo Enable Developer Mode and run: git config --global core.symlinks true + echo Re-clone the repository after enabling symlinks, then rerun install_executorch.bat. + exit /b 1 + ) +) + rem Under windows, it's always python set PYTHON_EXECUTABLE=python "%PYTHON_EXECUTABLE%" install_executorch.py %* -exit /b %ERRORLEVEL% +set "EXIT_CODE=%ERRORLEVEL%" +endlocal & exit /b %EXIT_CODE% diff --git a/setup.py b/setup.py index 62eed183cae..45b69b8b828 100644 --- a/setup.py +++ b/setup.py @@ -635,9 +635,6 @@ def run(self): dst_root = self.get_package_dir(".") else: dst_root = os.path.join(self.build_lib, "executorch") - # On Windows the package directory might not exist yet when building from a - # clean tree. Ensure it is created before we attempt to write version.py. - self.mkpath(dst_root) # Create the version file. Version.write_to_python_file(os.path.join(dst_root, "version.py"))