@vercel/python 6.47.0 → 6.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +204 -120
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -5649,12 +5649,16 @@ var import_execa4 = __toESM(require_execa());
5649
5649
  var import_build_utils6 = require("@vercel/build-utils");
5650
5650
  var import_fs5 = __toESM(require("fs"));
5651
5651
  var import_path6 = require("path");
5652
- function isPythonOnHive() {
5653
- const hive = process.env.VERCEL_PYTHON_ON_HIVE;
5654
- return hive === "1" || hive === "true";
5652
+
5653
+ // src/large-functions.ts
5654
+ function isLargeFunctionsEnabled() {
5655
+ const value = process.env.VERCEL_SUPPORT_LARGE_FUNCTIONS;
5656
+ return value === "1" || value === "true";
5655
5657
  }
5658
+
5659
+ // src/compileall.ts
5656
5660
  function isCompileAllEnabled() {
5657
- if (!isPythonOnHive())
5661
+ if (!isLargeFunctionsEnabled())
5658
5662
  return false;
5659
5663
  const val = process.env.VERCEL_PYTHON_COMPILEALL;
5660
5664
  if (val === void 0 || val === "")
@@ -5664,11 +5668,12 @@ function isCompileAllEnabled() {
5664
5668
  }
5665
5669
  function shouldUseCompileAll({
5666
5670
  isDev,
5667
- hasCustomCommand
5671
+ hasCustomCommand,
5672
+ hasCustomBuildCommand
5668
5673
  }) {
5669
5674
  if (isDev)
5670
5675
  return false;
5671
- if (hasCustomCommand)
5676
+ if (hasCustomCommand || hasCustomBuildCommand)
5672
5677
  return false;
5673
5678
  return isCompileAllEnabled();
5674
5679
  }
@@ -5788,11 +5793,9 @@ function shouldStripVendorFile(filePath) {
5788
5793
  return true;
5789
5794
  return false;
5790
5795
  }
5791
- var LAMBDA_BASE_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
5792
- var OTEL_LAYER_RESERVATION_BYTES = 5 * 1024 * 1024;
5793
- var LAMBDA_SIZE_THRESHOLD_BYTES = process.env.VERCEL_DEPLOYMENT_HAS_OTEL_LAYER === "1" ? LAMBDA_BASE_SIZE_THRESHOLD_BYTES - OTEL_LAYER_RESERVATION_BYTES : LAMBDA_BASE_SIZE_THRESHOLD_BYTES;
5796
+ var LAMBDA_SIZE_THRESHOLD_BYTES = 225 * 1024 * 1024;
5794
5797
  var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
5795
- var HIVE_LAMBDA_SIZE_BYTES = 1 * 1024 * 1024 * 1024;
5798
+ var MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE = 5 * 1024 * 1024 * 1024;
5796
5799
  var BUNDLING_DOCS_LINK = "https://vercel.com/docs/functions/runtimes/python#controlling-what-gets-bundled";
5797
5800
  var PythonDependencyExternalizer = class {
5798
5801
  constructor(options) {
@@ -5818,13 +5821,13 @@ var PythonDependencyExternalizer = class {
5818
5821
  if (this.hasCustomCommand) {
5819
5822
  return false;
5820
5823
  }
5821
- const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
5822
- if (pythonOnHiveEnabled) {
5824
+ if (this.totalBundleSize <= LAMBDA_SIZE_THRESHOLD_BYTES || this.uvLockPath === null) {
5823
5825
  return false;
5824
- } else if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.uvLockPath !== null) {
5825
- return true;
5826
5826
  }
5827
- return false;
5827
+ if (isLargeFunctionsEnabled() && this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
5828
+ return false;
5829
+ }
5830
+ return true;
5828
5831
  }
5829
5832
  /**
5830
5833
  * Analyze the bundle: mirror all vendor files, calculate total size,
@@ -5854,29 +5857,28 @@ var PythonDependencyExternalizer = class {
5854
5857
  const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
5855
5858
  (0, import_build_utils7.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
5856
5859
  const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
5857
- const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
5860
+ const largeFunctionsEnabled = isLargeFunctionsEnabled();
5858
5861
  options.onSized?.({
5859
5862
  totalSizeBytes: this.totalBundleSize,
5860
5863
  runtimeInstallEnabled
5861
5864
  });
5862
- if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
5865
+ if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !largeFunctionsEnabled) {
5863
5866
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
5864
5867
  throw new import_build_utils7.NowBuildError({
5865
5868
  code: "LAMBDA_SIZE_EXCEEDED",
5866
- message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
5869
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
5867
5870
 
5868
- When using a custom install command, Vercel cannot automatically
5869
- optimize dependency bundling. To reduce the size of your
5870
- dependencies, you can:
5871
- 1. Remove unused dependencies from your project.
5872
- 2. Remove the custom install command to allow Vercel to manage
5873
- and optimize dependencies automatically.`,
5871
+ A custom install command prevents Vercel from optimizing your
5872
+ function bundle size automatically. To fix this, you can:
5873
+ 1. Remove unused dependencies from your project, or
5874
+ 2. Remove the custom install command so Vercel can optimize
5875
+ the function bundle automatically.`,
5874
5876
  link: BUNDLING_DOCS_LINK,
5875
5877
  action: "Learn More"
5876
5878
  });
5877
5879
  }
5878
- if (pythonOnHiveEnabled && this.totalBundleSize > HIVE_LAMBDA_SIZE_BYTES) {
5879
- const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
5880
+ if (largeFunctionsEnabled && this.totalBundleSize >= MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE) {
5881
+ const limitMB = (MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE / (1024 * 1024)).toFixed(0);
5880
5882
  throw new import_build_utils7.NowBuildError({
5881
5883
  code: "LAMBDA_SIZE_EXCEEDED",
5882
5884
  message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
@@ -5898,6 +5900,10 @@ application into smaller functions.`,
5898
5900
  * Mutates `files` in place: adds vendor files (private + knapsack-selected
5899
5901
  * public), runtime config, and uv binary.
5900
5902
  * Must be called after analyze().
5903
+ *
5904
+ * If large functions are allowed and the bundle can't fit AWS Lambda, falls
5905
+ * back to bundling everything for Hive and returns `fellBackToFullBundle:
5906
+ * true` so the caller can apply the same compileall handling.
5901
5907
  */
5902
5908
  async generateBundle(files) {
5903
5909
  if (!this.analyzed) {
@@ -5906,54 +5912,49 @@ application into smaller functions.`,
5906
5912
  );
5907
5913
  }
5908
5914
  if (!this.uvLockPath || !this.uvProjectDir) {
5909
- throw new import_build_utils7.NowBuildError({
5910
- code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
5911
- message: "Runtime dependency installation requires a uv.lock file and project directory."
5912
- });
5915
+ throw new Error(
5916
+ "generateBundle() requires uvLockPath and uvProjectDir to be set"
5917
+ );
5913
5918
  }
5914
5919
  const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
5915
- console.log(
5916
- `Bundle size (${totalBundleSizeMB} MB) exceeds limit. Enabling runtime dependency installation.`
5917
- );
5920
+ const largeFunctionsEnabled = isLargeFunctionsEnabled();
5918
5921
  if (this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
5919
- const ephemeralLimitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(0);
5922
+ if (largeFunctionsEnabled) {
5923
+ return this.bundleAllForHive(files);
5924
+ }
5925
+ const limitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(
5926
+ 0
5927
+ );
5920
5928
  throw new import_build_utils7.NowBuildError({
5921
5929
  code: "LAMBDA_SIZE_EXCEEDED",
5922
- message: `Total bundle size (${totalBundleSizeMB} MB) exceeds Lambda ephemeral storage limit (${ephemeralLimitMB} MB).
5930
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
5923
5931
 
5924
- Even with runtime dependency installation, all packages must fit
5925
- within the ${ephemeralLimitMB} MB ephemeral storage available to Lambda
5926
- functions. Consider removing unused dependencies or splitting
5927
- your application into smaller functions.`,
5932
+ Reduce the size of your dependencies or split your application into
5933
+ smaller functions.`,
5928
5934
  link: BUNDLING_DOCS_LINK,
5929
5935
  action: "Learn More"
5930
5936
  });
5931
5937
  }
5938
+ const relLockPath = (0, import_path7.relative)(this.workPath, this.uvLockPath);
5932
5939
  let lockContent;
5933
5940
  try {
5934
5941
  lockContent = await readFile(this.uvLockPath, "utf8");
5935
5942
  } catch (error) {
5936
- if (error instanceof Error) {
5937
- console.log(
5938
- `Failed to read uv.lock file at "${this.uvLockPath}": ${error.message}`
5939
- );
5940
- } else {
5941
- console.log(
5942
- `Failed to read uv.lock file at "${this.uvLockPath}": ${String(error)}`
5943
- );
5944
- }
5943
+ (0, import_build_utils7.debug)(
5944
+ `Failed to read uv.lock at ${this.uvLockPath}: ${error instanceof Error ? error.message : String(error)}`
5945
+ );
5945
5946
  throw new import_build_utils7.NowBuildError({
5946
5947
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
5947
- message: `Failed to read uv.lock file at "${this.uvLockPath}"`
5948
+ message: `Failed to read the uv.lock file at "${relLockPath}".`
5948
5949
  });
5949
5950
  }
5950
5951
  let lockFile;
5951
5952
  try {
5952
- lockFile = (0, import_python_analysis3.parseUvLock)(lockContent, this.uvLockPath);
5953
+ lockFile = (0, import_python_analysis3.parseUvLock)(lockContent, relLockPath);
5953
5954
  } catch (error) {
5954
5955
  if (error instanceof import_python_analysis3.PythonAnalysisError) {
5955
5956
  if (error.fileContent) {
5956
- console.log(
5957
+ (0, import_build_utils7.debug)(
5957
5958
  `Failed to parse "${error.path}". File content:
5958
5959
  ${error.fileContent}`
5959
5960
  );
@@ -5995,19 +5996,18 @@ ${error.fileContent}`
5995
5996
  (name) => !forceBundledSet.has((0, import_python_analysis3.normalizePackageName)(name))
5996
5997
  );
5997
5998
  if (externalizablePublic.length === 0) {
5999
+ if (largeFunctionsEnabled) {
6000
+ return this.bundleAllForHive(files);
6001
+ }
5998
6002
  throw new import_build_utils7.NowBuildError({
5999
6003
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
6000
- message: `Bundle size exceeds the Lambda limit and requires runtime
6001
- dependency installation, but no public packages have compatible
6002
- pre-built wheels for the Lambda platform.
6003
-
6004
- Runtime dependency installation requires packages to have binary
6005
- wheels.
6004
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size and
6005
+ can't be optimized automatically because some dependencies don't
6006
+ provide a compatible pre-built wheel.
6006
6007
 
6007
6008
  To fix this, either:
6008
6009
  1. Regenerate your lock file with: uv lock --upgrade, or
6009
- 2. Switch the problematic packages to ones that have pre-built
6010
- wheels available.`
6010
+ 2. Replace the packages that don't provide a pre-built wheel.`
6011
6011
  });
6012
6012
  }
6013
6013
  const packageSizes = await this.calculatePerPackageSizes();
@@ -6052,6 +6052,12 @@ To fix this, either:
6052
6052
  (0, import_build_utils7.debug)(
6053
6053
  `Fixed overhead: ${(fixedOverhead / (1024 * 1024)).toFixed(2)} MB, runtime tooling: ${(runtimeToolingOverhead / (1024 * 1024)).toFixed(2)} MB, remaining capacity for public packages: ${(remainingCapacity / (1024 * 1024)).toFixed(2)} MB`
6054
6054
  );
6055
+ if (largeFunctionsEnabled && remainingCapacity < 0) {
6056
+ return this.bundleAllForHive(files);
6057
+ }
6058
+ console.log(
6059
+ `Bundle size (${totalBundleSizeMB} MB) exceeds the standard size; optimizing dependencies.`
6060
+ );
6055
6061
  const externalizableSet = new Set(
6056
6062
  externalizablePublic.map(import_python_analysis3.normalizePackageName)
6057
6063
  );
@@ -6105,27 +6111,54 @@ To fix this, either:
6105
6111
  });
6106
6112
  (0, import_build_utils7.debug)(`Bundled uv binary from ${uvBinaryPath} to ${uvLocalPath}`);
6107
6113
  } catch (err) {
6114
+ (0, import_build_utils7.debug)(
6115
+ `Failed to bundle uv binary: ${err instanceof Error ? err.message : String(err)}`
6116
+ );
6108
6117
  throw new import_build_utils7.NowBuildError({
6109
6118
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
6110
- message: `Failed to bundle uv binary for runtime installation: ${err instanceof Error ? err.message : String(err)}`
6119
+ message: "Failed to prepare dependency tooling."
6111
6120
  });
6112
6121
  }
6113
6122
  const finalBundleSize = await calculateBundleSize(files);
6114
6123
  if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES + 100 * 1024) {
6124
+ if (largeFunctionsEnabled) {
6125
+ return this.bundleAllForHive(files);
6126
+ }
6115
6127
  const finalSizeMB = (finalBundleSize / (1024 * 1024)).toFixed(2);
6116
6128
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
6117
6129
  throw new import_build_utils7.NowBuildError({
6118
6130
  code: "LAMBDA_SIZE_EXCEEDED",
6119
- message: `Total bundle size (${finalSizeMB} MB) exceeds Lambda limit (${limitMB} MB) even after
6120
- deferring public packages to runtime installation.
6131
+ message: `Total bundle size (${finalSizeMB} MB) exceeds the maximum function size (${limitMB} MB) even after
6132
+ optimizing dependencies.
6121
6133
 
6122
- This usually means your private packages or source code are too
6123
- large. Consider reducing the size of private dependencies or
6124
- splitting your application.`,
6134
+ This usually means your source code or private packages are too
6135
+ large. Reduce their size or split your application into smaller
6136
+ functions.`,
6125
6137
  link: BUNDLING_DOCS_LINK,
6126
6138
  action: "Learn More"
6127
6139
  });
6128
6140
  }
6141
+ return { fellBackToFullBundle: false };
6142
+ }
6143
+ /**
6144
+ * Discard any runtime-install artifacts added so far and bundle every
6145
+ * dependency directly, for a function that will run on Hive. Returns the
6146
+ * fell-back signal so the caller can apply the same compileall handling.
6147
+ */
6148
+ bundleAllForHive(files) {
6149
+ for (const key of [
6150
+ `${UV_BUNDLE_DIR}/_runtime_config.json`,
6151
+ `${UV_BUNDLE_DIR}/uv`,
6152
+ `${UV_BUNDLE_DIR}/pyproject.toml`,
6153
+ `${UV_BUNDLE_DIR}/uv.lock`
6154
+ ]) {
6155
+ delete files[key];
6156
+ }
6157
+ for (const [p, f] of Object.entries(this.allVendorFiles)) {
6158
+ files[p] = f;
6159
+ }
6160
+ (0, import_build_utils7.debug)("Bundling all dependencies for the large functions path.");
6161
+ return { fellBackToFullBundle: true };
6129
6162
  }
6130
6163
  /**
6131
6164
  * Identify public packages that have no compatible wheel for the Lambda platform.
@@ -8939,6 +8972,29 @@ function getTargetPlatform(isDev) {
8939
8972
  }
8940
8973
  return { uvPlatform: UV_LINUX_TARGET, architecture: "x86_64" };
8941
8974
  }
8975
+ async function getPythonLambdaOptions({
8976
+ config,
8977
+ entrypoint
8978
+ }) {
8979
+ if (!config?.functions) {
8980
+ return {};
8981
+ }
8982
+ const sources = /* @__PURE__ */ new Set([entrypoint]);
8983
+ if (entrypoint.endsWith(".py")) {
8984
+ sources.add(entrypoint.slice(0, -".py".length));
8985
+ }
8986
+ for (const sourceFile of sources) {
8987
+ const lambdaOptions = await (0, import_build_utils19.getLambdaOptionsFromFunction)({
8988
+ sourceFile,
8989
+ config
8990
+ });
8991
+ if (Object.keys(lambdaOptions).length > 0) {
8992
+ delete lambdaOptions.architecture;
8993
+ return lambdaOptions;
8994
+ }
8995
+ }
8996
+ return {};
8997
+ }
8942
8998
  async function installInjectedPackage({
8943
8999
  name,
8944
9000
  pinned,
@@ -8985,6 +9041,7 @@ var build = async ({
8985
9041
  let spawnEnv;
8986
9042
  let projectInstallCommand;
8987
9043
  let hasCustomCommand = false;
9044
+ let hasCustomBuildCommand = false;
8988
9045
  const target = getTargetPlatform(meta.isDev ?? false);
8989
9046
  (0, import_build_utils19.debug)(`workPath: ${workPath}`);
8990
9047
  workPath = await downloadFilesInWorkPath({
@@ -9190,12 +9247,16 @@ var build = async ({
9190
9247
  env: pythonEnv,
9191
9248
  cwd: workPath
9192
9249
  });
9250
+ hasCustomBuildCommand = true;
9193
9251
  } else {
9194
- await runPyprojectScript(
9252
+ const ranBuildScript = await runPyprojectScript(
9195
9253
  workPath,
9196
9254
  ["vercel-build", "now-build", "build"],
9197
9255
  pythonEnv
9198
9256
  );
9257
+ if (ranBuildScript) {
9258
+ hasCustomBuildCommand = true;
9259
+ }
9199
9260
  }
9200
9261
  });
9201
9262
  }
@@ -9302,7 +9363,8 @@ var build = async ({
9302
9363
  });
9303
9364
  const automaticCompileAllEnabled = shouldUseCompileAll({
9304
9365
  isDev: meta.isDev,
9305
- hasCustomCommand
9366
+ hasCustomCommand,
9367
+ hasCustomBuildCommand
9306
9368
  });
9307
9369
  const predefinedExcludes = [
9308
9370
  ".git/**",
@@ -9371,61 +9433,74 @@ var build = async ({
9371
9433
  });
9372
9434
  }
9373
9435
  });
9374
- if (depAnalysis.runtimeInstallEnabled) {
9375
- await depExternalizer.generateBundle(files);
9376
- } else {
9377
- addFiles(files, depAnalysis.allVendorFiles);
9378
- if (automaticCompileAllEnabled) {
9379
- await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
9380
- const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
9381
- const pythonBin = getVenvPythonBin(venvPath);
9382
- console.log("Compiling Python application bytecode...");
9383
- await runCompileAll({
9384
- pythonBin,
9385
- filesOrDirectories: [workPath],
9386
- env: pythonEnv,
9387
- excludeRegex: getCompileAllAppExcludeRegex(workPath)
9388
- });
9389
- console.log("Compiling Python dependency bytecode...");
9390
- await runCompileAll({
9391
- pythonBin,
9392
- filesOrDirectories: sitePackageDirs,
9393
- env: pythonEnv
9394
- });
9395
- compileSpan.setAttributes({
9396
- "python.compileall.enabled": "true",
9397
- "python.compileall.sitePackageDirectoryCount": String(
9398
- sitePackageDirs.length
9399
- )
9400
- });
9436
+ const runCompileAllAndFillBytecode = async () => {
9437
+ await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
9438
+ const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
9439
+ const pythonBin = getVenvPythonBin(venvPath);
9440
+ console.log("Compiling Python application bytecode...");
9441
+ await runCompileAll({
9442
+ pythonBin,
9443
+ filesOrDirectories: [workPath],
9444
+ env: pythonEnv,
9445
+ excludeRegex: getCompileAllAppExcludeRegex(workPath)
9401
9446
  });
9402
- const currentSize = await calculateBundleSize(files);
9403
- let remainingCapacity = HIVE_LAMBDA_SIZE_BYTES - currentSize;
9404
- if (pythonVersion.major != null && pythonVersion.minor != null) {
9405
- const appBytecodeInfo = await collectAppBytecodeFiles({
9406
- workPath,
9407
- files,
9408
- pythonMajor: pythonVersion.major,
9409
- pythonMinor: pythonVersion.minor
9410
- });
9411
- remainingCapacity = addBytecodeWithinCapacity(
9412
- files,
9413
- appBytecodeInfo,
9414
- remainingCapacity
9415
- );
9416
- }
9417
- const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles(
9418
- {
9419
- vendorDirName: vendorDir
9420
- }
9421
- );
9422
- await addVendorBytecodeWithinCapacity({
9447
+ console.log("Compiling Python dependency bytecode...");
9448
+ await runCompileAll({
9449
+ pythonBin,
9450
+ filesOrDirectories: sitePackageDirs,
9451
+ env: pythonEnv
9452
+ });
9453
+ compileSpan.setAttributes({
9454
+ "python.compileall.enabled": "true",
9455
+ "python.compileall.sitePackageDirectoryCount": String(
9456
+ sitePackageDirs.length
9457
+ )
9458
+ });
9459
+ });
9460
+ const currentSize = await calculateBundleSize(files);
9461
+ let remainingCapacity = MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE - currentSize;
9462
+ if (pythonVersion.major != null && pythonVersion.minor != null) {
9463
+ const appBytecodeInfo = await collectAppBytecodeFiles({
9464
+ workPath,
9423
9465
  files,
9424
- depExternalizer,
9425
- vendorDir,
9426
- bytecodeInfo: vendorBytecodeInfo,
9427
- capacity: remainingCapacity
9466
+ pythonMajor: pythonVersion.major,
9467
+ pythonMinor: pythonVersion.minor
9428
9468
  });
9469
+ remainingCapacity = addBytecodeWithinCapacity(
9470
+ files,
9471
+ appBytecodeInfo,
9472
+ remainingCapacity
9473
+ );
9474
+ }
9475
+ const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles({
9476
+ vendorDirName: vendorDir
9477
+ });
9478
+ await addVendorBytecodeWithinCapacity({
9479
+ files,
9480
+ depExternalizer,
9481
+ vendorDir,
9482
+ bytecodeInfo: vendorBytecodeInfo,
9483
+ capacity: remainingCapacity
9484
+ });
9485
+ };
9486
+ const announceLargeFunction = () => console.log(
9487
+ `Function "${entrypoint}" exceeds the standard size limit; enabling large functions (beta).`
9488
+ );
9489
+ if (depAnalysis.runtimeInstallEnabled) {
9490
+ const { fellBackToFullBundle } = await depExternalizer.generateBundle(files);
9491
+ if (fellBackToFullBundle) {
9492
+ announceLargeFunction();
9493
+ if (automaticCompileAllEnabled) {
9494
+ await runCompileAllAndFillBytecode();
9495
+ }
9496
+ }
9497
+ } else {
9498
+ addFiles(files, depAnalysis.allVendorFiles);
9499
+ if (isLargeFunctionsEnabled() && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
9500
+ announceLargeFunction();
9501
+ }
9502
+ if (automaticCompileAllEnabled && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
9503
+ await runCompileAllAndFillBytecode();
9429
9504
  }
9430
9505
  }
9431
9506
  });
@@ -9433,10 +9508,15 @@ var build = async ({
9433
9508
  ...files,
9434
9509
  [`${handlerPyFilename}.py`]: new import_build_utils19.FileBlob({ data: runtimeTrampoline })
9435
9510
  };
9511
+ const lambdaOptions = await getPythonLambdaOptions({
9512
+ config,
9513
+ entrypoint
9514
+ });
9436
9515
  const output = new import_build_utils19.Lambda({
9437
9516
  files: webFiles,
9438
9517
  handler: `${handlerPyFilename}.vc_handler`,
9439
9518
  runtime: pythonVersion.runtime,
9519
+ ...lambdaOptions,
9440
9520
  architecture: target.architecture,
9441
9521
  environment: lambdaEnv,
9442
9522
  supportsResponseStreaming: true
@@ -9499,7 +9579,11 @@ var build = async ({
9499
9579
  }
9500
9580
  const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
9501
9581
  const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
9502
- const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
9582
+ const isNonWebService = service?.name && service.type && service.type !== "web";
9583
+ const routes = isNonWebService ? void 0 : [
9584
+ { handle: "filesystem" },
9585
+ { src: "/(.*)", dest: `/${lambdaPath}` }
9586
+ ];
9503
9587
  return {
9504
9588
  resultVersion: 2,
9505
9589
  result: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.47.0",
3
+ "version": "6.47.2",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -36,9 +36,9 @@
36
36
  "smol-toml": "1.5.2",
37
37
  "vitest": "2.1.4",
38
38
  "which": "3.0.0",
39
- "@vercel/build-utils": "13.30.0",
40
- "@vercel/python-runtime": "0.15.0",
41
- "@vercel/error-utils": "2.2.0"
39
+ "@vercel/error-utils": "2.2.0",
40
+ "@vercel/build-utils": "13.32.1",
41
+ "@vercel/python-runtime": "0.15.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "node ../../utils/build-builder.mjs",