File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1515import sys
1616import sysconfig
1717import tempfile
18+ import uuid
1819
1920MOVEFILE_DELAY_UNTIL_REBOOT = 4
2021
@@ -472,8 +473,12 @@ def run_rebuild():
472473 tmp = tempfile .NamedTemporaryFile (delete = False )
473474 tmp .close ()
474475 os .unlink (tmp .name )
475- shutil .move (sys .executable , tmp .name )
476- ctypes .windll .kernel32 .MoveFileExW (tmp .name , None , MOVEFILE_DELAY_UNTIL_REBOOT )
476+ temp_path = tmp .name
477+ if os .path .splitdrive (temp_path )[0 ] == os .path .splitdrive (sys .executable )[0 ]:
478+ shutil .move (sys .executable , temp_path )
479+ else :
480+ shutil .move (sys .executable , sys .executable + uuid .uuid4 ().hex + ".old" )
481+ ctypes .windll .kernel32 .MoveFileExW (temp_path , None , MOVEFILE_DELAY_UNTIL_REBOOT )
477482
478483 shutil .move (os .path .join (build_dir , "python.exe" ), interpreter_path )
479484 elif platform .system () == "Linux" :
You can’t perform that action at this time.
0 commit comments