bootstrap: our best to achieve atomic rename on Win32

This is a tricky operation to implement on Win32; see
https://ci.appveyor.com/project/nodakai/python-win-behavior

Signed-off-by: NODA, Kai <nodakai@gmail.com>
This commit is contained in:
NODA, Kai
2018-06-27 03:23:14 +08:00
parent bcb8a06ef7
commit 97d0bc3f04
+6 -1
View File
@@ -308,7 +308,12 @@ def output(filepath):
tmp = filepath + '.tmp'
with open(tmp, 'w') as f:
yield f
os.rename(tmp, filepath)
try:
os.remove(filepath) # PermissionError/OSError on Win32 if in use
os.rename(tmp, filepath)
except OSError:
shutil.copy2(tmp, filepath)
os.remove(tmp)
class RustBuild(object):