Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perform file move of pythonservice.exe during install #2251

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading