bdist_egg and pyo files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bdist_egg and pyo files

andrea crotti-2
I've been asked to ship our eggs as pyo files instead of pyc, but
1. I'm not 100% sure it's a good idea, what issues can this raise?
2. I can't find any option in bdist_egg to actually compile the files
     in optimized mode, is it not there on purpose??

Thanks,
Andrea
_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: bdist_egg and pyo files

PJ Eby
On Wed, Mar 28, 2012 at 12:41 PM, Andrea Crotti <[hidden email]> wrote:
I've been asked to ship our eggs as pyo files instead of pyc, but
1. I'm not 100% sure it's a good idea, what issues can this raise?
2. I can't find any option in bdist_egg to actually compile the files
   in optimized mode, is it not there on purpose??

You have to do "setup.py build_py -O1 bdist_egg"  (or -O2 if you prefer).   Doing this will include the .pyo files *in addition* to the .pyc files.  There is currently no way to disable the .pyc files from being included. 

_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: bdist_egg and pyo files

Éric Araujo
Le 28/03/2012 15:56, PJ Eby a écrit :
> On Wed, Mar 28, 2012 at 12:41 PM, Andrea Crotti
> <[hidden email]>wrote:
>> I've been asked to ship our eggs as pyo files instead of pyc, but
>> 1. I'm not 100% sure it's a good idea, what issues can this raise?
- assert statements will not be executed; if some code uses asserts to
do argument checking, behavior can change for the worse.

- the global name __debug__ will be False; in the stdlib for example
it’s used by imaplib to log additional info (the assumption being that
in production it would be run with -O).

I’m not sure -O is really useful.

>> 2. I can't find any option in bdist_egg to actually compile the files
>>    in optimized mode, is it not there on purpose??
>> You have to do "setup.py build_py -O1 bdist_egg"  (or -O2 if you prefer).
>  Doing this will include the .pyo files *in addition* to the .pyc files.
Only because --compile is the default; passing “--no-compile -01” will
disable pyc and enable pyo.

Regards
_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig