[Python-Dev] Mysterious Python pyc file corruption problems
dmalcolm at redhat.com
Fri May 17 21:38:46 CEST 2013
On Fri, 2013-05-17 at 14:23 -0400, Barry Warsaw wrote:
> On May 17, 2013, at 01:19 PM, David Malcolm wrote:
> >Fedora/RH pregenerate the .pyc files during rpm creation, and they exist
> >as part of the rpm payload.
> Good to know, thanks. Do you use `$PYTHON -m py_compile` to generate the pyc
> files at build time?
We use compileall.compiledir() most of the time, but occasionally use
Specifically, for python 2, the core rpm-build package has a script:
run automatically in a postprocessing phase after the upstream source
has installed to a DESTDIR, and this invokes compileall.compiledir() on
all .py files in the package payload, with various logic to segment the
different parts of the filesystem to be bytecompiled by the appropriate
python binary (since we have duplicate .py files for different python
runtimes). This is all done sequentially, so I'd be surprised if
different pythons splatted on each other's .pyc files at this time.
In addition, python3-devel contains a:
which defines a py_byte_compile() macro, which can be used for
overriding these rules (IIRC), and this does use pycompile.compile()
Hope this is helpful
More information about the Python-Dev