From ca676ece13cf70798b98dddb7f9124660c6d37e4 Mon Sep 17 00:00:00 2001 From: Mohammad Hossein Namaki Date: Wed, 8 Apr 2026 16:08:06 -0700 Subject: [PATCH] fix component gov because of boost --- .../python/build/linux/restore-packages.sh | 21 +++++++++++++++++++ .../python/build/windows/restore-packages.cmd | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/language-extensions/python/build/linux/restore-packages.sh b/language-extensions/python/build/linux/restore-packages.sh index 99855c6f..1fda88c0 100644 --- a/language-extensions/python/build/linux/restore-packages.sh +++ b/language-extensions/python/build/linux/restore-packages.sh @@ -62,6 +62,27 @@ sed -i 's/using gcc[^;]*;/using gcc : foo : g++ : -fPIC ;/g' project-c cp -rf boost /usr/local/include/ +# Remove unused Boost library sources to avoid false Component Governance alerts. +# Only boost_python and boost_numpy are compiled (b2 --with-python). +# Headers under boost/ at the root are kept since they are needed at compile time. +# This runs after the build so that Jamfiles are available for b2's dependency resolution. +# +BOOST_LIBS_DIR=/usr/local/lib/boost_${BOOST_VERSION_IN_UNDERSCORE}/libs +if [ -d "${BOOST_LIBS_DIR}" ]; then + echo "-- Removing unused Boost library sources --" + pushd "${BOOST_LIBS_DIR}" + for dir in */; do + case "${dir%/}" in + python|numpy|headers) ;; + *) rm -rf "$dir" ;; + esac + done + popd + echo "-- Finished removing unused Boost library sources --" +else + echo "WARNING: Boost libs directory not found at ${BOOST_LIBS_DIR}, skipping cleanup." +fi + popd exit $? diff --git a/language-extensions/python/build/windows/restore-packages.cmd b/language-extensions/python/build/windows/restore-packages.cmd index 809b318b..a036c3b1 100644 --- a/language-extensions/python/build/windows/restore-packages.cmd +++ b/language-extensions/python/build/windows/restore-packages.cmd @@ -80,6 +80,7 @@ echo -- Finished Boost Zip extration -- Time: %time% -- REM Boost cleanup echo Delete 7z boost archive del boost_%BOOST_VERSION_IN_UNDERSCORE%.7z + echo go to dir with boost unarchived echo %cd% dir @@ -109,6 +110,26 @@ echo -- Beginning Boost build using compiled b2.exe -- Time: %time% -- b2.exe -j12 --with-python toolset=msvc-14.2 address-model=64 link=static,shared threading=multi echo -- Finished Boost build -- Time: %time% -- +REM Remove unused Boost library sources to avoid false Component Governance alerts. +REM Only boost_python and boost_numpy are compiled (b2 --with-python). +REM Headers under boost/ at the root are kept since they are needed at compile time. +REM This runs after the build so that Jamfiles are available for b2's dependency resolution. +REM +SET BOOST_LIBS_DIR=%PACKAGES_ROOT%\boost_%BOOST_VERSION_IN_UNDERSCORE%\libs +IF EXIST "%BOOST_LIBS_DIR%" ( + echo -- Removing unused Boost library sources -- Time: !time! -- + pushd "%BOOST_LIBS_DIR%" + for /d %%D in (*) do ( + if /I not "%%D"=="python" if /I not "%%D"=="numpy" if /I not "%%D"=="headers" ( + RMDIR /s /q "%%D" + ) + ) + popd + echo -- Finished removing unused Boost library sources -- Time: !time! -- +) ELSE ( + echo WARNING: Boost libs directory not found at %BOOST_LIBS_DIR%, skipping cleanup. +) + REM If building in pipeline, set the PYTHONHOME here to overwrite the existing PYTHONHOME REM if NOT "%BUILD_BUILDID%"=="" (