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

pywin32_postinstall wrongly identifies a debug build #2206

Closed
saevus1991 opened this issue Mar 14, 2024 · 1 comment
Closed

pywin32_postinstall wrongly identifies a debug build #2206

saevus1991 opened this issue Mar 14, 2024 · 1 comment

Comments

@saevus1991
Copy link

I was setting up a simple test project to play with python windows services with virtual environment based on this tutorial https://oxylabs.io/blog/python-script-service-guide . While running pywin32_postinstall I got the following error:

RuntimeError: Can not locate the program 'pythonw_d.exe'

It seems that a python debug build was identified even though I used a regular python build. After some digging, I located the issue in the _find_localserver_exe function in the win32com.server.register module. At the beginning of the file, the base .exe is identfied as

def _find_localserver_exe(mustfind):
    if not sys.platform.startswith("win32"):
        return sys.executable
    if pythoncom.__file__.find("_d") < 0:
        exeBaseName = "pythonw.exe"
    else:
        exeBaseName = "pythonw_d.exe"
    ...

pythoncom.file.find("_d") returns the full path. In my case, the project folder containing the virtual environment is named c:/Code/python_windows_service_demo so the "_d" produced a match. This should be easily fixable by only checking the filename instead of the full path, e.g.

if os.path.basename(pythoncom.__file__).find("_d") < 0:

Python: 3.12.2
PyWin32: 306
Steps to reproduce: Follow the tutorial but place your virtual environment in a dir that has "_d" somewhere in its path.

@Avasam
Copy link
Collaborator

Avasam commented Mar 14, 2024

Same as #1949 , fixed by #2169 . Will be included in next release.

@Avasam Avasam closed this as completed Mar 14, 2024
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

No branches or pull requests

2 participants