blob: 6412fe464a77bf2f705358793f65a7ce33c027c3 [file] [log] [blame]
Edward Lemura44d67c2019-08-20 00:52:42 +00001@echo off
2:: Copyright 2017 The Chromium Authors. All rights reserved.
3:: Use of this source code is governed by a BSD-style license that can be
4:: found in the LICENSE file.
5
6setlocal
7set PYTHON_BAT_RUNNER=1
8
9::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
10::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
11::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
12::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
13::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
14
15:: This file is automatically generated by "bootstrap\win\win_tools.py", and
16:: should not be modified.
17::
18:: The previous "::" block acts as a nop-sled. Each time a batch file executes
19:: a command, it reloads itself and seeks to its previous execution offset to
20:: begin execution. Updating this batch file is, therefore, risky, since any
21:: running Python instance that is using the old batch file will reload the new
22:: batch file once the Python command terminates and resume at some unknown
23:: offset.
24::
25:: With the sled in place, a previous instance will resume mid-label. We are
26:: assuming that the offset of the Python invocation is greater than the
27:: PYTHON_BAT_RUNNER set command, which is the case since the old instance has
28:: a large PATH set block before the Python execution. Old instances will hit
29:: the next block of code without PYTHON_BAT_RUNNER set. New instances will have
30:: it set.
31::
32:: We remedy this in the future by having the batch file load its core paths
33:: from an external file with for/set, removing the need to modify "python.bat"
34:: during upgrade.
35::
36:: After all of the old batch files are believed to be replaced, we can remove
37:: the PYTHON_BAT_RUNNER block and the sled. For this update, old instances
38:: will resume past the end of the file and terminate.
39
40if not "%PYTHON_BAT_RUNNER%" == "1" goto :END
41
42for /f %%i in (%~dp0python3_bin_reldir.txt) do set PYTHON3_BIN_RELDIR=%%i
43set PATH=%~dp0%PYTHON3_BIN_RELDIR%;%~dp0%PYTHON3_BIN_RELDIR%\Scripts;%PATH%
44"%~dp0%PYTHON3_BIN_RELDIR%\python3.exe" %*
45
46:END