8000 ENH, DOC: Build notes and fixes for Cygwin. by DWesl · Pull Request #18308 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH, DOC: Build notes and fixes for Cygwin. #18308

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BLD: Change cyg2win32 to use the cygpath utility.
The old function only handled the default `/cygdrive` prefix.  This
can be customized to different values: `/` and `/mnt` are both common.
`/proc/cygdrive` does the same thing, regardless of user customization.

`cygpath` handles all of these.  There's also a C function if you'd
prefer to avoid the `fork()` call, which tends to be slow on Cygwin.

Edit: Fix the cyg2win32 function to have correct types.

It returned bytes earlier; this should return a string.

Edit: Fix docsrting to follow numpydoc.
  • Loading branch information
DWesl committed Jul 21, 2021
commit e30548dce7b35e6ee06555d5894722d42bba6a0d
37 changes: 34 additions & 3 deletions numpy/distutils/misc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,40 @@ def blue_text(s):
#########################

def cyg2win32(path):
if sys.platform=='cygwin' and path.startswith('/cygdrive'):
path = path[10] + ':' + os.path.normcase(path[11:])
return path
"""Convert a path from Cygwin-native to Windows-native.

Uses the builting cygpath script to do the actual conversion.
Falls back to returning the original path if this fails.

Handles the default "/cygdrive" prefix as well as "/proc/cygdrive"
portable prefix and custom cygdrive prefixes such as "/" or "/mnt".

Parameters
----------
path : str
The path to convert

Returns
-------
converted_path : str
The converted path

Notes
-----
Documentation for cygpath utility:
https://cygwin.com/cygwin-ug-net/cygpath.html
Documentation for the C function it wraps:
https://cygwin.com/cygwin-api/func-cygwin-conv-path.html

"""
if sys.platform != "cygwin":
return path
try:
return subprocess.check_output(
["/usr/bin/cygpath", "--windows", path], universal_newlines=True
)
except subprocess.CalledProcessError:
return path

def mingw32():
"""Return true when using mingw32 environment.
Expand Down
0