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

Function getPythonLambdaOptions

packages/python/src/index.ts:406–437  ·  view source on GitHub ↗
({
  config,
  entrypoint,
}: {
  config: BuildOptions['config'];
  entrypoint: string;
})

Source from the content-addressed store, hash-verified

404}
405
406async function getPythonLambdaOptions({
407 config,
408 entrypoint,
409}: {
410 config: BuildOptions['config'];
411 entrypoint: string;
412}) {
413 if (!config?.functions) {
414 return {};
415 }
416
417 const sources = new Set<string>([entrypoint]);
418 if (entrypoint.endsWith('.py')) {
419 sources.add(entrypoint.slice(0, -'.py'.length));
420 }
421
422 for (const sourceFile of sources) {
423 const lambdaOptions = await getLambdaOptionsFromFunction({
424 sourceFile,
425 config,
426 });
427
428 if (Object.keys(lambdaOptions).length > 0) {
429 // Python resolves the target wheel platform before the Lambda is created,
430 // so the Lambda architecture must stay aligned with that build target.
431 delete lambdaOptions.architecture;
432 return lambdaOptions;
433 }
434 }
435
436 return {};
437}
438
439/**
440 * Install a Vercel-owned Python package into the build venv, resolving the

Callers 1

buildFunction · 0.85

Calls 3

addMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected