def get_version_from_pkg_info(package_name):
 try:
  pkg_info_file = open('PKG-INFO', 'r')
 except (IOError, OSError):
  return None
 try:
  pkg_info = email.message_from_file(pkg_info_file)
 except email.MessageError:
  return None
 if (pkg_info.get('Name', None) != package_name):
  return None
 return pkg_info.get('Version', None)

def get_version_from_pkg_info ( package_name ) : try : pkg_info_file = open ( 'PKG-INFO' , 'r' ) except ( IOError , OSError ) : return None try : pkg_info = email . message_from_file ( pkg_info_file ) except email . MessageError : return None if ( pkg_info . get ( 'Name' , None ) != package_name ) : return None return pkg_info . get ( 'Version' , None )
get the version from pkg-info file if we can .