@@ -305,6 +305,11 @@ int main(int argc, char *argv[]) {
305305 /* Get the entrypoint, search the .pyo then .py
306306 */
307307 char * dot = strrchr (env_entrypoint , '.' );
308+ #if PY_MAJOR_VERSION > 2
309+ char * ext = ".pyc" ;
310+ #else
311+ char * ext = ".pyo" ;
312+ #endif
308313 if (dot <= 0 ) {
309314 LOGP ("Invalid entrypoint, abort." );
310315 return -1 ;
@@ -313,14 +318,14 @@ int main(int argc, char *argv[]) {
313318 LOGP ("Entrypoint path is too long, try increasing ENTRYPOINT_MAXLEN." );
314319 return -1 ;
315320 }
316- if (!strcmp (dot , ".pyo" )) {
321+ if (!strcmp (dot , ext )) {
317322 if (!file_exists (env_entrypoint )) {
318323 /* fallback on .py */
319324 strcpy (entrypoint , env_entrypoint );
320325 entrypoint [strlen (env_entrypoint ) - 1 ] = '\0' ;
321326 LOGP (entrypoint );
322327 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" );
324329 return -1 ;
325330 }
326331 } else {
@@ -330,7 +335,11 @@ int main(int argc, char *argv[]) {
330335 /* if .py is passed, check the pyo version first */
331336 strcpy (entrypoint , env_entrypoint );
332337 entrypoint [strlen (env_entrypoint ) + 1 ] = '\0' ;
338+ #if PY_MAJOR_VERSION > 2
339+ entrypoint [strlen (env_entrypoint )] = 'c' ;
340+ #else
333341 entrypoint [strlen (env_entrypoint )] = 'o' ;
342+ #endif
334343 if (!file_exists (entrypoint )) {
335344 /* fallback on pure python version */
336345 if (!file_exists (env_entrypoint )) {
@@ -340,7 +349,7 @@ int main(int argc, char *argv[]) {
340349 strcpy (entrypoint , env_entrypoint );
341350 }
342351 } 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." );
344353 return -1 ;
345354 }
346355 // LOGP("Entrypoint is:");
0 commit comments