@ -21,39 +21,8 @@ APP_ICON = os.path.join( BASE_DIR, "vasl_templates/webapp/static/images/app.ico"
# ---------------------------------------------------------------------
def get_git_info ( ) :
""" Get the git branch/commit we ' re building from. """
# get the latest commit ID
proc = subprocess . run (
[ " git " , " log " ] ,
stdout = subprocess . PIPE , stderr = subprocess . PIPE , encoding = " utf-8 " ,
check = True
)
buf = proc . stdout . split ( " \n " ) [ 0 ]
mo = re . search ( r " ^commit ([a-z0-9]+)$ " , buf )
last_commit_id = mo . group ( 1 )
# get the current git branch
proc = subprocess . run (
[ " git " , " branch " ] ,
stdout = subprocess . PIPE , stderr = subprocess . PIPE , encoding = " utf-8 " ,
check = True
)
lines = [ s for s in proc . stdout . split ( " \n " ) if s . startswith ( " * " ) ]
if len ( lines ) != 1 :
raise RuntimeError ( " Can ' t parse git branch status. " )
branch_name = lines [ 0 ] [ 2 : ]
if branch_name . startswith ( " (HEAD detached at " ) and branch_name . endswith ( " ) " ) :
branch_name = branch_name [ 18 : - 1 ]
return { " last_commit_id " : last_commit_id , " branch_name " : branch_name }
def make_target_name ( fname ) :
""" Generate a target filename. """
return fname + " .exe " if sys . platform == " win32 " else fname
# ---------------------------------------------------------------------
def main ( args ) : #pylint: disable=too-many-locals
""" Main processing. """
# parse the command-line options
output_fname = None
@ -127,7 +96,7 @@ if sys.platform == "win32":
args . extend ( [ " --icon " , APP_ICON ] )
# NOTE: These files are not always required but it's probably safer to always include them.
import distutils . sysconfig #pylint: disable=import-error
dname = os . path . join ( distutils . sysconfig . get_python_lib ( ) , " PyQt5/Qt/bin " )
dname = os . path . join ( distutils . sysconfig . get_python_lib ( ) , " PyQt5/Qt5 /bin " )
args . extend ( [ " --add-binary " , os . path . join ( dname , " libEGL.dll " ) + os . pathsep + " PyQt5/Qt/bin " ] )
args . extend ( [ " --add-binary " , os . path . join ( dname , " libGLESv2.dll " ) + os . pathsep + " PyQt5/Qt/bin " ] )
args . append ( MAIN_SCRIPT )
@ -149,7 +118,8 @@ def ignore_files( dname, fnames ): #pylint: disable=redefined-outer-name
# ignore anything in .gitignore
fname = os . path . join ( dname , " .gitignore " )
if os . path . isfile ( fname ) :
for line_buf in open ( fname , " r " ) :
with open ( fname , " r " , encoding = " utf-8 " ) as fp :
for line_buf in fp :
line_buf = line_buf . strip ( )
if not line_buf or line_buf . startswith ( " # " ) :
continue
@ -172,7 +142,8 @@ build_info = {
}
build_info . update ( get_git_info ( ) )
dname = os . path . join ( dist_dir , " config " )
with open ( os . path . join ( dname , " build-info.json " ) , " w " ) as fp :
fname = os . path . join ( dname , " build-info.json " )
with open ( fname , " w " , encoding = " utf-8 " ) as fp :
json . dump ( build_info , fp )
# freeze the loader
@ -209,3 +180,42 @@ if cleanup:
elapsed_time = time . time ( ) - start_time
print ( )
print ( " Elapsed time: {} " . format ( datetime . timedelta ( seconds = int ( elapsed_time ) ) ) )
# ---------------------------------------------------------------------
def get_git_info ( ) :
""" Get the git branch/commit we ' re building from. """
# get the latest commit ID
proc = subprocess . run (
[ " git " , " log " ] ,
stdout = subprocess . PIPE , stderr = subprocess . PIPE , encoding = " utf-8 " ,
check = True
)
buf = proc . stdout . split ( " \n " ) [ 0 ]
mo = re . search ( r " ^commit ([a-z0-9]+)$ " , buf )
last_commit_id = mo . group ( 1 )
# get the current git branch
proc = subprocess . run (
[ " git " , " branch " ] ,
stdout = subprocess . PIPE , stderr = subprocess . PIPE , encoding = " utf-8 " ,
check = True
)
lines = [ s for s in proc . stdout . split ( " \n " ) if s . startswith ( " * " ) ]
if len ( lines ) != 1 :
raise RuntimeError ( " Can ' t parse git branch status. " )
branch_name = lines [ 0 ] [ 2 : ]
if branch_name . startswith ( " (HEAD detached at " ) and branch_name . endswith ( " ) " ) :
branch_name = branch_name [ 18 : - 1 ]
return { " last_commit_id " : last_commit_id , " branch_name " : branch_name }
def make_target_name ( fname ) :
""" Generate a target filename. """
return fname + " .exe " if sys . platform == " win32 " else fname
# ---------------------------------------------------------------------
if __name__ == " __main__ " :
main ( sys . argv [ 1 : ] )