-
Notifications
You must be signed in to change notification settings - Fork 180
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
Python image piping not working on MSYS2 #2960
Comments
It can be remedied temporarily by setting |
Under an MSYS2 shell, |
Hmmm so it does. I think I've gotten a couple a couple of wires crossed in my reasoning / description. There's been logic in place for quite some time to use a different default location for temporary piped files between Unix and Windows; see 9979917 & #199, though I don't think that's exhaustive regarding prior discussion on the topic. I seem to recall there was stronger reasoning at the time about preserving use of the working directory on Windows. Nevertheless that observation doesn't provides a solution to the issue at hand: passing a The image path passed down the pipe has to be absolute, as the invoked command that generates it and the command at the receiving end of the pipe have different working directories. So either:
While we could hypothetically not support this feature on Windows, and immediately report an error if the user attempts to create an output piped image from a Python command, there are Python scripts that now internally make use of Python command piping, so the source code for those commands would need to be reverted accordingly. |
My expectation is that using |
I had a little bit of a look at |
Feel free to ignore if I'm completely wide of the mark, but I had to grapple with MSYS2's internal path translation while sorting out a few issues with the |
I've already landed on using |
Issue with #2678.
When constructing the location of a piped image, on Windows the current working directory is used (assuming
TmpFileDir
is not set), given that/tmp/
does not exist. This currently yields a Posix-style path.However if the output of a Python script is piped to a C++ binary, the latter fails to locate that file, and the piped image remains on the file system. The C++ binary can be subsequently run standalone, copy-pasting that absolute path as input, and that works (presumably because the terminal emulator / shell is doing a path translation that is absent when that path is communicated via a pipe). Curiously, piping from a Python command to another Python command works.
Using an absolute path for piped images is a requirement: just specifying a file name will for most scripts result in the piped image file residing inside the scratch directory, which both by default gets deleted upon script completion and would regardless be in the wrong filesystem location for the command at the receiving end of the pipe to then resolve.
It is not a Windows line end encoding problem.
pathlib
does not appear to have the requisite conversion capabilities.If to resolve completely is going to require translation of paths to Windows format prior to sending down the pipe, I found this example, which invokes
cygwin
functionality via shared DLL; otherwise it could be custom code.Also would need to fill
app._STDOUT_IMAGES
with instances of a custom class that uses the standard Posix path f-string formatting when invoking a command to generate it but a different function to write the path tostdout
at script completion.Open to any better ideas.
The text was updated successfully, but these errors were encountered: