Use cpython3 host prebuilts on most branches

But continue building them on the aosp-build-tools branch, as that's
where the prebuilts come from.

This will allow us to link against openssl for host python, even though
openssl is only available on aosp-build-tools.

Bug: 173151817
Test: ensure prebuilts are used on master, and sources on build-tools
Test: treehugger
Change-Id: I568e84fb483a0cd2f949f65cd5392d252ee8d493
diff --git a/Android.bp b/Android.bp
index aff7f2a..7b5a629 100644
--- a/Android.bp
+++ b/Android.bp
@@ -67,3 +67,71 @@
         },
     },
 }
+
+///
+// cpython3 host prebuilts
+///
+soong_config_module_type {
+    name: "cpython3_cc_prebuilt_binary",
+    module_type: "cc_prebuilt_binary",
+    config_namespace: "cpython3",
+    bool_variables: ["force_build_host"],
+    properties: ["prefer"],
+}
+
+cpython3_cc_prebuilt_binary {
+    name: "py3-launcher",
+    host_supported: true,
+    device_supported: false,
+    compile_multilib: "64",
+    stl: "none",
+    notice: "common/py3-stdlib/NOTICE",
+    target: {
+        linux_glibc_x86_64: {
+            srcs: ["linux-x86/bin/py3-launcher64"]
+        },
+        darwin_x86_64: {
+            srcs: ["darwin-x86/bin/py3-launcher64"],
+        },
+    },
+
+    // Use the prebuilts for most branches
+    prefer: true,
+    soong_config_variables: {
+        force_build_host: {
+            prefer: false,
+        },
+    },
+}
+
+cpython3_cc_prebuilt_binary {
+    name: "py3-launcher-autorun",
+    host_supported: true,
+    device_supported: false,
+    compile_multilib: "64",
+    stl: "none",
+    notice: "common/py3-stdlib/NOTICE",
+    target: {
+        linux_glibc_x86_64: {
+            srcs: ["linux-x86/bin/py3-launcher-autorun64"]
+        },
+        darwin_x86_64: {
+            srcs: ["darwin-x86/bin/py3-launcher-autorun64"],
+        },
+    },
+
+    // Use the prebuilts for most branches
+    prefer: true,
+    soong_config_variables: {
+        force_build_host: {
+            prefer: false,
+        },
+    },
+}
+
+filegroup {
+    name: "py3-stdlib-prebuilt-srcs",
+    visibility: ["//external/python/cpython3/Lib"],
+    srcs: ["common/py3-stdlib/**/*.py"],
+    path: "common/py3-stdlib",
+}