[issue22730] ensurepip should work with pythonw.exe
New submission from Steve Dower: I'd like to be able to run ensurepip in the 3.5 installer with pythonw.exe, to avoid having the console window appear. Unfortunately, pip requires a valid value for sys.__stdout__. This patch adds a dummy value for __stdout__ that allows pip to be installed/uninstalled with pythonw. I see no reason not to check this into default now, so just seeking a quick review from the module owners. I can also backport it to 3.4 if that's thought to be worthwhile, but I don't think the installer for 3.4 will be updated to use pythonw, so it probably doesn't matter. -- assignee: steve.dower components: Installation files: ensurepip.patch keywords: patch messages: 230032 nosy: dstufft, ncoghlan, steve.dower priority: normal severity: normal status: open title: ensurepip should work with pythonw.exe versions: Python 3.5 Added file: http://bugs.python.org/file37020/ensurepip.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Donald Stufft added the comment: This looks OK to me. I'm not a Windows person are there changes in pip that would make sense to make it work without this patch? -- nosy: +Marcus.Smith, pmoore ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Steve Dower added the comment: I think the only thing pip could do is to stop using print(), which is not a reasonable request. It may be reasonable to change pythonw to use dummy IO streams by default, but that may cause programs to print() messages expecting the user to see them. It's also likely a breaking change for many programs, so I do think handling the ensurepip case like this is best. Just realised that I probably ought to make the same fix for __stderr__, in case pip succeeds but tries to write a warning there that causes the installer to detect a failure. Assume an equivalent line of code to set stderr/__stderr__ if needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Donald Stufft added the comment: The development version of pip switches things over to using the Python logging framework instead of a homegrown one which more or less relies on print(). Probably we could detect if we don't have a stdout and just not output anything? People can pass a parameter to redirect it to a log file or whatever too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Steve Dower added the comment: That change sounds like it'll be enough, and I'd be surprised if the logging module doesn't already handle the case with no streams. (Aside: it'd be nice for ensurepip to have a log file parameter that can be passed through.) I'll hold off on merging this in now, though I'll keep it in my branch until we get a pip update. -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Paul Moore added the comment: This looks reasonable to me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22730] ensurepip should work with pythonw.exe
Paul Moore added the comment: Wait, sorry I misread the discussion (long day here). If we can do this in pip yes that would be better. It looks like we can detect when we're being run via pythonw by checking if sys.stdout is None. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22730 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com