File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -376,10 +376,42 @@ def blue_text(s):
376376
377377#########################
378378
379- def cyg2win32 (path ):
380- if sys .platform == 'cygwin' and path .startswith ('/cygdrive' ):
381- path = path [10 ] + ':' + os .path .normcase (path [11 :])
382- return path
379+ def cyg2win32 (path : str ) -> str :
380+ """Convert a path from Cygwin-native to Windows-native.
381+
382+ Uses the cygpath utility (part of the Base install) to do the
383+ actual conversion. Falls back to returning the original path if
384+ this fails.
385+
386+ Handles the default ``/cygdrive`` mount prefix as well as the
387+ ``/proc/cygdrive`` portable prefix, custom cygdrive prefixes such
388+ as ``/`` or ``/mnt``, and absolute paths such as ``/usr/src/`` or
389+ ``/home/username``
390+
391+ Parameters
392+ ----------
393+ path : str
394+ The path to convert
395+
396+ Returns
397+ -------
398+ converted_path : str
399+ The converted path
400+
401+ Notes
402+ -----
403+ Documentation for cygpath utility:
404+ https://cygwin.com/cygwin-ug-net/cygpath.html
405+ Documentation for the C function it wraps:
406+ https://cygwin.com/cygwin-api/func-cygwin-conv-path.html
407+
408+ """
409+ if sys .platform != "cygwin" :
410+ return path
411+ return subprocess .check_output (
412+ ["/usr/bin/cygpath" , "--windows" , path ], universal_newlines = True
413+ )
414+
383415
384416def mingw32 ():
385417 """Return true when using mingw32 environment.
You can’t perform that action at this time.
0 commit comments