rescue on environments without `which` (windows)
543629
def pngcrush(image)
      if SUPPORTS_PNGCRUSH && config[:pngcrush]
        crushed = "#{image}.crushed"
        system('pngcrush', '-q', '-rem alla', '-reduce', '-brute', image, crushed)
        FileUtils.mv(crushed, image)
      end
    end
695352
def which(executable):
    """"""
    locations = (
        '/usr/local/bin',
        '/bin',
        '/usr/bin',
        '/usr/local/sbin',
        '/usr/sbin',
        '/sbin',
    )

    for location in locations:
        executable_path = os.path.join(location, executable)
        if os.path.exists(executable_path) and os.path.isfile(executable_path):
            return executable_path
1027091
def finalize_env(env):
    

    keys = _PLATFORM_ENV_KEYS.get(sys.platform, [])
    if 'PATH' not in keys:
        # this MUST be available due to Node.js (and others really)
        # needing something to look for binary locations when it shells
        # out to other binaries.
        keys.append('PATH')
    results = {
        key: os.environ.get(key, '') for key in keys
    }
    results.update(env)
    return results
1109533
def WhereIs(self, prog, path=None, pathext=None, reject=[]):
        
        if path is None:
            try:
                path = self['ENV']['PATH']
            except KeyError:
                pass
        elif SCons.Util.is_String(path):
            path = self.subst(path)
        if pathext is None:
            try:
                pathext = self['ENV']['PATHEXT']
            except KeyError:
                pass
        elif SCons.Util.is_String(pathext):
            pathext = self.subst(pathext)
        prog = SCons.Util.CLVar(self.subst(prog)) # support "program --with-args"
        path = SCons.Util.WhereIs(prog[0], path, pathext, reject)
        if path: return path
        return None
344529
def get_xdg_env(env_name, fallback):
    
    env = os.environ.get(env_name)
    return env if env else fallback
573572
def which_bin(exes):
    '''
    
    '''
    if not isinstance(exes, Iterable):
        return None
    for exe in exes:
        path = which(exe)
        if not path:
            continue
        return path
    return None
7738
def pkg_resources_env(self, platform_str):
    """"""
    os_name = ''
    platform_machine = ''
    platform_release = ''
    platform_system = ''
    platform_version = ''
    sys_platform = ''

    if 'win' in platform_str:
      os_name = 'nt'
      platform_machine = 'AMD64' if '64' in platform_str else 'x86'
      platform_system = 'Windows'
      sys_platform = 'win32'
    elif 'linux' in platform_str:
      os_name = 'posix'
      platform_machine = 'x86_64' if '64' in platform_str else 'i686'
      platform_system = 'Linux'
      sys_platform = 'linux2' if self._version[0] == 2 else 'linux'
    elif 'macosx' in platform_str:
      os_name = 'posix'
      platform_str = platform_str.replace('.', '_')
      platform_machine = platform_str.split('_', 3)[-1]
      # Darwin version are macOS version + 4
      platform_release = '{}.0.0'.format(int(platform_str.split('_')[2]) + 4)
      platform_system = 'Darwin'
      platform_version = 'Darwin Kernel Version {}'.format(platform_release)
      sys_platform = 'darwin'

    return {
      'implementation_name': self.interpreter.lower(),
      'implementation_version': self.version_str,
      'os_name': os_name,
      'platform_machine': platform_machine,
      'platform_release': platform_release,
      'platform_system': platform_system,
      'platform_version': platform_version,
      'python_full_version': self.version_str,
      'platform_python_implementation': self.interpreter,
      'python_version': self.version_str[:3],
      'sys_platform': sys_platform,
    }
331684
def get_from_environment():
    '''
        
    '''
    name = os.environ.get("EXECJS_RUNTIME", "")
    if not name:
        return None

    try:
        return _find_runtime_by_name(name)
    except exceptions.RuntimeUnavailableError:
        return None
413560
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
    

    if os.path.dirname(cmd):
        if os.path.isfile(cmd) and os.access(cmd, mode):
            return cmd

    if path is None:
        path = os.environ.get('PATH', defpath)
    if not path:
        return None

    paths = path.split(pathsep)

    if sys.platform == 'win32':
        # oh boy
        if curdir not in paths:
            paths = [curdir] + paths

        # also need to check the fileexts...
        pathext = os.environ.get('PATHEXT', '').split(pathsep)

        if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
            files = [cmd]
        else:
            files = [cmd + ext for ext in pathext]
    else:
        # sanity
        files = [cmd]

    seen = set()
    for p in paths:
        normpath = normcase(p)
        if normpath in seen:
            continue
        seen.add(normpath)
        for f in files:
            fn = os.path.join(p, f)
            if os.path.isfile(fn) and os.access(fn, mode):
                return fn

    return None
567065
def dyld_find(name, executable_path=None, env=None):
    
    name = _ensure_utf8(name)
    executable_path = _ensure_utf8(executable_path)
    for path in dyld_image_suffix_search(chain(
                dyld_override_search(name, env),
                dyld_executable_path_search(name, executable_path),
                dyld_default_search(name, env),
            ), env):
        if os.path.isfile(path):
            return path
    raise ValueError, "dylib %s could not be found" % (name,)
804452
def which(cmd):
    
    def is_exe(fp):
        return os.path.isfile(fp) and os.access(fp, os.X_OK)

    fpath, fname = os.path.split(cmd)
    if fpath:
        if is_exe(cmd):
            return cmd
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            exe_file = os.path.join(path, cmd)
            if is_exe(exe_file):
                return exe_file
    return None
519319
def __get_windows_path(self):
        """"""
        if OS_SEP == '\\':
            return self
        else:
            entry = self.get()
            r = entry.get_path().replace(OS_SEP, '\\')
            return SCons.Subst.SpecialAttrWrapper(r, entry.name + "_windows")
1168935
def which(x):
    '''
    
    '''
    for p in os.environ.get('PATH').split(os.pathsep):
        p = os.path.join(p, x)
        if os.path.exists(p):
            return os.path.abspath(p)
    return None
899625
def getenv(option_name, default=None):
    """"""
    env = "%s_%s" % (NAMESPACE.upper(), option_name.upper())
    return os.environ.get(env, default)
645859
def which(filename, env=None):
    ''''''

    # Special case where filename contains an explicit path.
    if os.path.dirname(filename) != '' and is_executable_file(filename):
        return filename
    if env is None:
        env = os.environ
    p = env.get('PATH')
    if not p:
        p = os.defpath
    pathlist = p.split(os.pathsep)
    for path in pathlist:
        ff = os.path.join(path, filename)
        if is_executable_file(ff):
            return ff
    return None
259386
def del_windows_env_var(key):
    

    if not isinstance(key, text_type):
        raise TypeError("%r not of type %r" % (key, text_type))

    status = winapi.SetEnvironmentVariableW(key, None)
    if status == 0:
        raise ctypes.WinError()
1329615
def get_environment(name):
    """"""
    if name == "_default":
        return env_from_template(name)
    filename = os.path.join("environments", name + ".json")
    try:
        with open(filename) as f:
            try:
                return json.loads(f.read())
            except ValueError as e:
                msg = 'LittleChef found the following error in'
                msg += ' "{0}":\n                {1}'.format(filename, str(e))
                abort(msg)
    except IOError:
        raise FileNotFoundError('File {0} not found'.format(filename))