@vercel/python 6.30.1 → 6.32.0

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 +30 -6
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -3582,7 +3582,9 @@ function useVirtualEnv(workPath, env, systemPython) {
3582
3582
  function createVenvEnv(venvPath, baseEnv = process.env, uvCacheDir) {
3583
3583
  const env = {
3584
3584
  ...getProtectedUvEnv(baseEnv, uvCacheDir),
3585
- VIRTUAL_ENV: venvPath
3585
+ VIRTUAL_ENV: venvPath,
3586
+ UV_PROJECT_ENVIRONMENT: venvPath,
3587
+ UV_NO_DEV: "true"
3586
3588
  };
3587
3589
  const binDir = getVenvBinDir(venvPath);
3588
3590
  const existingPath = env.PATH || process.env.PATH || "";
@@ -4310,6 +4312,7 @@ var import_python_analysis3 = require("@vercel/python-analysis");
4310
4312
  var readFile = (0, import_util.promisify)(import_fs5.default.readFile);
4311
4313
  var LAMBDA_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
4312
4314
  var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
4315
+ var HIVE_LAMBDA_SIZE_BYTES = 1 * 1024 * 1024 * 1024;
4313
4316
  var PythonDependencyExternalizer = class {
4314
4317
  constructor(options) {
4315
4318
  // Populated by analyze()
@@ -4375,6 +4378,15 @@ To resolve this, either:
4375
4378
  action: "Learn More"
4376
4379
  });
4377
4380
  }
4381
+ if (pythonOnHiveEnabled && this.totalBundleSize > HIVE_LAMBDA_SIZE_BYTES) {
4382
+ const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
4383
+ throw new import_build_utils5.NowBuildError({
4384
+ code: "LAMBDA_SIZE_EXCEEDED",
4385
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB). Consider removing unused dependencies or splitting your application into smaller functions.`,
4386
+ link: "https://vercel.com/docs/functions/runtimes/python#controlling-what-gets-bundled",
4387
+ action: "Learn More"
4388
+ });
4389
+ }
4378
4390
  return {
4379
4391
  runtimeInstallEnabled,
4380
4392
  allVendorFiles: this.allVendorFiles,
@@ -5236,8 +5248,9 @@ async function detectDjangoPythonEntrypoint(workPath) {
5236
5248
  }
5237
5249
  async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint, service) {
5238
5250
  if (configuredEntrypoint) {
5239
- const entrypoint = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
5240
- let varName = await checkEntrypoint(workPath, entrypoint);
5251
+ const { filePath: configEntryFile, varName: configEntryVar } = configuredEntrypoint;
5252
+ const entrypoint = configEntryFile.endsWith(".py") ? configEntryFile : `${configEntryFile}.py`;
5253
+ let varName = configEntryVar ?? await checkEntrypoint(workPath, entrypoint);
5241
5254
  if (!varName) {
5242
5255
  const isSpecialService = service?.type === "cron" || service?.type === "worker";
5243
5256
  if (isSpecialService) {
@@ -5811,10 +5824,16 @@ var startDevServer = async (opts) => {
5811
5824
  const env = { ...process.env, ...meta.env || {} };
5812
5825
  const entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
5813
5826
  let resolved;
5827
+ const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
5814
5828
  const detected = await detectPythonEntrypoint(
5815
5829
  framework,
5816
5830
  workPath,
5817
- entrypoint,
5831
+ entrypoint ? {
5832
+ filePath: entrypoint,
5833
+ // For cron services, the WSGI variable is always 'app' (created dynamically).
5834
+ // For other services, handlerFunction is used as the entrypoint variable name.
5835
+ varName: service?.type === "cron" ? void 0 : handlerFunction
5836
+ } : void 0,
5818
5837
  service
5819
5838
  );
5820
5839
  if (detected?.entrypoint) {
@@ -6731,10 +6750,16 @@ var build = async ({
6731
6750
  throw err;
6732
6751
  }
6733
6752
  let detected;
6753
+ const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
6734
6754
  detected = await detectPythonEntrypoint(
6735
6755
  config.framework,
6736
6756
  workPath,
6737
- entrypoint,
6757
+ entrypoint ? {
6758
+ filePath: entrypoint,
6759
+ // For cron services, the WSGI variable is always 'app' (created dynamically).
6760
+ // For other services, handlerFunction is used as the entrypoint variable name.
6761
+ varName: service?.type === "cron" ? void 0 : handlerFunction
6762
+ } : void 0,
6738
6763
  service
6739
6764
  ) ?? void 0;
6740
6765
  if (detected?.error && detected?.baseDir === void 0) {
@@ -6957,7 +6982,6 @@ var build = async ({
6957
6982
  }
6958
6983
  (0, import_build_utils15.debug)("Entrypoint is", entrypoint);
6959
6984
  const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
6960
- const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
6961
6985
  if (handlerFunction) {
6962
6986
  const entrypointPath = (0, import_path13.join)(workPath, entrypoint);
6963
6987
  const source = await import_fs12.default.promises.readFile(entrypointPath, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.30.1",
3
+ "version": "6.32.0",
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.14.2",
40
- "@vercel/error-utils": "2.0.3",
41
- "@vercel/python-runtime": "0.12.0"
39
+ "@vercel/build-utils": "13.16.0",
40
+ "@vercel/python-runtime": "0.12.0",
41
+ "@vercel/error-utils": "2.0.3"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "node ../../utils/build-builder.mjs",