def get_valid_build_systems(working_dir, package=None):
from rez.plugin_managers import plugin_manager<EOL>from rez.exceptions import PackageMetadataError<EOL>try:<EOL><INDENT>package = package or get_developer_package(working_dir)<EOL><DEDENT>except PackageMetadataError:<EOL><INDENT>pass<EOL><DEDENT>if package:<EOL><INDENT>if getattr(package, "<STR_LIT>", None) is not None:<EOL><INDENT>buildsys_name = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>buildsys_name = getattr(package, "<STR_LIT>", None)<EOL><DEDENT>if buildsys_name:<EOL><INDENT>cls = plugin_manager.get_plugin_class('<STR_LIT>', buildsys_name)<EOL>return [cls]<EOL><DEDENT><DEDENT>clss = []<EOL>for buildsys_name in get_buildsys_types():<EOL><INDENT>cls = plugin_manager.get_plugin_class('<STR_LIT>', buildsys_name)<EOL>if cls.is_valid_root(working_dir, package=package):<EOL><INDENT>clss.append(cls)<EOL><DEDENT><DEDENT>child_clss = set(x.child_build_system() for x in clss)<EOL>clss = list(set(clss) - child_clss)<EOL>return clss<EOL>
Returns the build system classes that could build the source in given dir.

    Args:
        working_dir (str): Dir containing the package definition and potentially
            build files.
        package (`Package`): Package to be built. This may or may not be needed
            to determine the build system. For eg, cmake just has to look for
            a CMakeLists.txt file, whereas the 'build_command' package field
            must be present for the 'custom' build system type.

    Returns:
        List of class: Valid build system class types.