sthen@ finally figured out most of the problem. Turns out python is stupid enough to store path+timestamp in its compiled *.pyc files to know when to recompile.
Our package system doesn't look to closely at timestamps... so this explains how *.pyc files sometimes get rebuilt, and then throw errors during pkg_delete. The following patch is a work-around for the issue. It removes the possibility to tie python files (recognize identical files and not re-extract them), thus preserving the timestamps more (and making python packages more painful to extract). Note that this is actually a large problem. There is work being done on speeding up updates, and if we have to store/restore timestamps along with other stuff, this has a cost (more code and bigger packages) ! so it would be WAYS better if python did stop doing that, which probably requires working with upstream to make them aware of the issue. In the meantime, people experiencing python-package deleting issues should use the following patch. It's a large sledge-hammer, but it should make the problem disappear, and it will probably be committed soon... Index: OpenBSD/PkgAdd.pm =================================================================== RCS file: /home/openbsd/cvs/src/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm,v retrieving revision 1.34 diff -u -p -r1.34 PkgAdd.pm --- OpenBSD/PkgAdd.pm 28 Apr 2012 12:00:10 -0000 1.34 +++ OpenBSD/PkgAdd.pm 2 Nov 2012 12:12:56 -0000 @@ -84,6 +84,8 @@ sub tie_files { my ($self, $sha, $state) = @_; return if $self->{link} or $self->{symlink} or $self->{nochecksum}; + # XXX python doesn't like this, overreliance on timestamps + return if $self->{name} =~ m/\.py$/; if (defined $sha->{$self->{d}->key}) { my $tied = $sha->{$self->{d}->key}; # don't tie if there's a problem with the file