[Distutils] bdist_egg and pyo files

4 views
Skip to first unread message

Andrea Crotti

unread,
Mar 28, 2012, 12:41:56 PM3/28/12
to distut...@python.org
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 - Distut...@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

PJ Eby

unread,
Mar 28, 2012, 3:56:24 PM3/28/12
to Andrea Crotti, distut...@python.org
On Wed, Mar 28, 2012 at 12:41 PM, Andrea Crotti <andrea....@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?
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. 

Éric Araujo

unread,
Mar 28, 2012, 11:28:48 PM3/28/12
to distut...@python.org
Le 28/03/2012 15:56, PJ Eby a écrit :
> On Wed, Mar 28, 2012 at 12:41 PM, Andrea Crotti
> <andrea....@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.

Regards

Reply all
Reply to author
Forward
0 new messages