提交 31e9ab5d authored 作者: James Bergstra's avatar James Bergstra

autogenerate compile directory from THEANO_COMPILEDIR

上级 edad54d2
...@@ -21,7 +21,7 @@ import utils ...@@ -21,7 +21,7 @@ import utils
def compile_dir(): def compile_dir():
"""Return the directory in which scipy.weave should store code objects. """Return the directory (name) in which scipy.weave should store code objects.
If the environment variable THEANO_COMPILEDIR is set, its value is returned. If the environment variable THEANO_COMPILEDIR is set, its value is returned.
If not, a directory of the form $HOME/.theano/compiledir_<platform Id>. If not, a directory of the form $HOME/.theano/compiledir_<platform Id>.
...@@ -29,11 +29,11 @@ def compile_dir(): ...@@ -29,11 +29,11 @@ def compile_dir():
As a test, this function touches the file __init__.py in the returned As a test, this function touches the file __init__.py in the returned
directory, and raises OSError if there's a problem. directory, and raises OSError if there's a problem.
A directory coming from THEANO_COMPILEDIR is not created automatically, but The returned directory is created automatically using os.makedirs.
a directory in $HOME/.theano is created automatically.
This directory is appended to the sys.path search path before being This directory is appended to the sys.path search path before being
returned, if the touch was successful. returned, if the touch was successful.
""" """
if os.getenv('THEANO_COMPILEDIR'): if os.getenv('THEANO_COMPILEDIR'):
cachedir = os.getenv('THEANO_COMPILEDIR') cachedir = os.getenv('THEANO_COMPILEDIR')
...@@ -44,8 +44,7 @@ def compile_dir(): ...@@ -44,8 +44,7 @@ def compile_dir():
platform_id = re.sub("[\(\)\s]+", "_", platform_id) platform_id = re.sub("[\(\)\s]+", "_", platform_id)
cachedir = os.path.join(os.getenv('HOME'), '.theano', 'compiledir_'+platform_id) cachedir = os.path.join(os.getenv('HOME'), '.theano', 'compiledir_'+platform_id)
if not os.access(cachedir, os.R_OK | os.W_OK): if not os.access(cachedir, os.R_OK | os.W_OK):
#this may raise a number of problems, I think all of which are serious. os.makedirs(cachedir, 7<<6) #read-write-execute for this user only
os.makedirs(cachedir, 7<<6)
cachedir_init = cachedir+'/__init__.py' cachedir_init = cachedir+'/__init__.py'
touch = os.system('touch '+cachedir_init) touch = os.system('touch '+cachedir_init)
if touch: if touch:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论