Skip to content

Commit cd601ad

Browse files
committed
Try with python and then python3
1 parent a0352a3 commit cd601ad

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

blosc/blosc-private.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,32 @@ static inline const char *dlerror (void) {
246246
#endif
247247

248248

249-
static inline void* load_lib(char *plugin_name, char *libpath) {
249+
static inline int get_libpath(char *plugin_name, char *libpath, char *python_version) {
250+
BLOSC_TRACE_INFO("Trying to get plugin path with python%s\n", python_version);
250251
char python_cmd[PATH_MAX] = {0};
251-
sprintf(python_cmd, "python3 -c \"import blosc2_%s; blosc2_%s.print_libpath()\"", plugin_name, plugin_name);
252+
sprintf(python_cmd, "python%s -c \"import blosc2_%s; blosc2_%s.print_libpath()\"", python_version, plugin_name, plugin_name);
252253
FILE *fp = popen(python_cmd, "r");
253254
if (fp == NULL) {
254255
BLOSC_TRACE_ERROR("Could not run python");
255-
return NULL;
256+
return BLOSC2_ERROR_FAILURE;
256257
}
257258
if (fgets(libpath, PATH_MAX, fp) == NULL) {
258259
BLOSC_TRACE_ERROR("Could not read python output");
259260
pclose(fp);
260-
return NULL;
261+
return BLOSC2_ERROR_FAILURE;
261262
}
262263
pclose(fp);
264+
265+
return BLOSC2_ERROR_SUCCESS;
266+
}
267+
268+
269+
static inline void* load_lib(char *plugin_name, char *libpath) {
270+
if (get_libpath(plugin_name, libpath, "") < 0 && get_libpath(plugin_name, libpath, "3") < 0) {
271+
BLOSC_TRACE_ERROR("Problems when running python or python3 for getting plugin path");
272+
return NULL;
273+
}
274+
263275
if (strlen(libpath) == 0) {
264276
BLOSC_TRACE_ERROR("Could not find plugin libpath");
265277
return NULL;

0 commit comments

Comments
 (0)