MCPcopy Create free account
hub / github.com/vercel/vercel / runSync

Function runSync

packages/python/src/start-dev-server.ts:226–310  ·  view source on GitHub ↗
({
  manifestType,
  manifestPath,
  uvPath,
  pythonBin,
  env,
  onStdout,
  onStderr,
}: RunSyncOptions)

Source from the content-addressed store, hash-verified

224}
225
226async function runSync({
227 manifestType,
228 manifestPath,
229 uvPath,
230 pythonBin,
231 env,
232 onStdout,
233 onStderr,
234}: RunSyncOptions): Promise<void> {
235 const projectDir = dirname(manifestPath);
236
237 const pip = uvPath
238 ? { cmd: uvPath, prefix: ['pip', 'install'] }
239 : { cmd: pythonBin, prefix: ['-m', 'pip', 'install'] };
240
241 let spawnCmd: string;
242 let spawnArgs: string[];
243
244 switch (manifestType) {
245 case 'uv.lock': {
246 if (!uvPath) {
247 throw new NowBuildError({
248 code: 'PYTHON_DEPENDENCY_SYNC_FAILED',
249 message: 'uv is required to install dependencies from uv.lock.',
250 link: 'https://docs.astral.sh/uv/getting-started/installation/',
251 action: 'Install uv',
252 });
253 }
254 spawnCmd = uvPath;
255 spawnArgs = ['sync'];
256 break;
257 }
258 case 'pylock.toml': {
259 spawnCmd = pip.cmd;
260 spawnArgs = [...pip.prefix, '-r', manifestPath];
261 break;
262 }
263 case 'pyproject.toml': {
264 spawnCmd = pip.cmd;
265 spawnArgs = [...pip.prefix, projectDir];
266 break;
267 }
268 default:
269 debug(`Unknown manifest type: ${manifestType}`);
270 return;
271 }
272
273 await new Promise<void>((resolve, reject) => {
274 debug(`Running "${spawnCmd} ${spawnArgs.join(' ')}" in ${projectDir}...`);
275 const child = spawn(spawnCmd, spawnArgs, {
276 cwd: projectDir,
277 env: getProtectedUvEnv(env),
278 stdio: ['inherit', 'pipe', 'pipe'],
279 });
280
281 child.stdout?.on('data', (data: Buffer) => {
282 if (onStdout) {
283 onStdout(data);

Callers 1

syncDependenciesFunction · 0.85

Calls 9

debugFunction · 0.90
getProtectedUvEnvFunction · 0.90
spawnFunction · 0.85
onStdoutFunction · 0.85
onStderrFunction · 0.85
resolveFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected