#NEWLINE# def write_version_py( filename = _VERSION_FILENAME ) : #NEWLINE# #INDENT# ' Create a file containing the version information. ' #NEWLINE# template = "# This file was automatically generated from the `setup.py` script.\nversion = '{version}'\nfull_version = '{full_version}'\ngit_revision = '{git_revision}'\nis_released = {is_released}\n\nif not is_released:\n    version = full_version\n" #NEWLINE# fullversion = VERSION #NEWLINE# if os . path . exists ( '.git' ) : #NEWLINE# #INDENT# ( git_rev , dev_num ) = git_version ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . path . exists ( git_rev ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from envisage._version import git_revision as git_rev #NEWLINE# from envisage._version import full_version as full_v #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# msg = "Unable to import 'git_revision' or 'full_revision'. Try removing {} and the build directory before building." #NEWLINE# raise ImportError ( msg . format ( _VERSION_FILENAME ) ) #NEWLINE# #UNINDENT# match = re . match ( '.*?\\.dev(?P<dev_num>\\d+)' , full_v ) #NEWLINE# if ( match is None ) : #NEWLINE# #INDENT# dev_num = '0' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dev_num = match . group ( 'dev_num' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# git_rev = 'Unknown' #NEWLINE# dev_num = '0' #NEWLINE# #UNINDENT# #UNINDENT# if ( not IS_RELEASED ) : #NEWLINE# #INDENT# fullversion += '.dev{0}' . format ( dev_num ) #NEWLINE# #UNINDENT# with open ( filename , 'wt' ) as fp : #NEWLINE# #INDENT# fp . write ( template . format ( version = VERSION , full_version = fullversion , git_revision = git_rev , is_released = IS_RELEASED ) )