From 0e8b3107e056f22f04ed82d6906560e7dd83baae Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Tue, 9 Mar 2021 21:53:47 +0000 Subject: [PATCH] Remove py batch wrappers from root dir This removes python.bat and python3.bat batch wrappers from root of this repository. This change brings Windows set up closer to unix. depot_tools provides batch wrappers in python-bin and python2-bin directories and user can opt in to use it by adding them to PATH. Bug: 777069 Change-Id: Ie7571a49f940e7a69b6c18779499c39aee94d06a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2742181 Reviewed-by: Edward Lesmes Reviewed-by: Dirk Pranke Commit-Queue: Josip Sokcevic --- bootstrap/bootstrap.py | 13 ++++++++----- git-runhooks | 2 +- vpython.bat | 7 ++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 39665881a..6f602058e 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -228,15 +228,20 @@ def clean_up_old_installations(skip_dir): that is using the bootstrapped Python! """ root_contents = os.listdir(ROOT_DIR) - for f in ('win_tools-*_bin', 'python27*_bin', 'git-*_bin', 'bootstrap-*_bin'): + cleanup_paths = ('win_tools-*_bin', 'python27*_bin', 'git-*_bin', + 'bootstrap-*_bin', 'python.bat', 'python3.bat') + for f in cleanup_paths: for entry in fnmatch.filter(root_contents, f): full_entry = os.path.join(ROOT_DIR, entry) - if full_entry == skip_dir or not os.path.isdir(full_entry): + if full_entry == skip_dir: continue logging.info('Cleaning up old installation %r', entry) if not _toolchain_in_use(full_entry): - _safe_rmtree(full_entry) + if os.path.isdir(full_entry): + _safe_rmtree(full_entry) + else: + os.remove(full_entry) else: logging.info('Toolchain at %r is in-use; skipping', full_entry) @@ -321,8 +326,6 @@ def main(argv): git_postprocess(template, os.path.join(bootstrap_dir, 'git')) templates = [ ('git-bash.template.sh', 'git-bash', ROOT_DIR), - ('python27.bat', 'python.bat', ROOT_DIR), - ('python3.bat', 'python3.bat', ROOT_DIR), ] for src_name, dst_name, dst_dir in templates: # Re-evaluate and regenerate our root templated files. diff --git a/git-runhooks b/git-runhooks index 5bb503e51..e487447d6 100755 --- a/git-runhooks +++ b/git-runhooks @@ -15,7 +15,7 @@ gclient_spec="solutions=[{'name':'src','url':None,'deps_file':'.DEPS.git'}]" kernel_name=$(uname -s) if [ "${kernel_name:0:5}" = "MINGW" ]; then dir="${0%\\*}" - cmd "/C ${dir}\\python.bat ${dir}\\gclient.py runhooks --spec=$gclient_spec" + cmd "/C ${dir}\\python2-bin\\python.bat ${dir}\\gclient.py runhooks --spec=$gclient_spec" else dir="$(dirname $0)" PYTHONDONTWRITEBYTECODE=1 exec python "$dir/gclient.py" runhooks --spec="$gclient_spec" diff --git a/vpython.bat b/vpython.bat index ca5fe39ba..a5c7d6374 100644 --- a/vpython.bat +++ b/vpython.bat @@ -3,5 +3,10 @@ :: Use of this source code is governed by a BSD-style license that can be :: found in the LICENSE file. +:: TODO(crbug.com/1003139): Remove. +:: Add Python 3 to PATH to work around crbug.com/1003139. +for /f %%i in (%~dp0python_bin_reldir.txt) do set PYTHON2_BIN_RELDIR=%%i +set PATH=%~dp0%PYTHON2_BIN_RELDIR%;%~dp0%PYTHON2_BIN_RELDIR%\Scripts;%~dp0%PYTHON2_BIN_RELDIR%\DLLs;%PATH% + call "%~dp0\cipd_bin_setup.bat" > nul 2>&1 -"%~dp0\.cipd_bin\vpython.exe" -vpython-interpreter "%~dp0\python.bat" %* +"%~dp0\.cipd_bin\vpython.exe" -vpython-interpreter "%~dp0\%PYTHON2_BIN_RELDIR%\python.exe" %*