Commit bc93924b authored by Darshan Sen's avatar Darshan Sen Committed by LUCI CQ

Add VPYTHON_BYPASS support for vpython on Windows

At Postman, we use a custom build of Electron which is built using a set
of tools that are managed by us. Till now, we were using the
VPYTHON_BYPASS environment variable to use our own managed version of
Python on macOS but unfortunately, on Windows, depot_tools doesn't
respect the value of this variable, so this change adds support for that
on Windows too.
Signed-off-by: 's avatarDarshan Sen <raisinten@gmail.com>
Change-Id: I63da0495463ace87d34c3c6fad1c03dee108d14b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3525642Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 76979dae
......@@ -5,5 +5,49 @@
:: See revert instructions in cipd_manifest.txt
:: Note: we set EnableDelayedExpansion so we can perform string manipulations
:: in our arguments parsing loop. This only works on Windows XP+.
setlocal EnableDelayedExpansion
if "%VPYTHON_BYPASS%"=="manually managed python not supported by chrome operations" (
set "arguments="
set "ignore="
set "stop="
for %%x in (%*) do (
set "arg=%%x"
if defined stop (
set "arguments=!arguments! %%~x"
) else (
if "!arg!"=="--" (
set "stop=1"
) else (
:: These tools all do something vpython related and quit
if "!arg:~0,13!"=="-vpython-tool" (
goto :END
)
:: Delete any vpython specific flag
if "!arg:~0,8!"=="-vpython" (
set "ignore=1"
) else (
if defined ignore (
set "ignore="
) else (
set "arguments=!arguments! %%~x"
)
)
)
)
)
call "python" !arguments!
if errorlevel 1 goto :END
)
call "%~dp0\cipd_bin_setup.bat" > nul 2>&1
"%~dp0\.cipd_bin\vpython.exe" -vpython-interpreter "%~dp0\python.bat" %*
:END
endlocal
exit /b %ERRORLEVEL%
......@@ -3,6 +3,46 @@
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
:: Note: we set EnableDelayedExpansion so we can perform string manipulations
:: in our arguments parsing loop. This only works on Windows XP+.
setlocal EnableDelayedExpansion
if "%VPYTHON_BYPASS%"=="manually managed python not supported by chrome operations" (
set "arguments="
set "ignore="
set "stop="
for %%x in (%*) do (
set "arg=%%x"
if defined stop (
set "arguments=!arguments! %%~x"
) else (
if "!arg!"=="--" (
set "stop=1"
) else (
:: These tools all do something vpython related and quit
if "!arg:~0,13!"=="-vpython-tool" (
goto :END
)
:: Delete any vpython specific flag
if "!arg:~0,8!"=="-vpython" (
set "ignore=1"
) else (
if defined ignore (
set "ignore="
) else (
set "arguments=!arguments! %%~x"
)
)
)
)
)
call "python3" !arguments!
if errorlevel 1 goto :END
)
:: TODO(crbug.com/1003139): Remove.
:: Add Python 3 to PATH to work around crbug.com/1003139.
for /f %%i in (%~dp0python3_bin_reldir.txt) do set PYTHON3_BIN_RELDIR=%%i
......@@ -10,3 +50,7 @@ set PATH=%~dp0%PYTHON3_BIN_RELDIR%;%~dp0%PYTHON3_BIN_RELDIR%\Scripts;%~dp0%PYTHO
call "%~dp0\cipd_bin_setup.bat" > nul 2>&1
"%~dp0\.cipd_bin\vpython3.exe" -vpython-interpreter "%~dp0\%PYTHON3_BIN_RELDIR%\python3.exe" %*
:END
endlocal
exit /b %ERRORLEVEL%
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment