acloud: fix py3 3rd_party compatible issues: ModuleNotFoundError: No module named 'http.client'
1 do sys.path.insert(0, /usr/lib/python3.X) while running in python3.
2 pyopenssl doesn't work in python3, so move into version py2.
3 replace import httplib as import six.moves.http_client.
BUG: 137195528
BUG: 144743252
Test: acloud-dev create
acloud-dev create --local-instance
acloud-dev create --local-instance --local-image
acloud-dev create --local-image
Change-Id: I5237da4a46fb7af43bfe4f3006a690de08b628b5
diff --git a/public/acloud_main.py b/public/acloud_main.py
index b26a01e..ac63029 100644
--- a/public/acloud_main.py
+++ b/public/acloud_main.py
@@ -70,8 +70,10 @@
from __future__ import print_function
import argparse
import logging
+import os
import platform
import sys
+import sysconfig
import traceback
# TODO: Remove this once we switch over to embedded launcher.
@@ -93,6 +95,12 @@
print(" - or -")
print(" POSIXLY_CORRECT=1 port -N install python27")
sys.exit(1)
+# This is a workaround to put '/usr/lib/python3.X' ahead of googleapiclient of
+# build system path list to fix python3 issue of http.client(b/144743252)
+# that googleapiclient existed http.py conflict with python3 build-in lib.
+# Using embedded_launcher(b/135639220) perhaps work whereas it didn't solve yet.
+if sys.version_info.major == 3:
+ sys.path.insert(0, os.path.dirname(sysconfig.get_paths()['purelib']))
# By Default silence root logger's stream handler since 3p lib may initial
# root logger no matter what level we're using. The acloud logger behavior will