Skip to content

Commit 9dd3e78

Browse files
authored
Improve error handling on python build batch script (#43640)
### What does this PR do? It makes sure the clean up after the python build on Windows executes even when errors occur. ### Motivation Cleanup I had taken note for after #42848. ### Describe how you validated your changes ### Additional Notes Co-authored-by: alex.lopez <[email protected]>
1 parent 2dbf3e8 commit 9dd3e78

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/MODULE.bazel* @DataDog/agent-build
3030
# Temporary during Bazel migration
3131
/**/BUILD.bazel @DataDog/agent-build
32+
/deps/ @DataDog/agent-build
3233

3334
# The owner should really be to a team that does not exist yet. It would cover supply chain in general.
3435
# For now, agent-build are the experts in that.

deps/cpython/build_python.bat

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ for %%F in (%MSBUILD%) do set MSBUILD=%%~fF
66

77
set build_outdir=%sourcedir%\PCbuild\amd64
88

9+
set script_errorlevel=0
10+
911
:: Start from a clean state
1012
%MSBUILD% "%sourcedir%\PCbuild\pcbuild.proj" /t:CleanAll
1113
rmdir /q /s %build_outdir%
@@ -51,7 +53,10 @@ echo "/p:SkipCopySSLDLL=1" >> %response_file%
5153
:: won't be built.
5254
call %sourcedir%\PCbuild\build.bat -e --pgo
5355

54-
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
56+
if %errorlevel% neq 0 (
57+
set script_errorlevel=%errorlevel%
58+
goto :cleanup
59+
)
5560

5661
@echo on
5762

@@ -70,15 +75,28 @@ xcopy /f %OPENSSL_DIR%*.dll %build_outdir%\
7075
:: --include-stable - adds python3.dll
7176
%build_outdir%\python.exe %sourcedir%PC\layout\main.py --build %build_outdir% --precompile --copy %destdir% --include-dev --include-venv --include-stable -vv
7277

73-
if ERRORLEVEL 1 exit /b %ERRORLEVEL%
78+
if %errorlevel% neq 0 (
79+
set script_errorlevel=%errorlevel%
80+
goto :cleanup
81+
)
7482

7583
:: Bootstrap pip
7684
%destdir%\python.exe -m ensurepip
7785

86+
if %errorlevel% neq 0 (
87+
set script_errorlevel=%errorlevel%
88+
goto :cleanup
89+
)
90+
91+
:cleanup
7892
:: Clean so that no artifacts produced by the build remain
7993
%MSBUILD% "%sourcedir%\PCbuild\pcbuild.proj" /t:CleanAll
8094
rmdir /q /s %build_outdir%
8195
rmdir /q /s %sourcedir%\PCbuild\obj
8296
rmdir /q /s %sourcedir%\PCbuild\win32
8397
del /q %response_file%
8498
del /q %sourcedir%\python.bat
99+
100+
if %script_errorlevel% neq 0 (
101+
exit /b %script_errorlevel%
102+
)

0 commit comments

Comments
 (0)