[Numpy-svn] r5054 - trunk/numpy/distutils

numpy-svn@scip... numpy-svn@scip...
Sun Apr 20 06:24:32 CDT 2008


Author: jarrod.millman
Date: 2008-04-20 06:24:30 -0500 (Sun, 20 Apr 2008)
New Revision: 5054

Modified:
   trunk/numpy/distutils/ccompiler.py
Log:
Reverting r4481, see #723


Modified: trunk/numpy/distutils/ccompiler.py
===================================================================
--- trunk/numpy/distutils/ccompiler.py	2008-04-20 02:45:19 UTC (rev 5053)
+++ trunk/numpy/distutils/ccompiler.py	2008-04-20 11:24:30 UTC (rev 5054)
@@ -398,5 +398,68 @@
     return _distutils_gen_preprocess_options(macros, include_dirs)
 ccompiler.gen_preprocess_options = gen_preprocess_options
 
+##Fix distutils.util.split_quoted:
+# NOTE:  I removed this fix in revision 4481 (see ticket #619), but it appears
+# that removing this fix causes f2py problems on Windows XP (see ticket #723).
+# Specifically, on WinXP when gfortran is installed in a directory path, which
+# contains spaces, then f2py is unable to find it.
+import re
+import string
+_wordchars_re = re.compile(r'[^\\\'\"%s ]*' % string.whitespace)
+_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
+_dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
+_has_white_re = re.compile(r'\s')
+def split_quoted(s):
+    s = string.strip(s)
+    words = []
+    pos = 0
+
+    while s:
+        m = _wordchars_re.match(s, pos)
+        end = m.end()
+        if end == len(s):
+            words.append(s[:end])
+            break
+
+        if s[end] in string.whitespace: # unescaped, unquoted whitespace: now
+            words.append(s[:end])       # we definitely have a word delimiter
+            s = string.lstrip(s[end:])
+            pos = 0
+
+        elif s[end] == '\\':            # preserve whatever is being escaped;
+                                        # will become part of the current word
+            s = s[:end] + s[end+1:]
+            pos = end+1
+
+        else:
+            if s[end] == "'":           # slurp singly-quoted string
+                m = _squote_re.match(s, end)
+            elif s[end] == '"':         # slurp doubly-quoted string
+                m = _dquote_re.match(s, end)
+            else:
+                raise RuntimeError, \
+                      "this can't happen (bad char '%c')" % s[end]
+
+            if m is None:
+                raise ValueError, \
+                      "bad string (mismatched %s quotes?)" % s[end]
+
+            (beg, end) = m.span()
+            if _has_white_re.search(s[beg+1:end-1]):
+                s = s[:beg] + s[beg+1:end-1] + s[end:]
+                pos = m.end() - 2
+            else:
+                # Keeping quotes when a quoted word does not contain
+                # white-space. XXX: send a patch to distutils
+                pos = m.end()
+
+        if pos >= len(s):
+            words.append(s)
+            break
+
+    return words
+ccompiler.split_quoted = split_quoted
+##Fix distutils.util.split_quoted:
+
 # define DISTUTILS_USE_SDK when necessary to workaround distutils/msvccompiler.py bug
 msvc_on_amd64()



More information about the Numpy-svn mailing list