@fbuild.db.caches
def guess_platform(ctx, arch=None):
    """L{guess_platform} returns a platform set that describes the various
    features of the specified I{platform}. If I{platform} is I{None}, try to
    determine which platform the system is and return that value. If the
    platform cannot be determined, return I{None}."""
    ctx.logger.check('determining platform')
    if arch is None:
        # If we're on Windows, then don't even try uname
        if os.name == 'nt':
            res = archmap[platform.system().lower()]
            ctx.logger.passed(res)
            return frozenset(res)
        # Let's see if uname exists
        try:
            uname = fbuild.builders.find_program(ctx, ['uname'], quieter=1)
        except fbuild.builders.MissingProgram:
            # Maybe we're on windows. Let's just use what python thinks is the
            # platform.
            #arch = os.name
            arch = platform.system().lower()
        else:
            # We've got uname, so let's see what platform it thinks we're on.
            try:
                stdout, stderr = ctx.execute((uname, '-s'), quieter=1)
            except fbuild.ExecutionError:
                # Ack, that failed too. Just fall back to python.
                #arch = os.name
                arch = platform.system().lower()
            else:
                arch = stdout.decode('utf-8').strip().lower()

    if arch.startswith('mingw32'):
        arch = 'mingw'
    elif arch.startswith('cygwin'):
        arch = 'cygwin'
    try:
        architecture = archmap[arch]
    except __HOLE__:
        ctx.logger.failed()
        raise UnknownPlatform(arch)
    else:
        ctx.logger.passed(architecture)
        return frozenset(architecture)

# ------------------------------------------------------------------------------
dataset/ETHPy150Open felix-lang/fbuild/lib/fbuild/builders/platform.py/guess_platform