def _get_build_prefix():
""" Returns a safe build_prefix """
path = os.path.join(tempfile.gettempdir(), 'pip-build-%s' % \
getpass.getuser())
if sys.platform == 'win32':
""" on windows(tested on 7) temp dirs are isolated """
return path
try:
os.mkdir(path)
except OSError:
file_uid = None
try:
fd = os.open(path, os.O_RDONLY | os.O_NOFOLLOW)
file_uid = os.fstat(fd).st_uid
os.close(fd)
except OSError:
file_uid = None
if file_uid != os.getuid():
msg = "The temporary folder for building (%s) is not owned by your user!" \
% path
print (msg)
print("pip will not work until the temporary folder is " + \
"either deleted or owned by your user account.")
raise pip.exceptions.InstallationError(msg)
return path
评论列表
文章目录