def version(modfile):
    import re
    with open(modfile) as fh:
        for line in fh:
            m = re.search(r"^__version__ = '([^']+)'$", line)
            if m:
                return m.group(1)
    raise Exception('No __version__ string found in {fn}'.format(fn=modfile))
Parse version from module without importing or evaluating the code.
dataset/ETHPy150Open todddeluca/daemoncmd/setup.py/version