From 03bea53b4a21fee808a1e6f5b99990874c736bba Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Thu, 22 Aug 2024 23:23:29 -0400 Subject: [PATCH] [Build] Add install_requirements.bat for windows build Add install_requirements.bat on windows like install_requirements.sh. Also force use ClangCL on windows in install_requirements.py. For #4661 --- install_requirements.bat | 21 +++++++++++++++++++++ install_requirements.py | 6 ++++++ 2 files changed, 27 insertions(+) create mode 100644 install_requirements.bat diff --git a/install_requirements.bat b/install_requirements.bat new file mode 100644 index 0000000000..4cfe4b21c4 --- /dev/null +++ b/install_requirements.bat @@ -0,0 +1,21 @@ +@ECHO OFF + +rem Copyright (c) Meta Platforms, Inc. and affiliates. +rem All rights reserved. + +rem This batch file provides a basic functionality similar to the bash script. + +cd /d "%~dp0" + +rem Find the names of the python tools to use (replace with your actual python installation) +if "%PYTHON_EXECUTABLE%"=="" ( + if "%CONDA_DEFAULT_ENV%"=="" OR "%CONDA_DEFAULT_ENV%"=="base" OR NOT EXIST "python" ( + set PYTHON_EXECUTABLE=python3 + ) else ( + set PYTHON_EXECUTABLE=python + ) +) + +"%PYTHON_EXECUTABLE%" install_requirements.py %* + +exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/install_requirements.py b/install_requirements.py index c61bdd02db..1f17884f21 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -83,6 +83,12 @@ def python_is_compatible(): print(f"Error: Unknown option {arg}") sys.exit(1) +# Use ClangCL on Windows. +# ClangCL is an alias to Clang that configures it to work in an MSVC-compatible +# mode. Using it on Windows to avoid compiler compatibility issues for MSVC. +if os.name == "nt": + CMAKE_ARGS += " -T ClangCL" + # Since ExecuTorch often uses main-branch features of pytorch, only the nightly # pip versions will have the required features. #