diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-05-06 04:07:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-05-06 04:13:42 +0300 |
commit | bc2f77e1da8f4a4e9074223824c9d3d29fc87a7b (patch) | |
tree | 52381accdc30f86e6c4cee51d00995b4da680319 /source/blender/blenkernel/intern/appdir.c | |
parent | c246e0c3b6bfd4c57d12f8c3b232968b59757e26 (diff) |
Add bpy.app.binary_path_python
Access to the python binary distributed with Blender,
fallback to system python executable (matching Blender's version).
Diffstat (limited to 'source/blender/blenkernel/intern/appdir.c')
-rw-r--r-- | source/blender/blenkernel/intern/appdir.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 61aa0eb617a..4c7cda95ad1 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -599,6 +599,45 @@ const char *BKE_appdir_program_dir(void) return bprogdir; } +bool BKE_appdir_program_python_search( + char *fullpath, const size_t fullpath_len, + const int version_major, const int version_minor) +{ + const char *basename = "python"; + bool is_found = false; + + { + const char *python_bin_dir = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, "bin"); + if (python_bin_dir) { + BLI_join_dirfile(fullpath, fullpath_len, python_bin_dir, basename); + if ( +#ifdef _WIN32 + BLI_path_program_extensions_add_win32(fullpath, fullpath_len) +#else + BLI_exists(fullpath) +#endif + ) + { + is_found = true; + } + } + } + + if (is_found == false) { + char python_ver[16]; + BLI_snprintf(python_ver, sizeof(python_ver), "%s%d.%d", basename, version_major, version_minor); + if (BLI_path_program_search(fullpath, fullpath_len, python_ver)) { + is_found = true; + } + } + + if (is_found == false) { + *fullpath = '\0'; + } + + return is_found; +} + /** * Gets the temp directory when blender first runs. * If the default path is not found, use try $TEMP |