[Python-Dev] "Some" .pyc files not ending up in __pycache__ during installation

Nick Coghlan ncoghlan at gmail.com
Sat Feb 19 14:07:17 CET 2011


On Sat, Feb 19, 2011 at 10:37 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> What I think is happening here, is that the normal import mechanism byte
> compiles the 2to3 converted sources into the __pycache__ directory (when
> invoked at extension building time), but then distutils' byte compilation
> seems to decide that it's better to keep the .pyc files where the sources
> are. And thus a mix of both ends up in the installation.
>
> Wouldn't it be better to let distutils *always* byte-compile the .py files
> into the appropriate __pycache__ directory, just like the import mechanism
> does? Or is there something else broken here?

A quick look [1] suggests that distutils.util.bytes_compile is indeed
second-guessing py_compile.compile and forcing use of the legacy .pyc
location rather than accepting the default location. (Why? I have no
idea, it's distutils...)

While this is definitely untidy, it doesn't strike me as a release
blocker. More of a "fix it in 3.2.1", since the status quo will
*work*, it just means the precompiled file will be ignored on first
execution with newer Python versions.

Cheers,
Nick.

[1] http://svn.python.org/view/python/branches/py3k/Lib/distutils/util.py?view=markup


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list