From 63e2a7dd2e504f4b95ba0000910915c013d2dcd9 Mon Sep 17 00:00:00 2001 From: Sing_chan <51314274+betterpig@users.noreply.github.com> Date: Mon, 20 Jun 2022 11:40:00 +0800 Subject: [PATCH] make paddle build and unit test in python virtual environment. (#43620) --- paddle/scripts/paddle_build.bat | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/paddle/scripts/paddle_build.bat b/paddle/scripts/paddle_build.bat index f5381937821..d87915d172b 100644 --- a/paddle/scripts/paddle_build.bat +++ b/paddle/scripts/paddle_build.bat @@ -92,15 +92,18 @@ rem ------initialize set git config------ git config --global core.longpaths true rem ------initialize the python environment------ -set PYTHON_EXECUTABLE=%PYTHON_ROOT%\python.exe -set PATH=%PYTHON_ROOT%\Scripts;%PYTHON_ROOT%;%PATH% +set PYTHON_VENV_ROOT=%cache_dir%\python_venv +set PYTHON_EXECUTABLE=!PYTHON_VENV_ROOT!\Scripts\python.exe +%PYTHON_ROOT%\python.exe -m venv --clear !PYTHON_VENV_ROOT! +call !PYTHON_VENV_ROOT!\Scripts\activate.bat + if "%WITH_PYTHON%" == "ON" ( where python where pip - pip install wheel --user - pip install pyyaml --user - pip install wget --user - pip install -r %work_dir%\python\requirements.txt --user + pip install wheel + pip install pyyaml + pip install wget + pip install -r %work_dir%\python\requirements.txt if !ERRORLEVEL! NEQ 0 ( echo pip install requirements.txt failed! exit /b 5 @@ -632,7 +635,7 @@ set /p PADDLE_WHL_FILE_WIN=< whl_file.txt @ECHO ON pip uninstall -y paddlepaddle pip uninstall -y paddlepaddle-gpu -pip install %PADDLE_WHL_FILE_WIN% --user +pip install %PADDLE_WHL_FILE_WIN% if %ERRORLEVEL% NEQ 0 ( call paddle_winci\Scripts\deactivate.bat 2>NUL echo pip install whl package failed! @@ -659,7 +662,7 @@ echo ======================================== : set CI_SKIP_CPP_TEST if only *.py changed git diff --name-only %BRANCH% | findstr /V "\.py" || set CI_SKIP_CPP_TEST=ON -pip install -r %work_dir%\python\unittest_py\requirements.txt --user +pip install -r %work_dir%\python\unittest_py\requirements.txt if %ERRORLEVEL% NEQ 0 ( echo pip install unittest requirements.txt failed! exit /b 5 -- GitLab