diff --git a/upip/upip_os.py b/upip/upip_os.py index 3d1239dd..d767d481 100644 --- a/upip/upip_os.py +++ b/upip/upip_os.py @@ -1,6 +1,6 @@ import ffi import array -import struct +import ustruct as struct import upip_errno import upip_stat as stat_ import upip__libc diff --git a/upip/upip_os_path.py b/upip/upip_os_path.py index 28fb97d0..6c7783eb 100644 --- a/upip/upip_os_path.py +++ b/upip/upip_os_path.py @@ -47,3 +47,13 @@ def isdir(path): return upip_stat.S_ISDIR(mode) except OSError: return False + + +def expanduser(s): + if s == "~" or s.startswith("~/"): + h = upip_os.getenv("HOME") + return h + s[1:] + if s[0] == "~": + # Sorry folks, follow conventions + return "/home/" + s[1:] + return s