({
config,
entrypoint,
}: {
config: BuildOptions['config'];
entrypoint: string;
})
| 404 | } |
| 405 | |
| 406 | async 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 |
no test coverage detected