import re


def parse_version_string(file_path):
    """
    Parse __version__ = 'xxx' from the specifed file
    """
    version = None
    with open(file_path, 'r') as fd:
        match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
                          fd.read(), re.MULTILINE)
    if match:
        version = match.group(1)
    else:
        raise Exception('File %s doesn\'t contain __version__ = \'x.y.z\' string')

    return version