def get_version(project_dir=os.curdir):
if '<STR_LIT>' in os.environ and os.environ['<STR_LIT>']:<EOL><INDENT>return os.environ['<STR_LIT>']<EOL><DEDENT>version = None<EOL>pkg_info_file = os.path.join(project_dir, '<STR_LIT>')<EOL>version_manager = os.path.join(project_dir, '<STR_LIT>')<EOL>if os.path.exists(pkg_info_file):<EOL><INDENT>with open(pkg_info_file) as info_fd:<EOL><INDENT>for line in info_fd.readlines():<EOL><INDENT>if line.startswith('<STR_LIT>'):<EOL><INDENT>version = line.split('<STR_LIT:U+0020>', <NUM_LIT:1>)[-<NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif os.path.exists(version_manager):<EOL><INDENT>version = check_output([version_manager, project_dir,<EOL>'<STR_LIT:version>']).strip()<EOL><DEDENT>if version is None:<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>if not isinstance(version, str) and isinstance(version, bytes):<EOL><INDENT>version = version.decode()<EOL><DEDENT>return version<EOL>
Retrieves the version of the package, from the PKG-INFO file or generates
it with the version script
Returns:
    str: Version for the package
Raises:
    RuntimeError: If the version could not be retrieved