Skip to content

Commit

Permalink
Migrate all Python scripts to Python 3
Browse files Browse the repository at this point in the history
This migrates all checked in Python scripts to run under Python 3.x.
Python 2.7 reached end-of-life in January of 2020 and has been removed
from may OS distributions at this point.

Rolls buildroot to 607277f

Issue: flutter/flutter#83043
  • Loading branch information
cbracken committed Jun 10, 2021
1 parent c913c75 commit 14f12e8
Show file tree
Hide file tree
Showing 47 changed files with 115 additions and 96 deletions.
17 changes: 10 additions & 7 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '3ae5da28db8cb028e21150f7472d0938fba2e057',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '607277f54052acd038edb4fe4c2f57fd81d96baf',

# Fuchsia compatibility
#
Expand Down Expand Up @@ -629,12 +629,15 @@ hooks = [
'name': 'landmines',
'pattern': '.',
'action': [
'python',
'python3',
'src/build/landmines.py',
],
},
{
# Update the Windows toolchain if necessary.
# TODO(cbracken): Migrate to python3 once
# depot_tools/win_toolchain/get_toolchain_if_necessary.py
# is migrated to Python 3.
'name': 'win_toolchain',
'condition': 'download_windows_deps',
'pattern': '.',
Expand All @@ -646,7 +649,7 @@ hooks = [
'name': 'remove_stale_pyc_files',
'pattern': 'src/tools/.*\\.py',
'action': [
'python',
'python3',
'src/tools/remove_stale_pyc_files.py',
'src/tools',
],
Expand All @@ -656,7 +659,7 @@ hooks = [
'pattern': '.',
'condition': 'download_windows_deps',
'action': [
'python',
'python3',
'src/flutter/tools/dia_dll.py',
],
},
Expand All @@ -665,7 +668,7 @@ hooks = [
'pattern': '.',
'condition': 'download_linux_deps',
'action': [
'python',
'python3',
'src/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x64'],
},
Expand All @@ -674,15 +677,15 @@ hooks = [
'pattern': '.',
'condition': 'download_linux_deps',
'action': [
'python',
'python3',
'src/build/linux/sysroot_scripts/install-sysroot.py',
'--arch=arm64'],
},
{
'name': 'pub get --offline',
'pattern': '.',
'action': [
'python',
'python3',
'src/flutter/tools/pub_get_offline.py',
]
},
Expand Down
5 changes: 1 addition & 4 deletions build/copy_info_plist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
Expand All @@ -13,9 +13,6 @@
usage: copy_info_plist.py <src_path> <dest_path> --bitcode=<enable_bitcode>
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import subprocess

import sys
Expand Down
3 changes: 2 additions & 1 deletion build/dart/tools/dart_package_name.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
8 changes: 4 additions & 4 deletions build/dart/tools/dart_pkg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
Expand Down Expand Up @@ -81,7 +81,7 @@ def copy(from_root, to_root, filter_func=None):
os.makedirs(to_dir)
shutil.copy(from_path, to_path)

dirs[:] = filter(wrapped_filter, dirs)
dirs[:] = list(filter(wrapped_filter, dirs))


def copy_or_link(from_root, to_root, filter_func=None):
Expand Down Expand Up @@ -114,7 +114,7 @@ def list_files(from_root, filter_func=None):
for name in filter(wrapped_filter, files):
path = os.path.join(root, name)
file_list.append(path)
dirs[:] = filter(wrapped_filter, dirs)
dirs[:] = list(filter(wrapped_filter, dirs))
return file_list


Expand Down Expand Up @@ -142,7 +142,7 @@ def remove_broken_symlinks(root_dir):


def analyze_entrypoints(dart_sdk, package_root, entrypoints):
cmd = [ "python", DART_ANALYZE ]
cmd = [ "python3", DART_ANALYZE ]
cmd.append("--dart-sdk")
cmd.append(dart_sdk)
cmd.append("--entrypoints")
Expand Down
4 changes: 2 additions & 2 deletions build/generate_coverage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
Expand Down Expand Up @@ -75,7 +75,7 @@ def main():

RemoveIfExists(raw_profile)

print "Running test %s to gather profile." % os.path.basename(absolute_test_path)
print("Running test %s to gather profile." % os.path.basename(absolute_test_path))

subprocess.check_call([absolute_test_path], env={
"LLVM_PROFILE_FILE": raw_profile
Expand Down
5 changes: 1 addition & 4 deletions build/git_revision.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Get the Git HEAD revision of a specified Git repository."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys
import subprocess
Expand Down
3 changes: 2 additions & 1 deletion build/zip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ curl https://raw.githubusercontent.com/flutter/engine/master/ci/docker/build/eng
# cd c:/flutter/engine
# gclient sync
# cd src
# python flutter/tools/gn
# python3 flutter/tools/gn
# ninja -C out/host_debug
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,7 @@ FILE: ../../../flutter/shell/profiling/sampling_profiler_unittest.cc
FILE: ../../../flutter/shell/version/version.cc
FILE: ../../../flutter/shell/version/version.h
FILE: ../../../flutter/sky/packages/flutter_services/lib/empty.dart
FILE: ../../../flutter/sky/tools/flutter_gdb
FILE: ../../../flutter/sky/tools/roll/patches/chromium/android_build.patch
FILE: ../../../flutter/third_party/accessibility/base/color_utils.h
FILE: ../../../flutter/third_party/accessibility/base/compiler_specific.h
Expand Down
2 changes: 1 addition & 1 deletion lib/snapshot/libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Note: if you edit this file, you must also edit libraries.json in this
# directory:
#
# python third_party/dart/tools/yaml2json.py flutter/lib/snapshot/libraries.yaml flutter/lib/snapshot/libraries.json
# python3 third_party/dart/tools/yaml2json.py flutter/lib/snapshot/libraries.yaml flutter/lib/snapshot/libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See
Expand Down
3 changes: 2 additions & 1 deletion lib/spirv/test/exception_shaders/assemble.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/felt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ IF %needsHostDebugUnoptRebuild%==1 (
del %SNAPSHOT_PATH%
)
CALL gclient sync -D
CALL python %GN% --unoptimized --full-dart-sdk
CALL python3 %GN% --unoptimized --full-dart-sdk
CALL ninja -C %HOST_DEBUG_UNOPT_DIR%)

cd %WEB_UI_DIR%
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/dart_runner/kernel/libraries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Note: if you edit this file, you must also edit libraries.json in this
# directory:
#
# python third_party/dart/tools/yaml2json.py <path_to>/libraries.yaml <same_path>/libraries.json
# python3 third_party/dart/tools/yaml2json.py <path_to>/libraries.yaml <same_path>/libraries.json
#
# We currently have several different files that needs to be updated when
# changing libraries, sources, and patch files. See
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/fuchsia/flutter/build/asset_package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import argparse
import os
import re
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/create_ios_framework.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/create_macos_gen_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
7 changes: 2 additions & 5 deletions sky/tools/create_xcframework.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import errno
import os
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/dist_dart_pkg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/flutter_gdb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/install_framework_headers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/objcopy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
7 changes: 4 additions & 3 deletions sky/tools/roll/patch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down Expand Up @@ -33,10 +34,10 @@ def patch(dest_dir, relative_patches_dir=os.curdir):

os.chdir(dest_dir)
for p in utils.find(["*.patch"], patches_dir):
print "applying patch %s" % os.path.basename(p)
print("applying patch %s" % os.path.basename(p))
try:
utils.system(["git", "apply", p])
utils.commit("applied patch %s" % os.path.basename(p))
except subprocess.CalledProcessError:
print "ERROR: patch %s failed to apply" % os.path.basename(p)
print("ERROR: patch %s failed to apply" % os.path.basename(p))
raise
15 changes: 8 additions & 7 deletions sky/tools/roll/roll.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand All @@ -8,7 +9,7 @@
import os
import subprocess
import sys
import urllib2
import urllib.request, urllib.error, urllib.parse
from utils import commit
from utils import system
import patch
Expand Down Expand Up @@ -96,12 +97,12 @@ def rev(source_dir, dest_dir, dirs_to_rev, name, revision_file=None):
else:
d = dir_to_rev
file_subset = None
print "removing directory %s" % d
print("removing directory %s" % d)
try:
system(["git", "rm", "-r", d], cwd=dest_dir)
except subprocess.CalledProcessError:
print "Could not remove %s" % d
print "cloning directory %s" % d
print("Could not remove %s" % d)
print("cloning directory %s" % d)

if file_subset is None:
files = system(["git", "ls-files", d], cwd=source_dir).splitlines()
Expand Down Expand Up @@ -151,8 +152,8 @@ def main():
try:
patch.patch_and_filter(dest_dir, os.path.join('patches', 'chromium'))
except subprocess.CalledProcessError:
print "ERROR: Roll failed due to a patch not applying"
print "Fix the patch to apply, commit the result, and re-run this script"
print("ERROR: Roll failed due to a patch not applying")
print("Fix the patch to apply, commit the result, and re-run this script")
return 1

return 0
Expand Down
3 changes: 2 additions & 1 deletion sky/tools/roll/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Expand Down
Loading

0 comments on commit 14f12e8

Please sign in to comment.