Comment 1 for bug 1216448

Revision history for this message
Matt Jones (workhorsy) wrote : Re: Make it work on Windows without Cygwin

Something like this can be used for 'which':
def which(name):
 result = []
 exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
 path = os.environ.get('PATH', None)
 if path is None:
  return []
 for p in os.environ.get('PATH', '').split(os.pathsep):
  p = os.path.join(p, name)
  print(p)
  if os.access(p, os.X_OK):
   result.append(p)
  for e in exts:
   pext = p + e
   if os.access(pext, os.X_OK):
    result.append(pext)
 return result