mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Remove python2 from bootstrap
With this change, python2[.bat] will no longer be available in depot_tools root. vpython continues to work. Bug: 1376538 Change-Id: Iabe22e4e33d0d79d258068c90128da8de4d3ece1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5170265 Reviewed-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Brian Ryner <bryner@google.com> Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
This commit is contained in:
@@ -12,7 +12,7 @@ ommodate this, and Python cleanup, we handle Python in two stages:
|
||||
fix-ups.
|
||||
|
||||
## Software bootstrapped
|
||||
* Python 2 and 3 (https://www.python.org/)
|
||||
* Python 3 (https://www.python.org/)
|
||||
* Git for Windows (https://git-for-windows.github.io/)
|
||||
|
||||
## Mechanism
|
||||
@@ -60,11 +60,11 @@ than the rest of this README.
|
||||
After any modification to this script set, a test sequence should be run on a
|
||||
Windows bot.
|
||||
|
||||
The post-processing will regenerate "python.bat" and "python3.bat" to point to
|
||||
the current Python instance. Any previous Python installations will stick
|
||||
around, but new invocations will use the new instance. Old installations will
|
||||
die off either due to processes terminating or systems restarting. When this
|
||||
happens, they will be cleaned up by the post-processing script.
|
||||
The post-processing will regenerate "python3.bat" to point to the current Python
|
||||
instance. Any previous Python installations will stick around, but new
|
||||
invocations will use the new instance. Old installations will die off either due
|
||||
to processes terminating or systems restarting. When this happens, they will be
|
||||
cleaned up by the post-processing script.
|
||||
|
||||
Testing
|
||||
=======
|
||||
@@ -76,9 +76,6 @@ they are working:
|
||||
:: Assert that `gclient` invocation will update (and do the update).
|
||||
gclient version
|
||||
|
||||
:: Assert that Python fundamentally works.
|
||||
python -c "import Queue; print dir(Queue)"
|
||||
|
||||
:: Assert that Python 3 fundamentally works.
|
||||
python3 -c "import queue; print(dir(queue))"
|
||||
|
||||
@@ -88,8 +85,6 @@ git map-branches
|
||||
:: Assert that `git bash` works.
|
||||
git bash
|
||||
|
||||
## (Within `git bash`) assert that Python fundamentally works.
|
||||
python -c "import Queue; print dir(Queue)"
|
||||
## (Within `git bash`) assert that Python 3 fundamentally works.
|
||||
python3 -c "import queue; print(dir(queue))"
|
||||
## (Within `git bash`) assert that Python scripts work.
|
||||
@@ -102,12 +97,9 @@ Run this sequence through the following upgrade/downgrade procedures:
|
||||
- Clean `depot_tools` via: `git clean -x -f -d .`
|
||||
- Run through test steps.
|
||||
- Test upgrade to bleeding edge (if it differs).
|
||||
- Run `python.bat` in another shell, keep it open
|
||||
- Run `python3.bat` in another shell, keep it open
|
||||
- Add `.bleeding_edge` to `depot_tools` root.
|
||||
- Run through test steps.
|
||||
- In the old `python.bat` shell, run `import Queue`, confirm that it
|
||||
works.
|
||||
- In the old `python3.bat` shell, run `import queue`, confirm that it
|
||||
works.
|
||||
- Close the Python shell, run `gclient version`, ensure that old directory
|
||||
@@ -117,12 +109,9 @@ Run this sequence through the following upgrade/downgrade procedures:
|
||||
- Add `.bleeding_edge` to `depot_tools` root.
|
||||
- Run through test steps.
|
||||
- Test downgrade to default (if it differs).
|
||||
- Run `python.bat` in another shell, keep it open
|
||||
- Run `python3.bat` in another shell, keep it open
|
||||
- Delete `.bleeding_edge` from `depot_tools` root.
|
||||
- Run through test steps.
|
||||
- In the old `python.bat` shell, run `import Queue`, confirm that it
|
||||
works.
|
||||
- In the old `python3.bat` shell, run `import queue`, confirm that it
|
||||
works.
|
||||
- Close the Python shell, run `gclient version`, ensure that old directory
|
||||
@@ -130,12 +119,9 @@ Run this sequence through the following upgrade/downgrade procedures:
|
||||
* Warm bleeding edge upgrade.
|
||||
- Clean `depot_tools` via: `git clean -x -f -d .`
|
||||
- Run `gclient version` to load defaults.
|
||||
- Run `python.bat` in another shell, keep it open
|
||||
- Run `python3.bat` in another shell, keep it open
|
||||
- Add `.bleeding_edge` to `depot_tools` root.
|
||||
- Run through test steps.
|
||||
- In the old `python.bat` shell, run `import Queue`, confirm that it
|
||||
works.
|
||||
- In the old `python3.bat` shell, run `import queue`, confirm that it
|
||||
works.
|
||||
- Close the Python shell, run `gclient version`, ensure that old directory is
|
||||
|
||||
@@ -38,9 +38,6 @@ WIN_GIT_STUBS = {
|
||||
# Accumulated template parameters for generated stubs.
|
||||
class Template(
|
||||
collections.namedtuple('Template', (
|
||||
'PYTHON_RELDIR',
|
||||
'PYTHON_BIN_RELDIR',
|
||||
'PYTHON_BIN_RELDIR_UNIX',
|
||||
'PYTHON3_BIN_RELDIR',
|
||||
'PYTHON3_BIN_RELDIR_UNIX',
|
||||
'GIT_BIN_RELDIR',
|
||||
@@ -307,10 +304,6 @@ def main(argv):
|
||||
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.WARN)
|
||||
|
||||
template = Template.empty()._replace(
|
||||
PYTHON_RELDIR=os.path.join(args.bootstrap_name, 'python'),
|
||||
PYTHON_BIN_RELDIR=os.path.join(args.bootstrap_name, 'python', 'bin'),
|
||||
PYTHON_BIN_RELDIR_UNIX=posixpath.join(args.bootstrap_name, 'python',
|
||||
'bin'),
|
||||
PYTHON3_BIN_RELDIR=os.path.join(args.bootstrap_name, 'python3', 'bin'),
|
||||
PYTHON3_BIN_RELDIR_UNIX=posixpath.join(args.bootstrap_name, 'python3',
|
||||
'bin'),
|
||||
@@ -326,7 +319,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:
|
||||
@@ -334,8 +326,7 @@ def main(argv):
|
||||
template.maybe_install(src_name, os.path.join(dst_dir, dst_name))
|
||||
|
||||
# Emit our Python bin depot-tools-relative directory. This is read by
|
||||
# python.bat, python3.bat, vpython[.bat] and vpython3[.bat] to identify the
|
||||
# path of the current Python installation.
|
||||
# python3.bat to identify the path of the current Python installation.
|
||||
#
|
||||
# We use this indirection so that upgrades can change this pointer to
|
||||
# redirect "python.bat" to a new Python installation. We can't just update
|
||||
@@ -346,9 +337,6 @@ def main(argv):
|
||||
# The intention is that the batch file itself never needs to change when
|
||||
# switching Python versions.
|
||||
|
||||
maybe_update(template.PYTHON_BIN_RELDIR,
|
||||
os.path.join(ROOT_DIR, 'python_bin_reldir.txt'))
|
||||
|
||||
maybe_update(template.PYTHON3_BIN_RELDIR,
|
||||
os.path.join(ROOT_DIR, 'python3_bin_reldir.txt'))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
export EDITOR=${EDITOR:=notepad}
|
||||
WIN_BASE=`dirname $0`
|
||||
UNIX_BASE=`cygpath "$WIN_BASE"`
|
||||
export PATH="$PATH:$UNIX_BASE/${PYTHON_BIN_RELDIR_UNIX}:$UNIX_BASE/${PYTHON_BIN_RELDIR_UNIX}/Scripts:$UNIX_BASE/${PYTHON3_BIN_RELDIR_UNIX}:$UNIX_BASE/${PYTHON3_BIN_RELDIR_UNIX}/Scripts"
|
||||
export PATH="$PATH:$UNIX_BASE/${PYTHON3_BIN_RELDIR_UNIX}:$UNIX_BASE/${PYTHON3_BIN_RELDIR_UNIX}/Scripts"
|
||||
export PYTHON_DIRECT=1
|
||||
export PYTHONUNBUFFERED=1
|
||||
if [[ $# > 0 ]]; then
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# "win_tools.bat", "bootstrap.py" and "../bootstrap_python3" templates.
|
||||
#
|
||||
# "win_tools.bat" has a hard requirement that the Python packages contain the
|
||||
# strings "cpython/" for Python 2 and "cpython3/" for Python 3, and ends with
|
||||
# the CIPD tag "version:VERSION". It uses this to extract VERSION.
|
||||
# string "cpython3/" for Python 3, and ends with the CIPD tag "version:VERSION".
|
||||
# It uses this to extract VERSION.
|
||||
#
|
||||
# "bootstrap_python3" has a hard requirement that the Python package contains
|
||||
# the string "cpython3/" and ends with the CIPD tag "version:VERSION".
|
||||
@@ -17,9 +17,6 @@
|
||||
|
||||
$VerifiedPlatform windows-amd64 windows-arm64 linux-amd64 mac-amd64 mac-arm64
|
||||
|
||||
@Subdir python
|
||||
infra/3pp/tools/cpython/${platform} version:2@2.7.18.chromium.44
|
||||
|
||||
@Subdir python3
|
||||
infra/3pp/tools/cpython3/${platform} version:2@3.8.10.chromium.26
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# "win_tools.bat", "bootstrap.py" and "../bootstrap_python3" templates.
|
||||
#
|
||||
# "win_tools.bat" has a hard requirement that the Python packages contain the
|
||||
# strings "cpython/" for Python 2 and "cpython3/" for Python 3, and ends with
|
||||
# the CIPD tag "version:VERSION". It uses this to extract VERSION.
|
||||
# string "cpython3/" for Python 3, and ends with the CIPD tag "version:VERSION".
|
||||
# It uses this to extract VERSION.
|
||||
#
|
||||
# "bootstrap_python3" has a hard requirement that the Python package contains
|
||||
# the string "cpython3/" and ends with the CIPD tag "version:VERSION".
|
||||
@@ -18,9 +18,6 @@
|
||||
$VerifiedPlatform windows-386 windows-amd64 linux-amd64 mac-amd64 mac-arm64
|
||||
$VerifiedPlatform windows-arm64
|
||||
|
||||
@Subdir python
|
||||
infra/3pp/tools/cpython/${platform} version:2@2.7.18.chromium.44
|
||||
|
||||
@Subdir python3
|
||||
infra/3pp/tools/cpython3/${platform} version:2@3.11.6.chromium.30
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
@echo off
|
||||
:: Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
:: Use of this source code is governed by a BSD-style license that can be
|
||||
:: found in the LICENSE file.
|
||||
|
||||
setlocal
|
||||
set PYTHON_BAT_RUNNER=1
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
:: This file is automatically generated by "bootstrap\win\win_tools.py", and
|
||||
:: should not be modified.
|
||||
::
|
||||
:: The previous "::" block acts as a nop-sled. Each time a batch file executes
|
||||
:: a command, it reloads itself and seeks to its previous execution offset to
|
||||
:: begin execution. Updating this batch file is, therefore, risky, since any
|
||||
:: running Python instance that is using the old batch file will reload the new
|
||||
:: batch file once the Python command terminates and resume at some unknown
|
||||
:: offset.
|
||||
::
|
||||
:: With the sled in place, a previous instance will resume mid-label. We are
|
||||
:: assuming that the offset of the Python invocation is greater than the
|
||||
:: PYTHON_BAT_RUNNER set command, which is the case since the old instance has
|
||||
:: a large PATH set block before the Python execution. Old instances will hit
|
||||
:: the next block of code without PYTHON_BAT_RUNNER set. New instances will have
|
||||
:: it set.
|
||||
::
|
||||
:: We remedy this in the future by having the batch file load its core paths
|
||||
:: from an external file with for/set, removing the need to modify "python.bat"
|
||||
:: during upgrade.
|
||||
::
|
||||
:: After all of the old batch files are believed to be replaced, we can remove
|
||||
:: the PYTHON_BAT_RUNNER block and the sled. For this update, old instances
|
||||
:: will resume past the end of the file and terminate.
|
||||
|
||||
if not "%PYTHON_BAT_RUNNER%" == "1" goto :END
|
||||
|
||||
for /f %%i in (%~dp0python_bin_reldir.txt) do set PYTHON_BIN_RELDIR=%%i
|
||||
set PATH=%~dp0%PYTHON_BIN_RELDIR%;%~dp0%PYTHON_BIN_RELDIR%\Scripts;%PATH%
|
||||
"%~dp0%PYTHON_BIN_RELDIR%\python.exe" %*
|
||||
|
||||
:END
|
||||
@@ -25,8 +25,8 @@ if not exist "%BOOTSTRAP_ROOT_DIR%\.bleeding_edge" (
|
||||
set CIPD_MANIFEST=manifest_bleeding_edge.txt
|
||||
)
|
||||
|
||||
:: Parse our CIPD manifest and identify the "cpython" version. We do this by
|
||||
:: reading it line-by-line, identifying the line containing "cpython", and
|
||||
:: Parse our CIPD manifest and identify the "cpython3" version. We do this by
|
||||
:: reading it line-by-line, identifying the line containing "cpython3", and
|
||||
:: stripping all text preceding "version:". This leaves us with the version
|
||||
:: string.
|
||||
::
|
||||
@@ -35,14 +35,8 @@ if not exist "%BOOTSTRAP_ROOT_DIR%\.bleeding_edge" (
|
||||
:: delayed expansion variables.
|
||||
for /F "usebackq tokens=*" %%A in ("%~dp0%CIPD_MANIFEST%") do (
|
||||
set LINE=%%A
|
||||
if not "x!LINE:cpython/=!" == "x!LINE!" set PYTHON_VERSION=!LINE:*version:=!
|
||||
if not "x!LINE:cpython3/=!" == "x!LINE!" set PYTHON3_VERSION=!LINE:*version:=!
|
||||
)
|
||||
if "%PYTHON_VERSION%" == "" (
|
||||
@echo Could not extract Python version from manifest.
|
||||
set ERRORLEVEL=1
|
||||
goto :END
|
||||
)
|
||||
if "%PYTHON3_VERSION%" == "" (
|
||||
@echo Could not extract Python version from manifest.
|
||||
set ERRORLEVEL=1
|
||||
|
||||
Reference in New Issue
Block a user