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

Conversation

JacobNolan1
Copy link
Contributor

During install perform move of pythonservice.exe instead of file copy to handle .exe always being present in src location.

Additional try-except added to handle continuation of program if fileMove fails.

@JacobNolan1
Copy link
Contributor Author

Attempted a build to test this, but wasn't successful. Was missing a couple dlls and haven't managed to track down why I don't have them yet.

@mhammond
Copy link
Owner

Thanks - note if you go to "checks" and dig around you can find artifacts for your PR - in this case it is at https://github.com/mhammond/pywin32/actions/runs/8890105083?pr=2251

@JacobNolan1
Copy link
Contributor Author

Awesome thanks Mark. This sorted my issue. I may change the exception output "Failed to move host exe" in the case where the file already exists, it did deceive me for a moment there thinking the process failed completely.

The current error output from MoveFile is "Cannot create a file when file already exists". So I think in this case, where the destination file is still used, MoveFile does fail to replace. Which makes sense.

The install does work regardless if pythonservice.exe is present in the destination dir.

@mhammond
Copy link
Owner

mhammond commented May 2, 2024

It's important that the move replace the file - if the source file exists it implies pywin32 has been upgraded so the existing target may not work. MoveFileEx should offer the semantics you needs.

win32/Lib/win32serviceutil.py Outdated Show resolved Hide resolved
JacobNolan1 and others added 2 commits August 6, 2024 12:15
… exists at src

During install perform move of pythonservice.exe instead of file copy to handle .exe always being present in src location. 

Additional try-except added to handle continuation of program if fileMove fails.
@mhammond mhammond merged commit a83b36c into mhammond:main Aug 6, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants