Skip to content

Commit

Permalink
Perform file move of pythonservice.exe during install (#2251)
Browse files Browse the repository at this point in the history
During service install perform file move of pythonservice.exe if file exists at src

Co-authored-by: Jacob Nolan <jacobnolan@gtslaptop03.gts.xyz>
  • Loading branch information
JacobNolan1 and Jacob Nolan committed Aug 6, 2024
1 parent 377a3ef commit a83b36c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions win32/Lib/win32serviceutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ def LocatePythonServiceExe(exe=None):
# pywin32 installed it next to win32service.pyd (but we can't run it from there)
maybe = os.path.join(os.path.dirname(win32service.__file__), exe)
if os.path.exists(maybe):
print(f"copying host exe '{maybe}' -> '{correct}'")
win32api.CopyFile(maybe, correct)
print(f"moving host exe '{maybe}' -> '{correct}'")
# Handle case where MoveFile() fails. Particularly if destination file
# has a resource lock and can't be replaced by src file
try:
win32api.MoveFileEx(maybe, correct, win32con.MOVEFILE_REPLACE_EXISTING)
except win32api.error as exc:
print(f"Failed to move host exe '{exc}'")

if not os.path.exists(correct):
raise error(f"Can't find '{correct}'")
Expand Down

0 comments on commit a83b36c

Please sign in to comment.