提交 88002fc2 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Prevent the home dir from being a tilde when expanduser fails, which is…

Prevent the home dir from being a tilde when expanduser fails, which is apparently possible on some systems
上级 5ae2a05f
...@@ -102,11 +102,23 @@ AddConfigVar('on_opt_error', ...@@ -102,11 +102,23 @@ AddConfigVar('on_opt_error',
EnumStr('warn', 'raise'), EnumStr('warn', 'raise'),
in_c_key=False) in_c_key=False)
def get_home_dir():
home = os.getenv('HOME')
if home is None:
# This expanduser usually works on Windows (see discussion on
# theano-users, July 13 2010).
home = os.path.expanduser('~')
if home == '~':
# This might happen when expanduser fails. Although the cause of
# failure is a mystery, it has been seen on some Windows system.
home = os.getenv('USERPROFILE')
assert home is not None
return home
AddConfigVar('home', AddConfigVar('home',
"User home directory", "User home directory",
StrParam(os.getenv("HOME", os.path.expanduser('~'))), StrParam(get_home_dir()),
in_c_key=False) in_c_key=False)
#This expanduser works on windows (see discussion on theano-users, July 13 2010)
AddConfigVar('nocleanup', AddConfigVar('nocleanup',
"Suppress the deletion of code files that did not compile cleanly", "Suppress the deletion of code files that did not compile cleanly",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论