Use a lock file to prevent problems from multiple processes using the same cache dir
BUG: do not overwrite .so files -- unlink first

If another process has started to import the .so while while it is being
overwritten, it may end up with garbage.

So, it's better to unlink first so that at least on unixes existing open
files are unaffected.

(Bug observed on MPI)