@@ -246,20 +246,32 @@ static inline const char *dlerror (void) {
246
246
#endif
247
247
248
248
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 );
250
251
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 );
252
253
FILE * fp = popen (python_cmd , "r" );
253
254
if (fp == NULL ) {
254
255
BLOSC_TRACE_ERROR ("Could not run python" );
255
- return NULL ;
256
+ return BLOSC2_ERROR_FAILURE ;
256
257
}
257
258
if (fgets (libpath , PATH_MAX , fp ) == NULL ) {
258
259
BLOSC_TRACE_ERROR ("Could not read python output" );
259
260
pclose (fp );
260
- return NULL ;
261
+ return BLOSC2_ERROR_FAILURE ;
261
262
}
262
263
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
+
263
275
if (strlen (libpath ) == 0 ) {
264
276
BLOSC_TRACE_ERROR ("Could not find plugin libpath" );
265
277
return NULL ;
0 commit comments