def _detect_linux_distro()

in linux/cuda_installer/os_installers/__init__.py [0:0]


    def _detect_linux_distro() -> (System, str):
        """
        Checks the /etc/os-release file to figure out what distribution of OS
        we're running.
        """
        with open("/etc/os-release") as os_release:
            lines = [
                line.strip() for line in os_release.readlines() if line.strip() != ""
            ]
            info = {
                k: v.strip("'\"")
                for k, v in (line.split("=", maxsplit=1) for line in lines)
            }

        name = info["NAME"]

        if name.startswith("Debian"):
            system = System.Debian
            version = info["VERSION"].split()[0]  # 11 (rodete) -> 11
        elif name.startswith("CentOS"):
            system = System.CentOS
            version = info["VERSION_ID"]  # 8
        elif name.startswith("Rocky"):
            system = System.Rocky
            version = info["VERSION_ID"]  # 8.4
        elif name.startswith("Ubuntu"):
            system = System.Ubuntu
            version = info["VERSION_ID"]  # 20.04
        elif name.startswith("SLES"):
            system = System.SUSE
            version = info["VERSION_ID"]  # 15.3
        elif name.startswith("Red Hat"):
            system = System.RHEL
            version = info["VERSION_ID"]  # 8.4
        elif name.startswith("Fedora"):
            system = System.Fedora
            version = info["VERSION_ID"]  # 34
        else:
            raise RuntimeError("Unrecognized operating system.")
        return system, version