From d0ebdc68828fd6e7e277e0db2de1c353dd60f6a7 Mon Sep 17 00:00:00 2001 From: Dimiter 'malkia' Stanev Date: Mon, 18 Dec 2023 13:08:16 -0800 Subject: [PATCH] No longer hard-code python3.12 path, rather find it, and then make custom PATH with only System32/Python folders. Deal with spaces in names too --- otel_sdk_build.cmd | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/otel_sdk_build.cmd b/otel_sdk_build.cmd index 4463cfeef5..2a0f499c5a 100644 --- a/otel_sdk_build.cmd +++ b/otel_sdk_build.cmd @@ -5,11 +5,17 @@ set BAZEL_SH= set BAZEL_VC= set BAZEL_VC_FULL_VERSION= +for /F "delims=" %%i in ("%ComSpec%") do set __COMSPEC_DIR__=%%~dpi +if "%__COMSPEC_DIR__%"=="" goto:no-comspec + +for /F "usebackq delims=" %%i in (`where python`) do set __PYTHON_DIR__=%%~dpi +if "%__PYTHON_DIR__%"=="" goto:no-python + rem Look first for bazelisk, then bazel -for /F "usebackq" %%i in (`where bazelisk bazel`) do set __BAZEL__=%%i +for /F "usebackq delims=" %%i in (`where bazelisk bazel`) do set __BAZEL__=%%i if "%__BAZEL__%"=="" goto:no-bazel -set PATH=c:\windows\system32;c:\program files\python312 +set PATH=%__COMSPEC_DIR__%;%__PYTHON_DIR__% pushd "%~dp0" "%__BAZEL__%" build -k --//:with_dll=true ... @@ -36,7 +42,15 @@ endlocal goto:eof :no-bazel -echo FAILED: No bazel.exe found! +echo FAILED: No bazelisk or bazel found! +goto:eof + +:no-python +echo FAILED: No python found! +goto:eof + +:no-comspec +echo FAILED: No ComSpec env var set! goto:eof :error