Python: search for 'python' and 'python#.#'

This commit is contained in:
Campbell Barton
2015-05-19 15:55:31 +10:00
parent 3d70a04a8a
commit d5a85f87b0

View File

@@ -607,30 +607,42 @@ bool BKE_appdir_program_python_search(
const int version_major, const int version_minor) const int version_major, const int version_minor)
{ {
const char *basename = "python"; const char *basename = "python";
char python_ver[16];
/* check both possible names */
const char *python_names[] = {basename, python_ver};
int i;
bool is_found = false; bool is_found = false;
BLI_snprintf(python_ver, sizeof(python_ver), "%s%d.%d", basename, version_major, version_minor);
{ {
const char *python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, "bin"); const char *python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, "bin");
if (python_bin_dir) { if (python_bin_dir) {
BLI_join_dirfile(fullpath, fullpath_len, python_bin_dir, basename);
if ( for (i = 0; i < ARRAY_SIZE(python_names); i++) {
BLI_join_dirfile(fullpath, fullpath_len, python_bin_dir, python_names[i]);
if (
#ifdef _WIN32 #ifdef _WIN32
BLI_path_program_extensions_add_win32(fullpath, fullpath_len) BLI_path_program_extensions_add_win32(fullpath, fullpath_len)
#else #else
BLI_exists(fullpath) BLI_exists(fullpath)
#endif #endif
) )
{ {
is_found = true; is_found = true;
}
} }
} }
} }
if (is_found == false) { if (is_found == false) {
char python_ver[16]; for (i = 0; i < ARRAY_SIZE(python_names); i++) {
BLI_snprintf(python_ver, sizeof(python_ver), "%s%d.%d", basename, version_major, version_minor); if (BLI_path_program_search(fullpath, fullpath_len, python_names[i])) {
if (BLI_path_program_search(fullpath, fullpath_len, python_ver)) { is_found = true;
is_found = true; break;
}
} }
} }