[Fedora-packaging] To .pyo or not to .pyo?

Jeff Pitman symbiont at berlios.de
Thu Aug 11 17:20:00 UTC 2005


On Thursday 11 August 2005 10:29, Orion Poplawski wrote:
> I'm a python neophyte, but I've been packaging some python packages
> and have questions about .pyo files.  I've gotten various feedback
> about including them, not including them, and using %ghost on them.
>  Can someone please explain what the issues are (both with arch and
> noarch packages)?  Also, what does %ghost do?

Arch/Noarch, it's the same.  The issues have to do with whether they 
provide the bang vs. buck (buck being diskspace in this case) that 
you'd want.  I think fedora-extras in general goes with the %ghost 
method because it was deemed that they don't.

%ghost deletes those files upon package removal.  The reason you want 
%ghost is because if you run a python script that starts with:

#!/usr/bin/python -O

or

# python -O /usr/share/script/main.py

Then .pyo files will automatically litter your harddrive.  %ghost will 
clean these up.

Currently, .pyo provides two optimizations:

1. (-O) some peephole bytecode optimization to improve startup.
2. (-OO) get rid of the docstrings to streamline the code.

#2 could be bad in that some testing relies on docstrings.  -OO is never 
really used in packages.

#1 -- I heard that this may be just included without -O in a future 
release. I don't know.  Depends on how pedantic the PowersThatBe want 
the bytecode to map against the code that's just been parsed/lexed.

Anyway, hope that helps.  Policy is to %ghost .pyo for add-on modules in 
extras, I believe.  (Although baseline python will always have .pyo in 
the lib directory.)

I for one, don't really care since were talking about saving kilobytes 
of diskspace...  YMMV.


-- 
-jeff




More information about the Fedora-packaging mailing list