8000 pythonw.exe opens console window · Issue #284 · python-versioneer/python-versioneer · GitHub
[go: up one dir, main page]

Skip to content

pythonw.exe opens console window #284

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

Closed
CSchulzeTLK opened this issue Feb 17, 2022 · 1 comment
Closed

pythonw.exe opens console window #284

CSchulzeTLK opened this issue Feb 17, 2022 · 1 comment

Comments

@CSchulzeTLK
Copy link
Contributor

If a module using versioneer is imported from in a pythonw.exe, then a console window is visible for each call to git.exe/git.cmd. The subprocess.Popen call should set the startupinfo argument.

This code will open a console window when executed by pythonw.exe:

import subprocess
command = ['git', '--help']
subprocess.Popen(command).wait()

This code does not open a console window:

import subprocess
command = ['git', '--help']
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.Popen(command, startupinfo=startupinfo).wait()

subprocess.STARTUPINFO is only available on windows.

@effigies
Copy link
Contributor

Would you be interested in submitting a PR to use this? I think inserting a kwarg is probably the cleanest way.

kwargs = {}
if windows:
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    kwargs["startupinfo"] = startupinfo
subprocess.Popen(command, **kwargs).wait()

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
0