-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
stderr duplication failed in console scripts #10875
Comments
/cc @vsajip, since they're the expert here. :) |
x-ref #10874, which also seems like something that's related to the Windows launchers. |
The following Java code calling package com.example.testScript;
import java.io.IOException;
public class TestScript {
public static void main(String[] args) throws IOException, InterruptedException {
String cmd = "test-script.exe";
ProcessBuilder pb = new ProcessBuilder().command(cmd);
// This is apparently exposing the issue
pb.redirectErrorStream(true);
Process iostat = pb.inheritIO().start();
int exitCode = iostat.waitFor();
System.out.println("exitCode = " + exitCode);
}
} |
@vsajip can you please have a look at this distlib regression? Switching the distlib binaries back to 0.3.3 (from pip 21.x) or moving back to pip 21.x is not showing the issue. In the affected effected environment this is a major issue. thank you |
Right now I can only recommend to install an older pip version on Windows: |
@pierreluctg I'm aware of this issue, but I probably won't have the bandwidth to spend much (if any) time on it until the last week of March 2022, due to other commitments 😞 |
Thank you @vsajip for the update. Is there any additional information that you need from us in the meantime to help you fix the issue when you will have free time? |
Right now my solution is to install an older pip version on Windows: |
Is this bad enough to justify a bug fix release? |
I have started running my console scripts with Python to get around this for now $ python -m pytest |
Does the problem occur for GUI scripts as well as console scripts? (Might be harder to ascertain, as there's no console to display diagnostic output). Other than that, no other things I can think of. |
For meson as an example, it is enough to run the following? or should it be specifically installed via the
|
I reinstalled meson in excact that way. |
It doesn't seem to happen all the time. The following reproducer builds a simple console executable, and when I run that it works fine (shows stderr as a file, not as So I think someone needs to be more precise about how this issue gets triggered, before we can assess the severity of the problem. (On the other hand, if py -m venv .venv
.venv/scripts/python -m pip install -U pip setuptools wheel
mkdir test_bug
set-content test_bug/test_bug.py -encoding UTF8 @"
import sys
def main():
print(repr(sys.stdin))
print(repr(sys.stdout))
print(repr(sys.stderr))
print('Writing to stdout')
print('Writing to stderr', file=sys.stderr)
"@
set-content test_bug/setup.py -encoding UTF8 @"
from setuptools import setup
setup(
name='test_bug',
version='1.0',
py_modules=['test_bug'],
entry_points = {
'console_scripts': ['test_bug=test_bug:main'],
},
)
"@
.venv/scripts/pip install ./test_bug
.venv/scripts/test_bug.exe |
@pfmoore, I don't know how more more precise, please take a look at: #10444 (comment). Other projects now have problems with pip 22, not only meson. To be even more precise: The problem is due to the change to distlib-0.34. On windows you have to use the meson launcher, as |
@carlkl I understand what the problem is, and I understand what we'd need to do to fix it (revert to an older distlib, or wait for a distlib fix). What I don't know is how many people are affected, nor do I know whether this issue is more disruptive than the issue that the distlib upgrade fixed, or whether it will be more disruptive than the cost of making a bugfix release. The comment you linked to says it is a "severe" bug. It's not severe for me, I've never seen it happen. So if you can be more precise about what circumstances cause it to occur, that would make it easier to assess the severity in a way that doesn't just boil down to "it doesn't happen for me" vs "it happens for a program someone else uses a lot". You also say "Now 🤷 I'm not really that bothered. Ultimately someone needs to make the case that this is important enough for us to produce a bugfix release with a reverted distlib. I'm only trying to help people make that case - if they don't, then this will likely just wait for a fix in distlib, and the next pip release. |
main issue: #10444 Here is a list of affected projects I'm aware of:
As I understand, it will happen if (and only if):
IMHO it is a severe problem that will most likely hit other project sooner or later. In case it pops up you have absolutely no clue what happens. It took me hours to come to that conclusion with pip 22 and distutils. |
As I say, I can't reproduce this. If it's only about GUI executables, my view is that it's (a) not demonstrably worse than reverting, as I believe the distlib change was to fix some aspect of how GUI scripts were handled, and (b) not major, demonstrated by the fact that the original distlib issue had gone for so long without being reported. The meson case worries me more, as it seems to be related to a console script. But until someone can provide a reproducer which doesn't involve meson, I remain unconvinced it's a general issue. Note: I'm not the RM for 22.0. If @pradyunsg decides to do a bugfix release, that's fine. I'm mostly interested here as I want to improve the process whereby we gather information about post-release issues, and in particular establish a principle that we should be looking for more objective measures of the impact rather than just reacting to generalised "it's broken" messages. |
The Meson issue as reported by one of our users apparently only manifests in CI, not on local dev machines, and only happens when meson.exe's Ninja does do some playing around with file descriptors, because stdout/stderr get buffered (failing |
Turns out, pip 22.0 is the source of the breakage: mesonbuild/meson#9955 (comment) pypa/pip#10875
Turns out, pip 22.0 is the source of the breakage: mesonbuild/meson#9955 (comment) pypa/pip#10875
It is definitely not just about GUI script wrappers. |
This is good context, thanks for noting this here @eli-schwartz! I think having a visible (albeit cryptic) error that users can discover is better than a silent error that they can't. Further, CLI entry points are a lot more common than GUI entry points and I'm pretty sure the right thing to do here is to downgrade distlib to 0.3.3 until @vsajip is able able to fix this issue in distlib. I'll cut a bugfix for this. |
Hmmm. See detailed analysis of this and related problems by Michael Bikovitsky here. |
I've reopened this, for tracking the fix being released on distlib's end (since we can't update our vendored copy until distlib fixes the underlying issue). |
There have been two |
Is this issue still extant, or can it be closed? |
It works for me (just tried with pip 22.3.1)! |
No problems on Windows so far. |
Thanks @vsajip for the fixes! ^>^ |
Description
I use a
console_scripts
entry point with a test function. If I do pip install . or use setup.py to make a binary dist then install it, under some shell like Git Bash, running the createdtest-script.exe
.stdin
,stdout
andstderr
should all be set to aTextIOWrapper
however,stderr
is set toNone
.The
stderr
handle is apparently not correctly set.This is probably related to #10444 and the fix introduced in Distlib 0.3.4 for a similar issue.
Expected behavior
pip version
22.0
Python version
Python 3.7
OS
Windows
How to Reproduce
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: