diff options
author | Dan Willemsen <dwillemsen@google.com> | 2023-08-17 20:56:09 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-08-17 20:56:09 +0000 |
commit | da63aaa9ab14c95e62459c37247e2a8a2ea9cffc (patch) | |
tree | f01c77644cce6e0aa87af221a38dfcc0ec5a6239 | |
parent | d48d7c8c93516401de432bc896f0b02531d49f5d (diff) | |
parent | 698b6765f8222dfbccf95a685adb3a422c6c5f83 (diff) | |
download | cpython3-da63aaa9ab14c95e62459c37247e2a8a2ea9cffc.tar.gz |
Simplify the launcher path detection (prep for 3.11) am: 02afc01277 am: b1fb7da08c am: 55f43e4231 am: 698b6765f8
Original change: https://android-review.googlesource.com/c/platform/external/python/cpython3/+/2713453
Change-Id: I9a6fbf9ccbd2d6a163b1a757b2e0521062e9d04e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | Android.bp | 5 | ||||
-rw-r--r-- | Lib/Android.bp | 51 | ||||
-rw-r--r-- | android/launcher_main.cpp | 34 |
3 files changed, 10 insertions, 80 deletions
diff --git a/Android.bp b/Android.bp index 47cdaa64bb..f9413bd1fb 100644 --- a/Android.bp +++ b/Android.bp @@ -347,10 +347,7 @@ cc_defaults { "-DVPATH=\"\"", "-DPREFIX=\"\"", "-DEXEC_PREFIX=\"\"", - "-DPYTHONPATH=\"..:\"", - "-DANDROID_SKIP_ZIP_PATH", - "-DANDROID_SKIP_EXEC_PREFIX_PATH", - "-DANDROID_LIB_PYTHON_PATH=\"internal/stdlib\"", + "-DPYTHONPATH=\"\"", "-DDATE=\"Dec 31 1969\"", "-DTIME=\"23:59:59\"", ], diff --git a/Lib/Android.bp b/Lib/Android.bp index 3b9c289d74..a4de8aa626 100644 --- a/Lib/Android.bp +++ b/Lib/Android.bp @@ -64,57 +64,12 @@ filegroup { ], } -soong_config_module_type { - name: "cpython3_python_stdlib", - module_type: "python_library", - config_namespace: "cpython3", - bool_variables: ["force_build_host"], - properties: ["defaults"], -} - -python_defaults { - name: "py3-stdlib-force-build", - defaults_visibility: ["//visibility:private"], - target: { - glibc: { - exclude_srcs: [":py3-stdlib-prebuilt-srcs"], - srcs: [":py3-stdlib-srcs"], - }, - musl: { - exclude_srcs: [":py3-stdlib-prebuilt-srcs"], - srcs: [":py3-stdlib-srcs"], - }, - darwin: { - exclude_srcs: [":py3-stdlib-prebuilt-srcs"], - srcs: [":py3-stdlib-srcs"], - }, - }, -} - -cpython3_python_stdlib { +python_library { name: "py3-stdlib", is_internal: true, - pkg_path: "stdlib", + pkg_path: "python3.10", host_supported: true, - target: { - bionic: { - srcs: [":py3-stdlib-srcs"], - }, - glibc: { - srcs: [":py3-stdlib-prebuilt-srcs"], - }, - musl: { - srcs: [":py3-stdlib-prebuilt-srcs"], - }, - darwin: { - srcs: [":py3-stdlib-prebuilt-srcs"], - }, - }, - soong_config_variables: { - force_build_host: { - defaults: ["py3-stdlib-force-build"], - }, - }, + srcs: [":py3-stdlib-srcs"], } // Used by prebuilts/build-tools/build-prebuilts.sh to update diff --git a/android/launcher_main.cpp b/android/launcher_main.cpp index 39c1f99e87..70fe0ff9b6 100644 --- a/android/launcher_main.cpp +++ b/android/launcher_main.cpp @@ -59,22 +59,16 @@ int main(int argc, char *argv[]) { // include something unusable, too bad. // android::base::GetExecutablePath() also handles for Darwin/Windows. std::string executable_path = android::base::GetExecutablePath(); - std::string internal_path = executable_path + "/internal"; - std::string stdlib_path = internal_path + "/stdlib"; PyStatus status; - PyConfig config; PyConfig_InitPythonConfig(&config); - wchar_t *path_entry; - // Ignore PYTHONPATH and PYTHONHOME from the environment. Unless we're not // running from inside the zip file, in which case the user may have // specified a PYTHONPATH. #ifdef ANDROID_AUTORUN config.use_environment = 0; - config.module_search_paths_set = 1; config.parse_argv = 0; #endif @@ -85,6 +79,12 @@ int main(int argc, char *argv[]) { return 1; } + config.platlibdir = Py_DecodeLocale("internal", NULL); + if (config.platlibdir == NULL) { + fprintf(stderr, "Unable to parse platlibdir\n"); + return 1; + } + #ifdef ANDROID_AUTORUN // Execute the __main__.py script inside the zip file attached to our executable. config.run_filename = wcsdup(config.home); @@ -100,28 +100,6 @@ int main(int argc, char *argv[]) { goto fail; } - path_entry = Py_DecodeLocale(internal_path.c_str(), NULL); - if (path_entry == NULL) { - fprintf(stderr, "Unable to parse path\n"); - return 1; - } - - status = PyWideStringList_Append(&config.module_search_paths, path_entry); - if (PyStatus_Exception(status)) { - goto fail; - } - - path_entry = Py_DecodeLocale(stdlib_path.c_str(), NULL); - if (path_entry == NULL) { - fprintf(stderr, "Unable to parse path\n"); - return 1; - } - - status = PyWideStringList_Append(&config.module_search_paths, path_entry); - if (PyStatus_Exception(status)) { - goto fail; - } - // Always enable Python "-S" option. We don't need site directories, // everything's supposed to be hermetic. config.site_import = 0; |