MCPcopy Index your code
hub / github.com/plotly/dash / build_components

Function build_components

dash/development/update_components.py:72–136  ·  view source on GitHub ↗
(components_source, concurrency)

Source from the content-addressed store, hash-verified

70
71
72def build_components(components_source, concurrency):
73
74 is_windows = sys.platform == "win32"
75
76 source_glob = (
77 components_source
78 if components_source != "all"
79 else "{dash-core-components,dash-html-components,dash-table}"
80 )
81
82 cmdstr = f"npx lerna exec --concurrency {concurrency} --scope='{source_glob}' -- npm run build"
83 cmd = shlex.split(cmdstr, posix=not is_windows)
84 status_print(cmdstr)
85
86 with subprocess.Popen(
87 cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=is_windows
88 ) as proc:
89 out, err = proc.communicate()
90 status = proc.poll()
91
92 if err:
93 status_print(("🛑 " if status else "") + err.decode(), file=sys.stderr)
94
95 if status or not out:
96 status_print(
97 f"🚨 Finished updating component packages: {source_glob} (status={status}) 🚨",
98 file=sys.stderr,
99 )
100 sys.exit(1)
101
102 if "{" in source_glob:
103 source_glob = source_glob.split("{")[1].split("}")[0]
104
105 for package in source_glob.split(","):
106 build_directory = os.path.join(
107 "components", package, package.replace("-", "_").rstrip("/\\")
108 )
109
110 dest_dir = dest_dir_map.get(package) or package
111
112 dest_path = os.path.join("dash", dest_dir)
113
114 if not os.path.exists(dest_path):
115 try:
116 os.makedirs(dest_path)
117 except OSError:
118 logger.exception("🚨 Having issues manipulating %s", dest_path)
119 sys.exit(1)
120
121 if not os.path.exists(build_directory):
122 status_print(
123 "🚨 Could not locate build artifacts."
124 + " Check that the npm build process completed"
125 + f" successfully for package: {package} 🚨"
126 )
127 sys.exit(1)
128 else:
129 status_print(f"🚚 Moving build artifacts from {build_directory} to Dash 🚚")

Callers 1

cliFunction · 0.85

Calls 4

status_printFunction · 0.85
exitMethod · 0.80
getMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…