Commit 64667b05 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Build Android] Fix monochrome_public_apk_checker data deps

This CL converts
//chrome/android/monochrome:monochrome_public_apk_checker
to use python_library and adds pydeps

BUG=1138758

Change-Id: If1b12bddbad721954ce227ab6c49af922ecca34f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2480846
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818282}
parent 18c540d8
......@@ -1366,6 +1366,7 @@ _GENERIC_PYDEPS_FILES = [
'build/android/test_wrapper/logdog_wrapper.pydeps',
'build/lacros/lacros_resource_sizes.pydeps',
'build/protoc_java.pydeps',
'chrome/android/monochrome/scripts/monochrome_python_tests.pydeps',
'chrome/test/chromedriver/log_replay/client_replay_unittest.pydeps',
'chrome/test/chromedriver/test/run_py_tests.pydeps',
'components/cronet/tools/generate_javadoc.pydeps',
......
......@@ -12,6 +12,7 @@ This script should be compatible with Python 2 and Python 3.
"""
import argparse
import fnmatch
import os
import pipes
import sys
......@@ -63,12 +64,13 @@ def _NormalizeCommandLine(options):
return ' '.join(pipes.quote(x) for x in args)
def _FindPythonInDirectory(directory):
def _FindPythonInDirectory(directory, allow_test):
"""Returns an iterable of all non-test python files in the given directory."""
files = []
for root, _dirnames, filenames in os.walk(directory):
for filename in filenames:
if filename.endswith('.py') and not filename.endswith('_test.py'):
if filename.endswith('.py') and (allow_test
or not filename.endswith('_test.py')):
yield os.path.join(root, filename)
......@@ -99,6 +101,8 @@ def _GetTargetPythonVersion(module):
def _ImportModuleByPath(module_path):
"""Imports a module by its source file."""
# Replace the path entry for print_python_deps.py with the one for the given
# module.
sys.path[0] = os.path.dirname(module_path)
if sys.version_info[0] == 2:
import imp # Python 2 only, since it's deprecated in Python 3.
......@@ -146,8 +150,17 @@ def main():
options.output = options.module + 'deps'
options.root = os.path.dirname(options.module)
target_version = _GetTargetPythonVersion(options.module)
modules = [options.module]
if os.path.isdir(options.module):
modules = list(_FindPythonInDirectory(options.module, allow_test=True))
if not modules:
parser.error('Input directory does not contain any python files!')
target_versions = [_GetTargetPythonVersion(m) for m in modules]
target_version = target_versions[0]
assert target_version in [2, 3]
assert all(v == target_version for v in target_versions)
current_version = sys.version_info[0]
# Trybots run with vpython as default Python, but with a different config
......@@ -167,10 +180,11 @@ def main():
vpython_to_use = {2: 'vpython', 3: 'vpython3'}[target_version]
os.execvp(vpython_to_use, [vpython_to_use] + sys.argv + ['--did-relaunch'])
# Replace the path entry for print_python_deps.py with the one for the given
# module.
paths_set = set()
try:
_ImportModuleByPath(options.module)
for module in modules:
_ImportModuleByPath(module)
paths_set.update(ComputePythonDependencies())
except Exception:
# Output extra diagnostics when loading the script fails.
sys.stderr.write('Error running print_python_deps.py.\n')
......@@ -179,9 +193,10 @@ def main():
sys.stderr.write('python={}\n'.format(sys.executable))
raise
paths_set = ComputePythonDependencies()
for path in options.whitelists:
paths_set.update(os.path.abspath(p) for p in _FindPythonInDirectory(path))
paths_set.update(
os.path.abspath(p)
for p in _FindPythonInDirectory(path, allow_test=False))
paths = [os.path.relpath(p, options.root) for p in paths_set]
......
......@@ -2,22 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/config.gni")
import("//build/config/python.gni")
group("monochrome_public_apk_checker") {
python_library("monochrome_public_apk_checker") {
testonly = true
pydeps_file =
"//chrome/android/monochrome/scripts/monochrome_python_tests.pydeps"
data_deps = [
"//android_webview:system_webview_apk",
"//chrome/android:chrome_public_apk",
"//chrome/android:monochrome_public_apk",
]
data = [
"scripts/",
"//testing/scripts/common.py",
"//testing/scripts/run_isolated_script_test.py",
"//third_party/catapult/devil/",
"//third_party/catapult/third_party/typ/",
"//testing/xvfb.py",
]
}
#!/usr/bin/env python3
#!/usr/bin/env python2.7
#
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
......
#!/usr/bin/env python3
#!/usr/bin/env python2.7
#
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
......
# Generated by running:
# build/print_python_deps.py chrome/android/monochrome/scripts
build/android/devil_chromium.py
build/android/pylib/__init__.py
build/android/pylib/constants/__init__.py
build/android/pylib/constants/host_paths.py
chrome/android/monochrome/scripts/monochrome_android_manifest_test.py
chrome/android/monochrome/scripts/monochrome_apk_checker_test.py
chrome/android/monochrome/scripts/monochrome_dexdump_test.py
chrome/android/monochrome/scripts/monochrome_python_tests.py
third_party/catapult/common/py_utils/py_utils/__init__.py
third_party/catapult/common/py_utils/py_utils/cloud_storage.py
third_party/catapult/common/py_utils/py_utils/cloud_storage_global_lock.py
third_party/catapult/common/py_utils/py_utils/lock.py
third_party/catapult/dependency_manager/dependency_manager/__init__.py
third_party/catapult/dependency_manager/dependency_manager/archive_info.py
third_party/catapult/dependency_manager/dependency_manager/base_config.py
third_party/catapult/dependency_manager/dependency_manager/cloud_storage_info.py
third_party/catapult/dependency_manager/dependency_manager/dependency_info.py
third_party/catapult/dependency_manager/dependency_manager/dependency_manager_util.py
third_party/catapult/dependency_manager/dependency_manager/exceptions.py
third_party/catapult/dependency_manager/dependency_manager/local_path_info.py
third_party/catapult/dependency_manager/dependency_manager/manager.py
third_party/catapult/dependency_manager/dependency_manager/uploader.py
third_party/catapult/devil/devil/__init__.py
third_party/catapult/devil/devil/android/__init__.py
third_party/catapult/devil/devil/android/constants/__init__.py
third_party/catapult/devil/devil/android/constants/chrome.py
third_party/catapult/devil/devil/android/ndk/__init__.py
third_party/catapult/devil/devil/android/ndk/abis.py
third_party/catapult/devil/devil/android/sdk/__init__.py
third_party/catapult/devil/devil/android/sdk/build_tools.py
third_party/catapult/devil/devil/android/sdk/keyevent.py
third_party/catapult/devil/devil/android/sdk/version_codes.py
third_party/catapult/devil/devil/base_error.py
third_party/catapult/devil/devil/constants/__init__.py
third_party/catapult/devil/devil/constants/exit_codes.py
third_party/catapult/devil/devil/devil_env.py
third_party/catapult/devil/devil/utils/__init__.py
third_party/catapult/devil/devil/utils/cmd_helper.py
third_party/catapult/devil/devil/utils/lazy/__init__.py
third_party/catapult/devil/devil/utils/lazy/weak_constant.py
third_party/catapult/devil/devil/utils/reraiser_thread.py
third_party/catapult/devil/devil/utils/timeout_retry.py
third_party/catapult/devil/devil/utils/watchdog_timer.py
third_party/catapult/third_party/typ/typ/__init__.py
third_party/catapult/third_party/typ/typ/arg_parser.py
third_party/catapult/third_party/typ/typ/artifacts.py
third_party/catapult/third_party/typ/typ/expectations_parser.py
third_party/catapult/third_party/typ/typ/fakes/__init__.py
third_party/catapult/third_party/typ/typ/fakes/host_fake.py
third_party/catapult/third_party/typ/typ/host.py
third_party/catapult/third_party/typ/typ/json_results.py
third_party/catapult/third_party/typ/typ/pool.py
third_party/catapult/third_party/typ/typ/printer.py
third_party/catapult/third_party/typ/typ/python_2_3_compat.py
third_party/catapult/third_party/typ/typ/runner.py
third_party/catapult/third_party/typ/typ/stats.py
third_party/catapult/third_party/typ/typ/test_case.py
third_party/catapult/third_party/typ/typ/version.py
third_party/catapult/third_party/zipfile/zipfile_2_7_13.py
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