def parse_version(package):
from os.path import dirname, join<EOL>import ast<EOL>init_fpath = join(dirname(__file__), package, '<STR_LIT>')<EOL>with open(init_fpath) as file_:<EOL><INDENT>sourcecode = file_.read()<EOL><DEDENT>pt = ast.parse(sourcecode)<EOL>class VersionVisitor(ast.NodeVisitor):<EOL><INDENT>def visit_Assign(self, node):<EOL><INDENT>for target in node.targets:<EOL><INDENT>if target.id == '<STR_LIT>':<EOL><INDENT>self.version = node.value.s<EOL><DEDENT><DEDENT><DEDENT><DEDENT>visitor = VersionVisitor()<EOL>visitor.visit(pt)<EOL>return visitor.version<EOL>
Statically parse the version number from __init__.py

CommandLine:
    python -c "import setup; print(setup.parse_version('progiter'))"