Hi, Currently python-updater lacks the ability to detect certain packages that create .py[co] files through python_mod_compile() or python_mod_optimize(). These packages can be problematic after a python upgrade, generally creating access violations. Bug #126799 exemplifies this. With that in mind, I made a patch to make python-updater detect packages with leftover binaries created by python.eclass. It works by checking that the python "magic" string in such binaries is the same as the magic string from the current python. Side note: In addition to python and some common utilities (sed, grep, awk), this patch uses 'od', which I guess should be available on any system, but I mention it in case anyone on a BSD system cares to verify that this works, and if maybe it implies a new dependency for python-updater. Thanks.
Created attachment 130785 [details, diff] python-updater-leftover_compiled_files.patch
I don't see why this should be a problem of python_mod_{compile,optimize}, because nearly all python-modules call those functions (through the distutils eclass) they obviously work. And for the leftover .py files we have python_mod_cleanup, so I'd suppose look for a reason why there are left over .pyc files.
(In reply to comment #2) > I don't see why this should be a problem of python_mod_{compile,optimize}, I'm not sure what you understand by the "problem" here, but it seems it's not the same thing I tried to describe. The python_mod_{compile|optimize|cleanup} functions are fine, the ebuilds that use them are fine as well. The problem is that after upgrading python on a system, our recommendation is for users to run python-updater to keep the system sane, but one problem that python-updater doesn't handle is that some packages install .py[co] files (using the eclass, and not necessarily under /usr/lib*/python*) which are left broken after a python upgrade. gnome-doc-utils is one package that does this, for example. Then, I guess by some auto-magic process handled by python, when a module is imported, the .pyc files are re-generated if they are from an old python and the corresponding .py is found. This can happen when emerge is installing a package that depends on another package that hasn't been cleaned by python-updater. For example many gnome packages depend on gnome-doc-utils and users ofter run into this scenario, where emerge fails because of an access violation (python tries to re-generate the .pyc files on the root filesystem). Please let me know if I'm not making myself clear, or if there's a better solution than extending python-updater to prevent the access violations. Thanks.
I don't understand how pyc files would be left behind here, unless the ebuild fails to run python_mod_cleanup. If the ebuild installs python modules without calling python_mod_optimize, that should be fixed in the ebuild.