Create py2-cmd which behaves more like the normal `python`
Instead of executing the __main__.py inside the par file, it'll use all
the normal python command line options, allowing you to replace python
in $PATH with this executable.
Also add distutils, which some script expect to be in the stdlib.
Bug: 117811537
Test: move py2-cmd to prebuilts/build-tools/path/linux-x86/python and build
Change-Id: Iddab6ab4db23f99953ecf4d42cd7d966851b1e1b
diff --git a/Android.bp b/Android.bp
index 5d72eda..aba4538 100644
--- a/Android.bp
+++ b/Android.bp
@@ -211,8 +211,8 @@
],
}
-cc_binary {
- name: "py2-launcher",
+cc_defaults {
+ name: "py2-launcher-defaults",
defaults: ["py2-interp-defaults"],
cflags: [
"-DVERSION=\"2.7\"",
@@ -226,8 +226,32 @@
"-DDATE=\"Dec 31 1969\"",
"-DTIME=\"23:59:59\"",
],
+ static_libs: [
+ "libbase",
+ "libcrypto",
+ "libexpat",
+ "libssl",
+ "libz",
+ ],
+ target: {
+ linux_glibc_x86_64: {
+ host_ldlibs: ["-lutil"],
+ },
+ host: {
+ static_libs: ["libsqlite"],
+ },
+ // Use shared libsqlite for device side, otherwise
+ // the executable size will be really huge.
+ android: {
+ shared_libs: ["libsqlite"],
+ },
+ },
+}
+
+cc_library_static {
+ name: "py2-launcher-lib",
+ defaults: ["py2-launcher-defaults"],
srcs: [
- "Launcher/launcher_main.cpp",
"Modules/gcmodule.c",
"Modules/getpath.c",
"Modules/config.c",
@@ -246,8 +270,7 @@
"Modules/main.c",
],
// NOTE: Please update Modules/config.c if new lib get added in the static_libs.
- static_libs: [
- "libbase",
+ whole_static_libs: [
// Be careful the order of these three static libraries below due to
// missing symbols issues.
"py2-interp-object",
@@ -307,22 +330,34 @@
"py2-c-module-_sqlite3",
"py2-c-module-_ctypes_test",
"py2-c-module-_ctypes",
- "libcrypto",
- "libexpat",
- "libssl",
- "libz",
],
- target: {
- linux_glibc_x86_64: {
- host_ldlibs: ["-lutil"],
+}
+
+cc_binary {
+ name: "py2-launcher",
+ defaults: ["py2-launcher-defaults"],
+ srcs: ["Launcher/launcher_main.cpp"],
+ static_libs: ["py2-launcher-lib"],
+}
+
+cc_binary {
+ name: "py2-launcher-autorun",
+ defaults: ["py2-launcher-defaults"],
+ srcs: ["Launcher/launcher_main.cpp"],
+ static_libs: ["py2-launcher-lib"],
+ cflags: ["-DANDROID_AUTORUN"],
+}
+
+python_binary_host {
+ name: "py2-cmd",
+ autorun: false,
+ version: {
+ py2: {
+ enabled: true,
+ embedded_launcher: true,
},
- host: {
- static_libs: ["libsqlite"],
- },
- // Use shared libsqlite for device side, otherwise
- // the executable size will be really huge.
- android: {
- shared_libs: ["libsqlite"],
+ py3: {
+ enabled: false,
},
},
}