-
Notifications
You must be signed in to change notification settings - Fork 37
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
sys.stderr is None when running generated exe in bash on Windows #168
Comments
I think this is out of date. I don't get this with the repo as at (for example) this commit. So I aim to close this, unless you can reproduce it with the latest distlib version in this repo. (You can do |
Should be fixed in 8d2acb5. |
Is this bug causing this issue? I'm getting the exact same thing, a |
Confirmed, a change since 0.3.3 is causing this issue. I resolve it by replacing the binaries in my global python with the ones from the 0.3.3 version:
Repro steps to this issue can be found here:
This is the possible culprit: static BOOL
make_handle_inheritable(HANDLE handle)
{
DWORD file_type = GetFileType(handle);
// Ignore an invalid handle, non-file object type, unsupported file type,
// or a console file prior to Windows 8.
if (file_type == FILE_TYPE_UNKNOWN ||
(file_type == FILE_TYPE_CHAR && ((ULONG_PTR)handle & 3))) {
return TRUE;
}
return SetHandleInformation(handle, HANDLE_FLAG_INHERIT,
HANDLE_FLAG_INHERIT);
} 8d2acb5#diff-e2ab17b255bd58eedd164c4013e70168ee5441e9a93ca15a09baa2d6d912d9c0R530 I suspect that what is happening is that the |
Unless something has changed recently, git-bash runs bash attached to a mintty terminal that uses named pipes for I/O, with the file type I was unable to reproduce CPython issue 99937 using git-bash and Python 3.10.8, so I still don't have anything reproducible that I can dig into. Whatever is causing the problem, my guess is that it's ultimately due to the fact that bash spawns a process using the same handle value for Footnotes
|
It's not that |
Can someone point me to build instructions for distlib? I'm a C++ and python programmer but have never built a python+cpp project before. I'm going to take a stab and figure out what's causing this. |
Thanks. |
It may be something unusual in your configuration, or perhaps mine, but the combination of mintty, bash, Python 3.10.8, and pip 22.2.2 (distlib 0.3.5) work fine for me. |
You should be able to use a newer version of Visual Studio. For example, I built the ARM version using VS 2019. I stick with VS2010 because for some reason the executables built with VS2019 are a lot larger. |
Okay that built. It creates an output like CLISimpleLauncher.exe. Do I rename this to t64..exe ? |
If you do a Release batch build, it should create with those names. |
Thanks, that worked. I changed build.cmd to use visual studio 19 and it just builds. |
Now I can't reproduce the issue after I did a fresh reinstall (and removal of all the files) of python 3.10.8 |
As it happens, the C runtime's |
Describe the bug
On Windows using distlib version 0.3.4 and using a bash terminal, when I run an exe file generated by distlib,
sys.stderr
is set toNone
. Running the same exe from cmd or powershell works as expected. Generating the exe with distlib0.3.3
also works as expected.This was first reported in IPython ipython/ipython#13509. IPython works fine when running
python -m IPython
or when runningipython.exe
from other shells like cmd or powershell. This was later fixed because pip downgraded distlib here but I thought to report it here for visibility.I'm including a small example that prints sys.stdout and sys.stderr for comparison.
To Reproduce
Steps to reproduce the behavior:
python -m venv .venv
source .venv/Scripts/activate
python -m pip install distlib==0.3.4
python make.py
to create an executable calledfoo.exe
PYTHONPATH=. ./foo.exe
It prints this:cmd /V /C "set "PYTHONPATH=." && foo.exe"
powershell -Command { $env:PYTHONPATH="."; .\foo.exe }
Expected behavior
It should print this:
Environment
4.4.23(2)-release (x86_64-pc-msys)
that comes bundled with git for windows0.3.4
Additional information
This problem doesn't happen with distlib version
0.3.3
The text was updated successfully, but these errors were encountered: