@vercel/python 6.47.0 → 6.47.1
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.
- package/dist/index.js +176 -120
- package/package.json +3 -3
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
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
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 (!
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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 && !
|
|
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
|
|
5869
|
+
message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
|
|
5867
5870
|
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
dependencies,
|
|
5871
|
-
|
|
5872
|
-
|
|
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 (
|
|
5879
|
-
const limitMB = (
|
|
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
|
|
5910
|
-
|
|
5911
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
5930
|
+
message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
|
|
5923
5931
|
|
|
5924
|
-
|
|
5925
|
-
|
|
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
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
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 "${
|
|
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,
|
|
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
|
-
|
|
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: `
|
|
6001
|
-
|
|
6002
|
-
pre-built
|
|
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.
|
|
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:
|
|
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
|
|
6120
|
-
|
|
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
|
|
6123
|
-
large.
|
|
6124
|
-
|
|
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.
|
|
@@ -8985,6 +9018,7 @@ var build = async ({
|
|
|
8985
9018
|
let spawnEnv;
|
|
8986
9019
|
let projectInstallCommand;
|
|
8987
9020
|
let hasCustomCommand = false;
|
|
9021
|
+
let hasCustomBuildCommand = false;
|
|
8988
9022
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
8989
9023
|
(0, import_build_utils19.debug)(`workPath: ${workPath}`);
|
|
8990
9024
|
workPath = await downloadFilesInWorkPath({
|
|
@@ -9190,12 +9224,16 @@ var build = async ({
|
|
|
9190
9224
|
env: pythonEnv,
|
|
9191
9225
|
cwd: workPath
|
|
9192
9226
|
});
|
|
9227
|
+
hasCustomBuildCommand = true;
|
|
9193
9228
|
} else {
|
|
9194
|
-
await runPyprojectScript(
|
|
9229
|
+
const ranBuildScript = await runPyprojectScript(
|
|
9195
9230
|
workPath,
|
|
9196
9231
|
["vercel-build", "now-build", "build"],
|
|
9197
9232
|
pythonEnv
|
|
9198
9233
|
);
|
|
9234
|
+
if (ranBuildScript) {
|
|
9235
|
+
hasCustomBuildCommand = true;
|
|
9236
|
+
}
|
|
9199
9237
|
}
|
|
9200
9238
|
});
|
|
9201
9239
|
}
|
|
@@ -9302,7 +9340,8 @@ var build = async ({
|
|
|
9302
9340
|
});
|
|
9303
9341
|
const automaticCompileAllEnabled = shouldUseCompileAll({
|
|
9304
9342
|
isDev: meta.isDev,
|
|
9305
|
-
hasCustomCommand
|
|
9343
|
+
hasCustomCommand,
|
|
9344
|
+
hasCustomBuildCommand
|
|
9306
9345
|
});
|
|
9307
9346
|
const predefinedExcludes = [
|
|
9308
9347
|
".git/**",
|
|
@@ -9371,61 +9410,74 @@ var build = async ({
|
|
|
9371
9410
|
});
|
|
9372
9411
|
}
|
|
9373
9412
|
});
|
|
9374
|
-
|
|
9375
|
-
await
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
await
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
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
|
-
});
|
|
9413
|
+
const runCompileAllAndFillBytecode = async () => {
|
|
9414
|
+
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
9415
|
+
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
|
|
9416
|
+
const pythonBin = getVenvPythonBin(venvPath);
|
|
9417
|
+
console.log("Compiling Python application bytecode...");
|
|
9418
|
+
await runCompileAll({
|
|
9419
|
+
pythonBin,
|
|
9420
|
+
filesOrDirectories: [workPath],
|
|
9421
|
+
env: pythonEnv,
|
|
9422
|
+
excludeRegex: getCompileAllAppExcludeRegex(workPath)
|
|
9401
9423
|
});
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
}
|
|
9421
|
-
);
|
|
9422
|
-
await addVendorBytecodeWithinCapacity({
|
|
9424
|
+
console.log("Compiling Python dependency bytecode...");
|
|
9425
|
+
await runCompileAll({
|
|
9426
|
+
pythonBin,
|
|
9427
|
+
filesOrDirectories: sitePackageDirs,
|
|
9428
|
+
env: pythonEnv
|
|
9429
|
+
});
|
|
9430
|
+
compileSpan.setAttributes({
|
|
9431
|
+
"python.compileall.enabled": "true",
|
|
9432
|
+
"python.compileall.sitePackageDirectoryCount": String(
|
|
9433
|
+
sitePackageDirs.length
|
|
9434
|
+
)
|
|
9435
|
+
});
|
|
9436
|
+
});
|
|
9437
|
+
const currentSize = await calculateBundleSize(files);
|
|
9438
|
+
let remainingCapacity = MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE - currentSize;
|
|
9439
|
+
if (pythonVersion.major != null && pythonVersion.minor != null) {
|
|
9440
|
+
const appBytecodeInfo = await collectAppBytecodeFiles({
|
|
9441
|
+
workPath,
|
|
9423
9442
|
files,
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
bytecodeInfo: vendorBytecodeInfo,
|
|
9427
|
-
capacity: remainingCapacity
|
|
9443
|
+
pythonMajor: pythonVersion.major,
|
|
9444
|
+
pythonMinor: pythonVersion.minor
|
|
9428
9445
|
});
|
|
9446
|
+
remainingCapacity = addBytecodeWithinCapacity(
|
|
9447
|
+
files,
|
|
9448
|
+
appBytecodeInfo,
|
|
9449
|
+
remainingCapacity
|
|
9450
|
+
);
|
|
9451
|
+
}
|
|
9452
|
+
const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles({
|
|
9453
|
+
vendorDirName: vendorDir
|
|
9454
|
+
});
|
|
9455
|
+
await addVendorBytecodeWithinCapacity({
|
|
9456
|
+
files,
|
|
9457
|
+
depExternalizer,
|
|
9458
|
+
vendorDir,
|
|
9459
|
+
bytecodeInfo: vendorBytecodeInfo,
|
|
9460
|
+
capacity: remainingCapacity
|
|
9461
|
+
});
|
|
9462
|
+
};
|
|
9463
|
+
const announceLargeFunction = () => console.log(
|
|
9464
|
+
`Function "${entrypoint}" exceeds the standard size limit; enabling large functions (beta).`
|
|
9465
|
+
);
|
|
9466
|
+
if (depAnalysis.runtimeInstallEnabled) {
|
|
9467
|
+
const { fellBackToFullBundle } = await depExternalizer.generateBundle(files);
|
|
9468
|
+
if (fellBackToFullBundle) {
|
|
9469
|
+
announceLargeFunction();
|
|
9470
|
+
if (automaticCompileAllEnabled) {
|
|
9471
|
+
await runCompileAllAndFillBytecode();
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9474
|
+
} else {
|
|
9475
|
+
addFiles(files, depAnalysis.allVendorFiles);
|
|
9476
|
+
if (isLargeFunctionsEnabled() && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
|
|
9477
|
+
announceLargeFunction();
|
|
9478
|
+
}
|
|
9479
|
+
if (automaticCompileAllEnabled && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
|
|
9480
|
+
await runCompileAllAndFillBytecode();
|
|
9429
9481
|
}
|
|
9430
9482
|
}
|
|
9431
9483
|
});
|
|
@@ -9499,7 +9551,11 @@ var build = async ({
|
|
|
9499
9551
|
}
|
|
9500
9552
|
const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
|
|
9501
9553
|
const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
|
|
9502
|
-
const
|
|
9554
|
+
const isNonWebService = service?.name && service.type && service.type !== "web";
|
|
9555
|
+
const routes = isNonWebService ? void 0 : [
|
|
9556
|
+
{ handle: "filesystem" },
|
|
9557
|
+
{ src: "/(.*)", dest: `/${lambdaPath}` }
|
|
9558
|
+
];
|
|
9503
9559
|
return {
|
|
9504
9560
|
resultVersion: 2,
|
|
9505
9561
|
result: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.47.
|
|
3
|
+
"version": "6.47.1",
|
|
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/
|
|
39
|
+
"@vercel/error-utils": "2.2.0",
|
|
40
40
|
"@vercel/python-runtime": "0.15.0",
|
|
41
|
-
"@vercel/
|
|
41
|
+
"@vercel/build-utils": "13.31.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "node ../../utils/build-builder.mjs",
|