提交 9a0b5d36 authored 作者: ruslanagit's avatar ruslanagit

Support paths with spaces on Windows

上级 c24b9572
......@@ -430,12 +430,15 @@ if param != "":
del newp
del distutils
# to support path that includes spaces, we need to wrap it with double quotes on Windows
if param and os.name == 'nt':
param = '"%s"' % param
AddConfigVar('cxx',
"The C++ compiler to use. Currently only g++ is"
" supported, but supporting additional compilers should not be "
"too difficult. "
"If it is empty, no C++ code is compiled.",
StrParam('"%s"' % param),
StrParam(param),
in_c_key=False)
del param
......@@ -1201,7 +1204,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,7 +1237,7 @@ 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(
......@@ -1267,13 +1270,15 @@ def default_blas_ldflags():
if res:
return res
# to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name =='nt' else ""
ret = (
# TODO: the Gemm op below should separate the
# -L and -l arguments into the two callbacks
# that CLinker uses for that stuff. for now,
# we just pass the whole ldflags as the -l
# options part.
['-L%s' % l for l in blas_info.get('library_dirs', [])] +
['-L%s%s%s' % (path_wrapper,l,path_wrapper) for l in blas_info.get('library_dirs', [])] +
['-l%s' % l for l in blas_info.get('libraries', [])] +
blas_info.get('extra_link_args', []))
# For some very strange reason, we need to specify -lm twice
......@@ -1335,7 +1340,9 @@ def try_blas_flag(flags):
}
""")
cflags = flags
cflags.extend(['-L"%s"' % d for d in theano.gof.cmodule.std_lib_dirs()])
# to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name =='nt' else ""
cflags.extend(['-L%s%s%s' % (path_wrapper,d,path_wrapper) for d in theano.gof.cmodule.std_lib_dirs()])
res = GCC_compiler.try_compile_tmp(
test_code, tmp_prefix='try_blas_',
......
......@@ -2251,7 +2251,10 @@ 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)
# to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name =='nt' else ""
cmd.extend(['-I%s%s%s' % (path_wrapper,idir,path_wrapper) for idir in include_dirs])
cmd.extend(['-L%s%s%s' % (path_wrapper,ldir,path_wrapper) for ldir in lib_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 +2265,6 @@ 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' % l for l in libs])
# print >> sys.stderr, 'COMPILING W CMD', cmd
_logger.debug('Running cmd: %s', ' '.join(cmd))
......
......@@ -296,12 +296,14 @@ if ((err = cudnnCreate(&_handle)) != CUDNN_STATUS_SUCCESS) {
return 1;
}
"""
# to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name =='nt' else ""
params = ["-l", "cudnn"]
params.extend(['-I"%s"' % os.path.dirname(__file__)])
params.extend(['-I%s%s%s' % (path_wrapper,os.path.dirname(__file__),path_wrapper)])
if config.dnn.include_path:
params.extend(['-I"%s"' % config.dnn.include_path])
params.extend(['-I%s%s%s' % (path_wrapper, config.dnn.include_path, path_wrapper)])
if config.dnn.library_path:
params.extend(['-L"%s"' % config.dnn.library_path])
params.extend(['-L%s%s%s' % (path_wrapper, config.dnn.library_path, path_wrapper)])
if config.nvcc.compiler_bindir:
params.extend(['--compiler-bindir',
config.nvcc.compiler_bindir])
......
......@@ -321,11 +321,13 @@ class NVCC_compiler(Compiler):
# the -rpath option is not understood by the Microsoft linker
for rpath in rpaths:
cmd.extend(['-Xlinker', ','.join(['-rpath', rpath])])
cmd.extend('-I%s' % idir for idir in include_dirs)
# to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name =='nt' else ""
cmd.extend(['-I%s%s%s' % (path_wrapper,idir,path_wrapper) for idir in include_dirs])
cmd.extend(['-L%s%s%s' % (path_wrapper,ldir,path_wrapper) for ldir in lib_dirs])
cmd.extend(['-o', lib_filename])
cmd.append(os.path.split(cppfilename)[-1])
cmd.extend(['-L"%s"' % ldir for ldir in lib_dirs])
cmd.extend(['-l"%s"' % l for l in libs])
cmd.extend(['-l%s' % l for l in libs])
if sys.platform == 'darwin':
# This tells the compiler to use the already-loaded python
# symbols (which should always be the right ones).
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论