def build_js():
    ''' Build BokehJS files (CSS, JS, etc) under the ``bokehjs`` source
    subdirectory.

    Also prints a table of statistics about the generated assets (file sizes,
    etc.) or any error messages if the build fails.

    Note this function only builds BokehJS assets, it does not install them
    into the python source tree.

    '''
    print("Building BokehJS... ", end="")
    sys.stdout.flush()
    os.chdir('bokehjs')

    cmd = ["node", "make", 'build', '--emit-error']

    t0 = time.time()
    try:
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except OSError as e:
        print(BUILD_EXEC_FAIL_MSG % (cmd, e))
        sys.exit(1)
    finally:
        os.chdir('..')

    result = proc.wait()
    t1 = time.time()

    if result != 0:
        indented_msg = ""
        outmsg = proc.stdout.read().decode('ascii', errors='ignore')
        outmsg = "\n".join("    " + x for x in outmsg.split("\n"))
        errmsg = proc.stderr.read().decode('ascii', errors='ignore')
        errmsg = "\n".join("    " + x for x in errmsg.split("\n"))
        print(BUILD_FAIL_MSG % (red(outmsg), red(errmsg)))
        sys.exit(1)

    indented_msg = ""
    msg = proc.stdout.read().decode('ascii', errors='ignore')
    pat = re.compile(r"(\[.*\]) (.*)", re.DOTALL)
    for line in msg.strip().split("\n"):
        m = pat.match(line)
        if not m: continue # skip generate.py output lines
        stamp, txt = m.groups()
        indented_msg += "   " + dim(green(stamp)) + " " + dim(txt) + "\n"
    msg = "\n".join("    " + x for x in msg.split("\n"))
    print(BUILD_SUCCESS_MSG % indented_msg)
    print("Build time: %s" % bright(yellow("%0.1f seconds" % (t1-t0))))
    print()
    print("Build artifact sizes:")
    try:
        def size(*path):
            return os.stat(join("bokehjs", "build", *path)).st_size / 2**10

        print("  - bokeh.js              : %6.1f KB" % size("js", "bokeh.js"))
        print("  - bokeh.css             : %6.1f KB" % size("css", "bokeh.css"))
        print("  - bokeh.min.js          : %6.1f KB" % size("js", "bokeh.min.js"))
        print("  - bokeh.min.css         : %6.1f KB" % size("css", "bokeh.min.css"))

        print("  - bokeh-widgets.js      : %6.1f KB" % size("js", "bokeh-widgets.js"))
        print("  - bokeh-widgets.css     : %6.1f KB" % size("css", "bokeh-widgets.css"))
        print("  - bokeh-widgets.min.js  : %6.1f KB" % size("js", "bokeh-widgets.min.js"))
        print("  - bokeh-widgets.min.css : %6.1f KB" % size("css", "bokeh-widgets.min.css"))

        print("  - bokeh-tables.js       : %6.1f KB" % size("js", "bokeh-tables.js"))
        print("  - bokeh-tables.css      : %6.1f KB" % size("css", "bokeh-tables.css"))
        print("  - bokeh-tables.min.js   : %6.1f KB" % size("js", "bokeh-tables.min.js"))
        print("  - bokeh-tables.min.css  : %6.1f KB" % size("css", "bokeh-tables.min.css"))

        print("  - bokeh-api.js          : %6.1f KB" % size("js", "bokeh-api.js"))
        print("  - bokeh-api.min.js      : %6.1f KB" % size("js", "bokeh-api.min.js"))
    except Exception as e:
        print(BUILD_SIZE_FAIL_MSG % e)
        sys.exit(1)
def build_js ( ) : print ( "Building BokehJS... " , end = "" ) sys . stdout . flush ( ) os . chdir ( 'bokehjs' ) cmd = [ "node" , "make" , 'build' , '--emit-error' ] t0 = time . time ( ) try : proc = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) except OSError as e : print ( BUILD_EXEC_FAIL_MSG % ( cmd , e ) ) sys . exit ( 1 ) finally : os . chdir ( '..' ) result = proc . wait ( ) t1 = time . time ( ) if result != 0 : indented_msg = "" outmsg = proc . stdout . read ( ) . decode ( 'ascii' , errors = 'ignore' ) outmsg = "\n" . join ( "    " + x for x in outmsg . split ( "\n" ) ) errmsg = proc . stderr . read ( ) . decode ( 'ascii' , errors = 'ignore' ) errmsg = "\n" . join ( "    " + x for x in errmsg . split ( "\n" ) ) print ( BUILD_FAIL_MSG % ( red ( outmsg ) , red ( errmsg ) ) ) sys . exit ( 1 ) indented_msg = "" msg = proc . stdout . read ( ) . decode ( 'ascii' , errors = 'ignore' ) pat = re . compile ( r"(\[.*\]) (.*)" , re . DOTALL ) for line in msg . strip ( ) . split ( "\n" ) : m = pat . match ( line ) if not m : continue stamp , txt = m . groups ( ) indented_msg += "   " + dim ( green ( stamp ) ) + " " + dim ( txt ) + "\n" msg = "\n" . join ( "    " + x for x in msg . split ( "\n" ) ) print ( BUILD_SUCCESS_MSG % indented_msg ) print ( "Build time: %s" % bright ( yellow ( "%0.1f seconds" % ( t1 - t0 ) ) ) ) print ( ) print ( "Build artifact sizes:" ) try : def size ( * path ) : return os . stat ( join ( "bokehjs" , "build" , * path ) ) . st_size / 2 ** 10 print ( "  - bokeh.js              : %6.1f KB" % size ( "js" , "bokeh.js" ) ) print ( "  - bokeh.css             : %6.1f KB" % size ( "css" , "bokeh.css" ) ) print ( "  - bokeh.min.js          : %6.1f KB" % size ( "js" , "bokeh.min.js" ) ) print ( "  - bokeh.min.css         : %6.1f KB" % size ( "css" , "bokeh.min.css" ) ) print ( "  - bokeh-widgets.js      : %6.1f KB" % size ( "js" , "bokeh-widgets.js" ) ) print ( "  - bokeh-widgets.css     : %6.1f KB" % size ( "css" , "bokeh-widgets.css" ) ) print ( "  - bokeh-widgets.min.js  : %6.1f KB" % size ( "js" , "bokeh-widgets.min.js" ) ) print ( "  - bokeh-widgets.min.css : %6.1f KB" % size ( "css" , "bokeh-widgets.min.css" ) ) print ( "  - bokeh-tables.js       : %6.1f KB" % size ( "js" , "bokeh-tables.js" ) ) print ( "  - bokeh-tables.css      : %6.1f KB" % size ( "css" , "bokeh-tables.css" ) ) print ( "  - bokeh-tables.min.js   : %6.1f KB" % size ( "js" , "bokeh-tables.min.js" ) ) print ( "  - bokeh-tables.min.css  : %6.1f KB" % size ( "css" , "bokeh-tables.min.css" ) ) print ( "  - bokeh-api.js          : %6.1f KB" % size ( "js" , "bokeh-api.js" ) ) print ( "  - bokeh-api.min.js      : %6.1f KB" % size ( "js" , "bokeh-api.min.js" ) ) except Exception as e : print ( BUILD_SIZE_FAIL_MSG % e ) sys . exit ( 1 )
Build BokehJS files (CSS, JS, etc) under the ``bokehjs`` source
    subdirectory.

    Also prints a table of statistics about the generated assets (file sizes,
    etc.) or any error messages if the build fails.

    Note this function only builds BokehJS assets, it does not install them
    into the python source tree.