[Distutils] Spawning Swig fails if not installed in C:\

Andy Sy andy at nospam.com
Tue Sep 30 17:43:08 EDT 2003

In build_ext.py, we see the following code:

         elif os.name == "nt":
             # Look for SWIG in its standard installation directory on
             # Windows (or so I presume!).  If we find it there, great;
    SEE ---> # if not, act like Unix and assume it's in the PATH.
             for vers in ("1.3", "1.2", "1.1"):
                 fn = os.path.join("c:\\swig%s" % vers, "swig.exe")
                 if os.path.isfile(fn):
                     return fn
                 return "swig.exe"

However, it doesn't really work because in spawn.py:

     if not dry_run:
SEE ---># spawn for NT requires a full path to the .exe
             rc = os.spawnv(os.P_WAIT, executable, cmd)
         except OSError, exc:
             # this seems to happen when the command isn't found
             raise DistutilsExecError, \
                   "command '%s' failed: %s" % (cmd[0], exc[-1])
         if rc != 0:
             # and this reflects the command running but failing
             raise DistutilsExecError, \
                   "command '%s' failed with exit status %d" % (cmd[0], rc)

Thus, if Swig is installed in any place other than c:\, the
first code will not be smart enough to make things work.

reply-to: a n d y @ n e t f x p h . c o m

More information about the Distutils-SIG mailing list