@@ -305,6 +305,11 @@ int main(int argc, char *argv[]) {
305
305
/* Get the entrypoint, search the .pyo then .py
306
306
*/
307
307
char * dot = strrchr (env_entrypoint , '.' );
308
+ #if PY_MAJOR_VERSION > 2
309
+ char * ext = ".pyc" ;
310
+ #else
311
+ char * ext = ".pyo" ;
312
+ #endif
308
313
if (dot <= 0 ) {
309
314
LOGP ("Invalid entrypoint, abort." );
310
315
return -1 ;
@@ -313,14 +318,14 @@ int main(int argc, char *argv[]) {
313
318
LOGP ("Entrypoint path is too long, try increasing ENTRYPOINT_MAXLEN." );
314
319
return -1 ;
315
320
}
316
- if (!strcmp (dot , ".pyo" )) {
321
+ if (!strcmp (dot , ext )) {
317
322
if (!file_exists (env_entrypoint )) {
318
323
/* fallback on .py */
319
324
strcpy (entrypoint , env_entrypoint );
320
325
entrypoint [strlen (env_entrypoint ) - 1 ] = '\0' ;
321
326
LOGP (entrypoint );
322
327
if (!file_exists (entrypoint )) {
323
- LOGP ("Entrypoint not found (.pyo, fallback on .py), abort" );
328
+ LOGP ("Entrypoint not found (.pyc/. pyo, fallback on .py), abort" );
324
329
return -1 ;
325
330
}
326
331
} else {
@@ -330,7 +335,11 @@ int main(int argc, char *argv[]) {
330
335
/* if .py is passed, check the pyo version first */
331
336
strcpy (entrypoint , env_entrypoint );
332
337
entrypoint [strlen (env_entrypoint ) + 1 ] = '\0' ;
338
+ #if PY_MAJOR_VERSION > 2
339
+ entrypoint [strlen (env_entrypoint )] = 'c' ;
340
+ #else
333
341
entrypoint [strlen (env_entrypoint )] = 'o' ;
342
+ #endif
334
343
if (!file_exists (entrypoint )) {
335
344
/* fallback on pure python version */
336
345
if (!file_exists (env_entrypoint )) {
@@ -340,7 +349,7 @@ int main(int argc, char *argv[]) {
340
349
strcpy (entrypoint , env_entrypoint );
341
350
}
342
351
} else {
343
- LOGP ("Entrypoint have an invalid extension (must be .py or .pyo), abort." );
352
+ LOGP ("Entrypoint have an invalid extension (must be .py or .pyc/. pyo), abort." );
344
353
return -1 ;
345
354
}
346
355
// LOGP("Entrypoint is:");
0 commit comments