When inside msys2-Python (3.4.3), how am I supposed to get the native windows path of some file from the msys-filesystem?
I want to write a configuration file for a native windows application so the msys path rewriting does not come into account.
There is a solution, but I don't like it, because I have to feed an unknown path into a shell:
path = "/home/user/workspace"
output = subprocess.check_output( 'cmd //c echo ' + path, shell = True )
This returns C:/msys64/home/user/workspace
.
This question is not really a duplicate of Convert POSIX->WIN path, in Cygwin Python, w/o calling cygpath because it is about msys2.
MSYS2 comes with a utility named
cygpath
that you can use. Runcygpath -w NAME
.cygpath
is a command-line utility in/usr/bin
that you can run the same way you would run any other command-line utility. The output will be a Windows-style path corresponding to the NAME argument you passed.