@@ -263,6 +263,11 @@ int main(int argc, char *argv[]) {
263
263
/* Get the entrypoint, search the .pyo then .py
264
264
*/
265
265
char * dot = strrchr (env_entrypoint , '.' );
266
+ #if PY_MAJOR_VERSION > 2
267
+ char * ext = ".pyc" ;
268
+ #else
269
+ char * ext = ".pyo" ;
270
+ #endif
266
271
if (dot <= 0 ) {
267
272
LOGP ("Invalid entrypoint, abort." );
268
273
return -1 ;
@@ -271,14 +276,14 @@ int main(int argc, char *argv[]) {
271
276
LOGP ("Entrypoint path is too long, try increasing ENTRYPOINT_MAXLEN." );
272
277
return -1 ;
273
278
}
274
- if (!strcmp (dot , ".pyo" )) {
279
+ if (!strcmp (dot , ext )) {
275
280
if (!file_exists (env_entrypoint )) {
276
281
/* fallback on .py */
277
282
strcpy (entrypoint , env_entrypoint );
278
283
entrypoint [strlen (env_entrypoint ) - 1 ] = '\0' ;
279
284
LOGP (entrypoint );
280
285
if (!file_exists (entrypoint )) {
281
- LOGP ("Entrypoint not found (.pyo, fallback on .py), abort" );
286
+ LOGP ("Entrypoint not found (.pyc/. pyo, fallback on .py), abort" );
282
287
return -1 ;
283
288
}
284
289
} else {
@@ -288,7 +293,11 @@ int main(int argc, char *argv[]) {
288
293
/* if .py is passed, check the pyo version first */
289
294
strcpy (entrypoint , env_entrypoint );
290
295
entrypoint [strlen (env_entrypoint ) + 1 ] = '\0' ;
296
+ #if PY_MAJOR_VERSION > 2
297
+ entrypoint [strlen (env_entrypoint )] = 'c' ;
298
+ #else
291
299
entrypoint [strlen (env_entrypoint )] = 'o' ;
300
+ #endif
292
301
if (!file_exists (entrypoint )) {
293
302
/* fallback on pure python version */
294
303
if (!file_exists (env_entrypoint )) {
@@ -298,7 +307,7 @@ int main(int argc, char *argv[]) {
298
307
strcpy (entrypoint , env_entrypoint );
299
308
}
300
309
} else {
301
- LOGP ("Entrypoint have an invalid extension (must be .py or .pyo), abort." );
310
+ LOGP ("Entrypoint have an invalid extension (must be .py or .pyc/. pyo), abort." );
302
311
return -1 ;
303
312
}
304
313
// LOGP("Entrypoint is:");
0 commit comments