import re


def extract_variable(filename, variable):  # type: (str, str) -> str
    """Extract the version number from a python file that contains the '__version__' variable."""
    with open(filename, "r", encoding="utf8") as stream:
        search_refind = r'{} = ["\'](\d+\.\d+\.\d+)["\']'.format(variable)
        verdata = re.search(search_refind, stream.read())
        if verdata:
            return verdata.group(1)
        else:
            raise RuntimeError("Unable to extract version number")