From 48eee8b4b447a2ad11df28dd81a2ccb65562b5f5 Mon Sep 17 00:00:00 2001 From: ThomasCJY Date: Wed, 21 Apr 2021 17:55:04 -0700 Subject: [PATCH] [Bazel] Fix mobile-install for python2 **Background** Fix issue introduced by https://github.com/bazelbuild/bazel/commit/1049fe89f12cfcae00902fbae6f6a5f1bc0b3a33 It turns out the queue module name is inconsistent across different python versions. We found that: * On some macos system: - python2 contains both queue and Queue module. All python2 contains Queue module - python3 only contains queue module * On some Linux system - python2 contains only Queue module. - python3 only contains queue module Therefore, some developers are seeing `ImportError: No module named queue` errors locally on linux machine after using mobile-install. **Change** Import correct Queue module instead **Test** Local test pass Closes #12540. PiperOrigin-RevId: 369773133 --- tools/android/build_incremental_dexmanifest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/android/build_incremental_dexmanifest.py b/tools/android/build_incremental_dexmanifest.py index 2832761a896db7..6f97c02f394f3d 100644 --- a/tools/android/build_incremental_dexmanifest.py +++ b/tools/android/build_incremental_dexmanifest.py @@ -32,7 +32,13 @@ import hashlib import os -from queue import Queue +# pylint: disable=g-import-not-at-top +try: + # python2 without compatibility package + from Queue import Queue +except ImportError: + # python3 + from queue import Queue import shutil import sys import tempfile