This I've seen before... Subversion makes various files inside a working copy read-only, and shutil.rmtree on Windows won't remove read-only files, and hence directories will not be empty when expected to.
I've got some utility code for another project that wraps rmtree, and if OS is Windows it walks all files and turns off read-only before removing:
import shutil, os
def rmtree(path, *args, **kwargs):
if os.name == 'nt':
for (dirpath, dirnames, filenames) in os.walk(path):
# Windows does not allow remove of read-only files
for filename in filenames:
os.chmod(os.path.join(dirpath, filename),
stat.S_IWRITE)
shutil.rmtree(path, *args, **kwargs)
I'll see if I can make a patch to actually test this.