Skip to content

Commit 7dcf623

Browse files
committed
MAINT: Fix issue with C compiler args containing spaces
Instead of doing a dumb string split, use shlex to make sure args containing spaces are handled properly.
1 parent e869222 commit 7dcf623

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

numpy/distutils/unixccompiler.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import sys
77
import subprocess
8+
import shlex
89

910
from distutils.errors import CompileError, DistutilsExecError, LibError
1011
from distutils.unixccompiler import UnixCCompiler
@@ -30,15 +31,15 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts
3031
if 'OPT' in os.environ:
3132
# XXX who uses this?
3233
from sysconfig import get_config_vars
33-
opt = " ".join(os.environ['OPT'].split())
34-
gcv_opt = " ".join(get_config_vars('OPT')[0].split())
35-
ccomp_s = " ".join(self.compiler_so)
34+
opt = shlex.join(shlex.split(os.environ['OPT']))
35+
gcv_opt = shlex.join(shlex.split(get_config_vars('OPT')[0]))
36+
ccomp_s = shlex.join(self.compiler_so)
3637
if opt not in ccomp_s:
3738
ccomp_s = ccomp_s.replace(gcv_opt, opt)
38-
self.compiler_so = ccomp_s.split()
39-
llink_s = " ".join(self.linker_so)
39+
self.compiler_so = shlex.split(ccomp_s)
40+
llink_s = shlex.join(self.linker_so)
4041
if opt not in llink_s:
41-
self.linker_so = llink_s.split() + opt.split()
42+
self.linker_so = self.linker_so + shlex.split(opt)
4243

4344
display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
4445

0 commit comments

Comments
 (0)