[SciPy-dev] Possible bug in distutils compiler when using scipy's weave on windows
Brian Thorne
hardbyte@gmail....
Tue Dec 2 20:36:53 CST 2008
I am running python(x,y) which installs python and scipy and weave
under the "program files" folder on windows. When using weave by
having some inline C/C++ it uses a modified distutils to compile the
inline source right?
Unfortunately it doesn't seem to handle spaces in the path to either
the output or to the temporary source files.
I checked that this was the problem by copying the weave directory
from site-packages and put it in another directory without spaces in
the path - this worked fine.
I then tried the exact g++ command from the stack trace at the command
line and got the same error - so altered the command by adding quotes
to the -c "path/to source/a.c" and the -o "objects".
This worked at the command line so I set out changing it in weave...
After spending a while debugging I found where quotes were added to
the included libraries. After a lot more tracing found where the
command line gets stringed together for the linker - in
unixcompiler.py (surprising as I am under windows!)
So I changed it to quote the source and the output objects and now it goes fine.
What I changed was:
In distutils.cygwinccompiler __revision__ = "$Id: cygwinccompiler.py
37828 2004-11-10 22:23:15Z loewis $":
> def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
> if ext == '.rc' or ext == '.res':
> # gcc needs '.res' and '.rc' compiled to object files !!!
> try:
> self.spawn(["windres", "-i", src, "-o", obj])
> except DistutilsExecError, msg:
> raise CompileError, msg
> else: # for other files use the C-compiler
> try:
> lis = ['"' + src + '"', '-o', '"' + obj + '"']
> cmd = self.compiler_so + cc_args + lis + extra_postargs
> self.spawn(cmd)
> except DistutilsExecError, msg:
> raise CompileError, msg
In distutils.unixccompiler __revision__ = "$Id: unixccompiler.py 54954
2007-04-25 06:42:41Z neal.norwitz $":
> def link(self, target_desc, objects,
> output_filename, output_dir=None, libraries=None,
> library_dirs=None, runtime_library_dirs=None,
> export_symbols=None, debug=0, extra_preargs=None,
> extra_postargs=None, build_temp=None, target_lang=None):
> objects, output_dir = self._fix_object_args(objects, output_dir)
> libraries, library_dirs, runtime_library_dirs = \
> self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
>
> lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries)
> if type(output_dir) not in (StringType, NoneType):
> raise TypeError, "'output_dir' must be a string or None"
> if output_dir is not None:
> output_filename = os.path.join(output_dir, output_filename)
>
> if self._need_link(objects, output_filename):
> objects = ['"' + o + '"' for o in objects]
> self.objects = ['"' + o + '"' for o in self.objects]
> ld_args = (objects + self.objects +
> lib_opts + ['-o', '"' + output_filename + '"'])
> if debug:
> ld_args[:0] = ['-g']
> if extra_preargs:
> ld_args[:0] = extra_preargs
I don't know if that would still work on gnu/linux systems tho...
Brian Thorne
More information about the Scipy-dev
mailing list