[Distutils] bdist_egg and pyo files

Éric Araujo merwok at netwok.org
Thu Mar 29 05:28:48 CEST 2012

Le 28/03/2012 15:56, PJ Eby a écrit :
> On Wed, Mar 28, 2012 at 12:41 PM, Andrea Crotti
> <andrea.crotti.0 at gmail.com>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.


More information about the Distutils-SIG mailing list