Skip to content

Commit

Permalink
bootstrap: our best to achieve atomic rename on Win32
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
nodakai committed Jul 10, 2018
1 parent bcb8a06 commit 97d0bc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 97d0bc3

Please sign in to comment.