提交 243d7434 authored 作者: ruslanagit's avatar ruslanagit

Support spaces in paths

Make theano support programs and packages installed under paths which include spaces (such as 'Program Files')
上级 e4e08782
......@@ -435,7 +435,7 @@ AddConfigVar('cxx',
" supported, but supporting additional compilers should not be "
"too difficult. "
"If it is empty, no C++ code is compiled.",
StrParam(param),
StrParam('"%s"' % param),
in_c_key=False)
del param
......@@ -1168,7 +1168,7 @@ def default_blas_ldflags():
use_unix_epd = True
if sys.platform == 'win32':
return ' '.join(
['-L%s' % os.path.join(sys.prefix, "Scripts")] +
['-L"%s"' % os.path.join(sys.prefix, "Scripts")] +
# Why on Windows, the library used are not the
# same as what is in
# blas_info['libraries']?
......@@ -1201,7 +1201,7 @@ def default_blas_ldflags():
use_unix_epd = False
if use_unix_epd:
return ' '.join(
['-L%s' % os.path.join(sys.prefix, "lib")] +
['-L"%s"' % os.path.join(sys.prefix, "lib")] +
['-l%s' % l for l in blas_info['libraries']])
# Canopy
......@@ -1234,11 +1234,11 @@ def default_blas_ldflags():
if sys.platform == "linux2" or sys.platform == "darwin":
return ' '.join(
['-L%s' % lib_path] +
['-L"%s"' % lib_path] +
['-l%s' % l for l in blas_info['libraries']])
elif sys.platform == 'win32':
return ' '.join(
['-L%s' % lib_path] +
['-L"%s"' % lib_path] +
# Why on Windows, the library used are not the
# same as what is in blas_info['libraries']?
['-l%s' % l for l in ["mk2_core", "mk2_intel_thread",
......@@ -1259,7 +1259,7 @@ def default_blas_ldflags():
else:
# This branch is executed if no exception was raised
lib_path = os.path.join(sys.prefix, 'DLLs')
flags = ['-L%s' % lib_path]
flags = ['-L"%s"' % lib_path]
flags += ['-l%s' % l for l in ["mkl_core",
"mkl_intel_thread",
"mkl_rt"]]
......@@ -1334,7 +1334,9 @@ def try_blas_flag(flags):
return 0;
}
""")
cflags = flags + ['-L' + d for d in theano.gof.cmodule.std_lib_dirs()]
cflags = flags
cflags.extend(['-L"%s"' % d for d in theano.gof.cmodule.std_lib_dirs()])
res = GCC_compiler.try_compile_tmp(
test_code, tmp_prefix='try_blas_',
flags=cflags, try_run=True)
......
......@@ -2251,7 +2251,7 @@ class GCC_compiler(Compiler):
cmd.extend(p for p in preargs if not p.startswith('-O'))
else:
cmd.extend(preargs)
cmd.extend('-I%s' % idir for idir in include_dirs)
cmd.extend('-I"%s"' % idir for idir in include_dirs)
if hide_symbols and sys.platform != 'win32':
# This has been available since gcc 4.0 so we suppose it
# is always available. We pass it here since it
......@@ -2262,7 +2262,7 @@ class GCC_compiler(Compiler):
cmd.append('-fvisibility=hidden')
cmd.extend(['-o', lib_filename])
cmd.append(cppfilename)
cmd.extend(['-L%s' % ldir for ldir in lib_dirs])
cmd.extend(['-L"%s"' % ldir for ldir in lib_dirs])
cmd.extend(['-l%s' % l for l in libs])
# print >> sys.stderr, 'COMPILING W CMD', cmd
_logger.debug('Running cmd: %s', ' '.join(cmd))
......
......@@ -24,6 +24,13 @@ def subprocess_Popen(command, **params):
# execute "g++" without extensions.
# (Executing "g++.bat" explicitly would also work.)
params['shell'] = True
# "If shell is True, it is recommended to pass args as a string rather than as a sequence." (cite taken from https://docs.python.org/2/library/subprocess.html#frequently-used-arguments)
# In case when command arguments have spaces, passing a command as a list will result in incorrect arguments break down, and consequently
# in "The filename, directory name, or volume label syntax is incorrect" error message.
# Passing the command as a single string solves this problem.
if isinstance(command, list):
command = ' '.join(command)
# Using the dummy file descriptors below is a workaround for a
# crash experienced in an unusual Python 2.4.4 Windows environment
......
......@@ -296,11 +296,12 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
return 1;
}
"""
params = ["-l", "cudnn", "-I" + os.path.dirname(__file__)]
params = ["-l", "cudnn"]
params.extend(['-I"%s"' % os.path.dirname(__file__)])
if config.dnn.include_path:
params.append("-I" + config.dnn.include_path)
params.extend(['-I"%s"' % config.dnn.include_path])
if config.dnn.library_path:
params.append("-L" + config.dnn.library_path)
params.extend(['-L"%s"' % config.dnn.library_path])
if config.nvcc.compiler_bindir:
params.extend(['--compiler-bindir',
config.nvcc.compiler_bindir])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论