On Mon, 2003-08-11 at 22:03, Matthias Urlichs wrote: > Hi, Josselin Mouette wrote: > > > Hrm, this could be achieved quite simply, /methinks. It needs little > > changes in dh_python and some prerm/postinst stuff in the python package > > (not the pythonX.Y package) to rebuild all .pyc's and .pyo's in this > > directory upon upgrade. > > > > Matthias, do you think it is feasible ? > > Would work for me. /usr/lib/site-python is supposed to have "clean" python > scripts only, so running compileall.py on all subdirectories thereof > should pose no problem.
The problem I have with it is it doesn't take into account programs with python modules outside /usr/lib/site-python. Probably mailman is the prime example. Currently packages with python modules are responsible for compiling and removing their own pyc's and pyo's. Having the python package "take over" and re-compile them might be risky. I personally favour having the python package identify all packages that depend on "python" and getting them to do the recompilation by re-configuring them. This will work for packages that install *.py's anywhere. The python package should do the same on removal, so packages that have things like "Depends: python | python2.1" can recompile themselves with python2.1 if "python" disappears. The pythonX.Y packages should do the same to "notify" packages that optionally depend/support them that the pythonX.Y packages have been installed/removed. I know this is more complicated, but if we don't do this, we end up with yet another half-solution, where version independent packages are only supported if they put their modules in /usr/lib/site-python, and only for multiple versions of "python", not "pythonX.Y". The following is a code fragment for identifying all the installed packages to be "notified" on install/remove of any python or pythonX.Y package # get_dependants <package> # echo to stdout installed packages that depend on the specified package # in any way. get_dependants () { PYTHONXY=$1 QUERYFORMAT='${Status}:${Package}:${Depends}\n' dpkg-query --show-format=$QUERYFORMAT -W | \ egrep "^install ok installed:[^:]*:.*$PYTHONXY([ ,]|$)" | \ cut -f 2 -d':' } Using this the python package can "notify" all packages that depend on it by calling dpkg-reconfigure on them; for p in `get_dependants python`; do dpkg-reconfigure --priority=critical $p done This assumes packages will compile their own *.py's using a suitable python when they are "dpkg-reconfigured". Note this means packages that have things like "Depends: python (<<2.3) | python2.2" can choose to fall-back to compiling with python2.2 when python (2.3) is installed. I'm not sure if dpkg-reconfigure only does stuff for packages that use debconf. If it does, than an alternative would be to call "/var/lib/dpkg/info/$p.postinst configure" directly. -- Donovan Baarda <[EMAIL PROTECTED]> http://minkirri.apana.org.au/~abo/