@vercel/python 25.1.0 → 25.1.3
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 +111 -70
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5032,7 +5032,7 @@ var import_fs20 = __toESM(require("fs"));
|
|
|
5032
5032
|
var import_path21 = require("path");
|
|
5033
5033
|
|
|
5034
5034
|
// src/package-versions.ts
|
|
5035
|
-
var VERCEL_RUNTIME_VERSION = "0.23.
|
|
5035
|
+
var VERCEL_RUNTIME_VERSION = "0.23.3";
|
|
5036
5036
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
5037
5037
|
|
|
5038
5038
|
// src/conditional-vendoring.ts
|
|
@@ -5366,12 +5366,13 @@ var import_execa4 = __toESM(require_execa());
|
|
|
5366
5366
|
var import_fs5 = __toESM(require("fs"));
|
|
5367
5367
|
var import_path6 = require("path");
|
|
5368
5368
|
var import_build_utils6 = require("@vercel/build-utils");
|
|
5369
|
-
var
|
|
5369
|
+
var import_python_analysis5 = require("@vercel/python-analysis");
|
|
5370
5370
|
|
|
5371
5371
|
// src/utils.ts
|
|
5372
5372
|
var import_fs3 = __toESM(require("fs"));
|
|
5373
5373
|
var import_path4 = require("path");
|
|
5374
5374
|
var import_build_utils3 = require("@vercel/build-utils");
|
|
5375
|
+
var import_python_analysis3 = require("@vercel/python-analysis");
|
|
5375
5376
|
var import_execa3 = __toESM(require_execa());
|
|
5376
5377
|
|
|
5377
5378
|
// src/uv.ts
|
|
@@ -5956,6 +5957,22 @@ async function ensureVenv({
|
|
|
5956
5957
|
await (0, import_execa3.default)(pythonVersion.pythonPath, ["-m", "venv", venvPath]);
|
|
5957
5958
|
}
|
|
5958
5959
|
}
|
|
5960
|
+
var BUILD_ONLY_SEED_PACKAGES = ["pip"];
|
|
5961
|
+
async function getSeedPackagesMissingFromLock(uvLockPath) {
|
|
5962
|
+
let lockedPackages;
|
|
5963
|
+
try {
|
|
5964
|
+
const content = await import_fs3.default.promises.readFile(uvLockPath, "utf8");
|
|
5965
|
+
lockedPackages = new Set(
|
|
5966
|
+
(0, import_python_analysis3.parseUvLock)(content, uvLockPath).packages.map(
|
|
5967
|
+
(pkg) => (0, import_python_analysis3.normalizePackageName)(pkg.name)
|
|
5968
|
+
)
|
|
5969
|
+
);
|
|
5970
|
+
} catch (err) {
|
|
5971
|
+
(0, import_build_utils3.debug)(`could not read lock file "${uvLockPath}" for seed packages: ${err}`);
|
|
5972
|
+
return [];
|
|
5973
|
+
}
|
|
5974
|
+
return BUILD_ONLY_SEED_PACKAGES.filter((name) => !lockedPackages.has(name));
|
|
5975
|
+
}
|
|
5959
5976
|
function getVenvPythonBin(venvPath) {
|
|
5960
5977
|
return (0, import_path4.join)(getVenvBinDir(venvPath), isWin2 ? "python.exe" : "python");
|
|
5961
5978
|
}
|
|
@@ -5996,7 +6013,7 @@ async function runPyprojectScript(workPath, scriptNames, env, useUserVirtualEnv
|
|
|
5996
6013
|
var import_path5 = require("path");
|
|
5997
6014
|
var import_fs4 = require("fs");
|
|
5998
6015
|
var import_build_utils5 = require("@vercel/build-utils");
|
|
5999
|
-
var
|
|
6016
|
+
var import_python_analysis4 = require("@vercel/python-analysis");
|
|
6000
6017
|
|
|
6001
6018
|
// src/platform-info.ts
|
|
6002
6019
|
var import_os2 = __toESM(require("os"));
|
|
@@ -6207,7 +6224,7 @@ function resolvePythonVersion({
|
|
|
6207
6224
|
const defaultBuild = toPythonBuild(defaultPv);
|
|
6208
6225
|
const availableBuilds = getAvailablePythonBuilds();
|
|
6209
6226
|
const allBuilds = getAllPythonBuilds();
|
|
6210
|
-
const result = (0,
|
|
6227
|
+
const result = (0, import_python_analysis4.selectPythonVersion)({
|
|
6211
6228
|
constraints,
|
|
6212
6229
|
availableBuilds,
|
|
6213
6230
|
allBuilds,
|
|
@@ -6266,7 +6283,7 @@ function resolvePythonVersion({
|
|
|
6266
6283
|
}
|
|
6267
6284
|
let pinVersionFilePath;
|
|
6268
6285
|
const hasPythonVersionFile = pythonPackage.configs?.some(
|
|
6269
|
-
(configSet) => configSet[
|
|
6286
|
+
(configSet) => configSet[import_python_analysis4.PythonConfigKind.PythonVersion] !== void 0
|
|
6270
6287
|
) ?? false;
|
|
6271
6288
|
if (!hasPythonVersionFile && pythonPackage.manifest && versionLessOrEqual(selection, defaultPv)) {
|
|
6272
6289
|
if (autoUpgraded || !pythonPackage.manifest.origin && source?.endsWith("pyproject.toml")) {
|
|
@@ -6425,9 +6442,9 @@ async function discoverPackage({
|
|
|
6425
6442
|
rootDir
|
|
6426
6443
|
}) {
|
|
6427
6444
|
try {
|
|
6428
|
-
return await (0,
|
|
6445
|
+
return await (0, import_python_analysis5.discoverPythonPackage)({ entrypointDir, rootDir });
|
|
6429
6446
|
} catch (error) {
|
|
6430
|
-
if (error instanceof
|
|
6447
|
+
if (error instanceof import_python_analysis5.PythonAnalysisError) {
|
|
6431
6448
|
if (error.fileContent && (error.code.endsWith("_PARSE_ERROR") || error.code.endsWith("_VALIDATION_ERROR"))) {
|
|
6432
6449
|
console.log(
|
|
6433
6450
|
`Failed to parse "${error.path}". File content:
|
|
@@ -6449,10 +6466,10 @@ function detectInstallSource(pythonPackage, rootDir) {
|
|
|
6449
6466
|
let manifestPath = null;
|
|
6450
6467
|
const lockFile = pythonPackage.manifest?.lockFile ?? pythonPackage.workspaceLockFile;
|
|
6451
6468
|
if (lockFile) {
|
|
6452
|
-
if (lockFile.kind ===
|
|
6469
|
+
if (lockFile.kind === import_python_analysis5.PythonLockFileKind.UvLock) {
|
|
6453
6470
|
manifestType = "uv.lock";
|
|
6454
6471
|
manifestPath = (0, import_path6.join)(rootDir, lockFile.path);
|
|
6455
|
-
} else if (lockFile.kind ===
|
|
6472
|
+
} else if (lockFile.kind === import_python_analysis5.PythonLockFileKind.PylockToml) {
|
|
6456
6473
|
manifestType = "pylock.toml";
|
|
6457
6474
|
manifestPath = (0, import_path6.join)(rootDir, lockFile.path);
|
|
6458
6475
|
}
|
|
@@ -6499,11 +6516,11 @@ async function ensureUvProject({
|
|
|
6499
6516
|
projectDir = (0, import_path6.join)(rootDir, (0, import_path6.dirname)(manifest.path));
|
|
6500
6517
|
pyprojectPath = (0, import_path6.join)(rootDir, manifest.path);
|
|
6501
6518
|
const originKind = manifest.origin?.kind;
|
|
6502
|
-
if (originKind ===
|
|
6519
|
+
if (originKind === import_python_analysis5.PythonManifestConvertedKind.Pipfile) {
|
|
6503
6520
|
console.log("Installing required dependencies from Pipfile...");
|
|
6504
|
-
} else if (originKind ===
|
|
6521
|
+
} else if (originKind === import_python_analysis5.PythonManifestConvertedKind.PipfileLock) {
|
|
6505
6522
|
console.log("Installing required dependencies from Pipfile.lock...");
|
|
6506
|
-
} else if (originKind ===
|
|
6523
|
+
} else if (originKind === import_python_analysis5.PythonManifestConvertedKind.RequirementsTxt || originKind === import_python_analysis5.PythonManifestConvertedKind.RequirementsIn) {
|
|
6507
6524
|
console.log(
|
|
6508
6525
|
`Installing required dependencies from ${manifest.origin?.path ?? "requirements.txt"}...`
|
|
6509
6526
|
);
|
|
@@ -6514,7 +6531,7 @@ async function ensureUvProject({
|
|
|
6514
6531
|
if (manifest.data.project && pythonVersion !== void 0) {
|
|
6515
6532
|
manifest.data.project["requires-python"] = `~=${pythonVersion}.0`;
|
|
6516
6533
|
}
|
|
6517
|
-
const content = (0,
|
|
6534
|
+
const content = (0, import_python_analysis5.stringifyManifest)(manifest.data);
|
|
6518
6535
|
pyprojectPath = (0, import_path6.join)(projectDir, "pyproject.toml");
|
|
6519
6536
|
await import_fs5.default.promises.writeFile(pyprojectPath, content);
|
|
6520
6537
|
}
|
|
@@ -6537,12 +6554,12 @@ async function ensureUvProject({
|
|
|
6537
6554
|
"No Python manifest found; creating an empty pyproject.toml and uv.lock..."
|
|
6538
6555
|
);
|
|
6539
6556
|
const requiresPython = pythonVersion !== void 0 ? `~=${pythonVersion}.0` : `>=${DEFAULT_PYTHON_VERSION_STRING}`;
|
|
6540
|
-
const minimalManifest = (0,
|
|
6557
|
+
const minimalManifest = (0, import_python_analysis5.createMinimalManifest)({
|
|
6541
6558
|
name: "app",
|
|
6542
6559
|
requiresPython,
|
|
6543
6560
|
dependencies: []
|
|
6544
6561
|
});
|
|
6545
|
-
const content = (0,
|
|
6562
|
+
const content = (0, import_python_analysis5.stringifyManifest)(minimalManifest);
|
|
6546
6563
|
await import_fs5.default.promises.writeFile(pyprojectPath, content);
|
|
6547
6564
|
await restoreCachedLock(cachedLockPath, projectDir);
|
|
6548
6565
|
await uv.lock({
|
|
@@ -6656,7 +6673,7 @@ var import_fs6 = __toESM(require("fs"));
|
|
|
6656
6673
|
var import_util = require("util");
|
|
6657
6674
|
var import_path7 = require("path");
|
|
6658
6675
|
var import_build_utils7 = require("@vercel/build-utils");
|
|
6659
|
-
var
|
|
6676
|
+
var import_python_analysis6 = require("@vercel/python-analysis");
|
|
6660
6677
|
|
|
6661
6678
|
// src/large-functions.ts
|
|
6662
6679
|
function isLargeFunctionsEnabled() {
|
|
@@ -6818,9 +6835,9 @@ smaller functions.`,
|
|
|
6818
6835
|
}
|
|
6819
6836
|
let lockFile;
|
|
6820
6837
|
try {
|
|
6821
|
-
lockFile = (0,
|
|
6838
|
+
lockFile = (0, import_python_analysis6.parseUvLock)(lockContent, relLockPath);
|
|
6822
6839
|
} catch (error) {
|
|
6823
|
-
if (error instanceof
|
|
6840
|
+
if (error instanceof import_python_analysis6.PythonAnalysisError) {
|
|
6824
6841
|
if (error.fileContent) {
|
|
6825
6842
|
(0, import_build_utils7.debug)(
|
|
6826
6843
|
`Failed to parse "${error.path}". File content:
|
|
@@ -6841,7 +6858,7 @@ ${error.fileContent}`
|
|
|
6841
6858
|
`Excluding project package "${this.projectName}" from runtime installation`
|
|
6842
6859
|
);
|
|
6843
6860
|
}
|
|
6844
|
-
const classification = (0,
|
|
6861
|
+
const classification = (0, import_python_analysis6.classifyPackages)({
|
|
6845
6862
|
lockFile,
|
|
6846
6863
|
excludePackages
|
|
6847
6864
|
});
|
|
@@ -6858,10 +6875,10 @@ ${error.fileContent}`
|
|
|
6858
6875
|
);
|
|
6859
6876
|
}
|
|
6860
6877
|
const forceBundledSet = new Set(
|
|
6861
|
-
forceBundledDueToWheels.map(
|
|
6878
|
+
forceBundledDueToWheels.map(import_python_analysis6.normalizePackageName)
|
|
6862
6879
|
);
|
|
6863
6880
|
const externalizablePublic = classification.publicPackages.filter(
|
|
6864
|
-
(name) => !forceBundledSet.has((0,
|
|
6881
|
+
(name) => !forceBundledSet.has((0, import_python_analysis6.normalizePackageName)(name))
|
|
6865
6882
|
);
|
|
6866
6883
|
if (externalizablePublic.length === 0) {
|
|
6867
6884
|
if (largeFunctionsEnabled) {
|
|
@@ -6927,11 +6944,11 @@ To fix this, either:
|
|
|
6927
6944
|
`Bundle size (${totalBundleSizeMB} MB) exceeds the standard size; optimizing dependencies.`
|
|
6928
6945
|
);
|
|
6929
6946
|
const externalizableSet = new Set(
|
|
6930
|
-
externalizablePublic.map(
|
|
6947
|
+
externalizablePublic.map(import_python_analysis6.normalizePackageName)
|
|
6931
6948
|
);
|
|
6932
6949
|
const publicPackageSizes = new Map(
|
|
6933
6950
|
[...packageSizes].filter(
|
|
6934
|
-
([name]) => externalizableSet.has((0,
|
|
6951
|
+
([name]) => externalizableSet.has((0, import_python_analysis6.normalizePackageName)(name))
|
|
6935
6952
|
)
|
|
6936
6953
|
);
|
|
6937
6954
|
const { packingMode, bundledPublic } = planPublicPackagePacking({
|
|
@@ -6944,9 +6961,9 @@ To fix this, either:
|
|
|
6944
6961
|
`bytecode-first packing disabled: the public package set exceeds the ephemeral install budget (${(EPHEMERAL_INSTALL_BUDGET_BYTES / (1024 * 1024)).toFixed(2)} MB); falling back to knapsack packing`
|
|
6945
6962
|
);
|
|
6946
6963
|
}
|
|
6947
|
-
const bundledPublicSet = new Set(bundledPublic.map(
|
|
6964
|
+
const bundledPublicSet = new Set(bundledPublic.map(import_python_analysis6.normalizePackageName));
|
|
6948
6965
|
const externalizedPublic = externalizablePublic.filter(
|
|
6949
|
-
(name) => !bundledPublicSet.has((0,
|
|
6966
|
+
(name) => !bundledPublicSet.has((0, import_python_analysis6.normalizePackageName)(name))
|
|
6950
6967
|
);
|
|
6951
6968
|
const allBundledPackages = [...alwaysBundled, ...bundledPublic];
|
|
6952
6969
|
const selectedVendorFiles = await this.installedDistributions.mirrorPackagesIntoVendor({
|
|
@@ -7084,24 +7101,24 @@ functions.`,
|
|
|
7084
7101
|
platform.archName
|
|
7085
7102
|
);
|
|
7086
7103
|
const relevantPackages = reachable ? publicPackageNames.filter(
|
|
7087
|
-
(name) => reachable.has((0,
|
|
7104
|
+
(name) => reachable.has((0, import_python_analysis6.normalizePackageName)(name))
|
|
7088
7105
|
) : publicPackageNames;
|
|
7089
7106
|
if (relevantPackages.length < publicPackageNames.length) {
|
|
7090
7107
|
(0, import_build_utils7.debug)(
|
|
7091
7108
|
`Skipping wheel check for ${publicPackageNames.length - relevantPackages.length} package(s) not reachable on the target platform`
|
|
7092
7109
|
);
|
|
7093
7110
|
}
|
|
7094
|
-
const publicSet = new Set(relevantPackages.map(
|
|
7111
|
+
const publicSet = new Set(relevantPackages.map(import_python_analysis6.normalizePackageName));
|
|
7095
7112
|
const packageWheels = /* @__PURE__ */ new Map();
|
|
7096
7113
|
for (const pkg of lockFile.packages) {
|
|
7097
|
-
const normalized = (0,
|
|
7114
|
+
const normalized = (0, import_python_analysis6.normalizePackageName)(pkg.name);
|
|
7098
7115
|
if (publicSet.has(normalized) && pkg.wheels.length > 0) {
|
|
7099
7116
|
packageWheels.set(normalized, pkg.wheels);
|
|
7100
7117
|
}
|
|
7101
7118
|
}
|
|
7102
7119
|
const incompatible = [];
|
|
7103
7120
|
for (const name of relevantPackages) {
|
|
7104
|
-
const normalized = (0,
|
|
7121
|
+
const normalized = (0, import_python_analysis6.normalizePackageName)(name);
|
|
7105
7122
|
const wheels = packageWheels.get(normalized);
|
|
7106
7123
|
if (!wheels || wheels.length === 0) {
|
|
7107
7124
|
incompatible.push(name);
|
|
@@ -7113,7 +7130,7 @@ functions.`,
|
|
|
7113
7130
|
if (!filename || !filename.endsWith(".whl"))
|
|
7114
7131
|
continue;
|
|
7115
7132
|
try {
|
|
7116
|
-
const compatible = await (0,
|
|
7133
|
+
const compatible = await (0, import_python_analysis6.isWheelCompatible)(
|
|
7117
7134
|
filename,
|
|
7118
7135
|
this.pythonVersion.major,
|
|
7119
7136
|
this.pythonVersion.minor,
|
|
@@ -7151,10 +7168,10 @@ functions.`,
|
|
|
7151
7168
|
async function getPackagesReachableOnPlatform(lockFile, projectName, pythonMajor, pythonMinor, sysPlatform, platformMachine) {
|
|
7152
7169
|
if (!projectName)
|
|
7153
7170
|
return null;
|
|
7154
|
-
const rootNormalized = (0,
|
|
7171
|
+
const rootNormalized = (0, import_python_analysis6.normalizePackageName)(projectName);
|
|
7155
7172
|
const packageMap = /* @__PURE__ */ new Map();
|
|
7156
7173
|
for (const pkg of lockFile.packages) {
|
|
7157
|
-
packageMap.set((0,
|
|
7174
|
+
packageMap.set((0, import_python_analysis6.normalizePackageName)(pkg.name), pkg);
|
|
7158
7175
|
}
|
|
7159
7176
|
const rootPkg = packageMap.get(rootNormalized);
|
|
7160
7177
|
if (!rootPkg)
|
|
@@ -7166,12 +7183,12 @@ async function getPackagesReachableOnPlatform(lockFile, projectName, pythonMajor
|
|
|
7166
7183
|
if (!pkg.dependencies)
|
|
7167
7184
|
return;
|
|
7168
7185
|
for (const dep of pkg.dependencies) {
|
|
7169
|
-
const normalized = (0,
|
|
7186
|
+
const normalized = (0, import_python_analysis6.normalizePackageName)(dep.name);
|
|
7170
7187
|
if (visited.has(normalized))
|
|
7171
7188
|
continue;
|
|
7172
7189
|
if (dep.marker) {
|
|
7173
7190
|
try {
|
|
7174
|
-
const compatible = await (0,
|
|
7191
|
+
const compatible = await (0, import_python_analysis6.evaluateMarker)(
|
|
7175
7192
|
dep.marker,
|
|
7176
7193
|
pythonMajor,
|
|
7177
7194
|
pythonMinor,
|
|
@@ -7278,7 +7295,7 @@ function planPublicPackagePacking({
|
|
|
7278
7295
|
// src/diagnostics.ts
|
|
7279
7296
|
var import_fs7 = __toESM(require("fs"));
|
|
7280
7297
|
var import_build_utils8 = require("@vercel/build-utils");
|
|
7281
|
-
var
|
|
7298
|
+
var import_python_analysis7 = require("@vercel/python-analysis");
|
|
7282
7299
|
function isDependencyGroupInclude(entry) {
|
|
7283
7300
|
return typeof entry === "object" && "include-group" in entry;
|
|
7284
7301
|
}
|
|
@@ -7371,13 +7388,13 @@ async function generateProjectManifest({
|
|
|
7371
7388
|
allRawDeps.push({ dep, scope: "dev" });
|
|
7372
7389
|
}
|
|
7373
7390
|
}
|
|
7374
|
-
const allParsed = await (0,
|
|
7391
|
+
const allParsed = await (0, import_python_analysis7.parsePep508)(allRawDeps.map((d) => d.dep));
|
|
7375
7392
|
for (let i = 0; i < allRawDeps.length; i++) {
|
|
7376
7393
|
const parsed = allParsed[i];
|
|
7377
7394
|
if (!parsed)
|
|
7378
7395
|
continue;
|
|
7379
7396
|
const { dep, scope } = allRawDeps[i];
|
|
7380
|
-
const normalized = (0,
|
|
7397
|
+
const normalized = (0, import_python_analysis7.normalizePackageName)(parsed.name);
|
|
7381
7398
|
let scopes = directScopesMap.get(normalized);
|
|
7382
7399
|
if (!scopes) {
|
|
7383
7400
|
scopes = /* @__PURE__ */ new Set();
|
|
@@ -7392,15 +7409,15 @@ async function generateProjectManifest({
|
|
|
7392
7409
|
const transitiveEntries = [];
|
|
7393
7410
|
{
|
|
7394
7411
|
const content = await import_fs7.default.promises.readFile(uvLockPath, "utf-8");
|
|
7395
|
-
const uvLock = (0,
|
|
7412
|
+
const uvLock = (0, import_python_analysis7.parseUvLock)(content, uvLockPath);
|
|
7396
7413
|
const projectName = project?.name;
|
|
7397
7414
|
const excludeSet = new Set(
|
|
7398
|
-
projectName ? [(0,
|
|
7415
|
+
projectName ? [(0, import_python_analysis7.normalizePackageName)(projectName)] : []
|
|
7399
7416
|
);
|
|
7400
7417
|
const lockMap = /* @__PURE__ */ new Map();
|
|
7401
7418
|
const depGraph = /* @__PURE__ */ new Map();
|
|
7402
7419
|
for (const pkg of uvLock.packages) {
|
|
7403
|
-
const normalized = (0,
|
|
7420
|
+
const normalized = (0, import_python_analysis7.normalizePackageName)(pkg.name);
|
|
7404
7421
|
if (excludeSet.has(normalized))
|
|
7405
7422
|
continue;
|
|
7406
7423
|
if (pkg.source?.virtual)
|
|
@@ -7409,7 +7426,7 @@ async function generateProjectManifest({
|
|
|
7409
7426
|
if (pkg.dependencies) {
|
|
7410
7427
|
const deps = /* @__PURE__ */ new Set();
|
|
7411
7428
|
for (const d of pkg.dependencies) {
|
|
7412
|
-
deps.add((0,
|
|
7429
|
+
deps.add((0, import_python_analysis7.normalizePackageName)(d.name));
|
|
7413
7430
|
}
|
|
7414
7431
|
depGraph.set(normalized, deps);
|
|
7415
7432
|
}
|
|
@@ -7512,7 +7529,7 @@ var import_path8 = require("path");
|
|
|
7512
7529
|
var import_build_utils9 = require("@vercel/build-utils");
|
|
7513
7530
|
var import_build_utils10 = require("@vercel/build-utils");
|
|
7514
7531
|
var import_build_utils11 = require("@vercel/build-utils");
|
|
7515
|
-
var
|
|
7532
|
+
var import_python_analysis8 = require("@vercel/python-analysis");
|
|
7516
7533
|
var PYTHON_ENTRYPOINT_FILENAMES = [
|
|
7517
7534
|
"app",
|
|
7518
7535
|
"index",
|
|
@@ -7595,7 +7612,7 @@ async function checkEntrypoint(workPath, relPath) {
|
|
|
7595
7612
|
if (!await fileExists(absPath))
|
|
7596
7613
|
return null;
|
|
7597
7614
|
const content = await import_fs8.default.promises.readFile(absPath, "utf-8");
|
|
7598
|
-
return (0,
|
|
7615
|
+
return (0, import_python_analysis8.findAppOrHandler)(content);
|
|
7599
7616
|
}
|
|
7600
7617
|
async function findPythonFilesRecursive(dir, rootDir) {
|
|
7601
7618
|
const results = [];
|
|
@@ -7626,7 +7643,7 @@ async function findEntrypointCandidates(workPath) {
|
|
|
7626
7643
|
(0, import_path8.join)(workPath, relPath),
|
|
7627
7644
|
"utf-8"
|
|
7628
7645
|
);
|
|
7629
|
-
const varName = await (0,
|
|
7646
|
+
const varName = await (0, import_python_analysis8.findAppOrHandler)(content);
|
|
7630
7647
|
if (varName) {
|
|
7631
7648
|
candidates.push({ entrypoint: relPath, variableName: varName });
|
|
7632
7649
|
}
|
|
@@ -7725,7 +7742,7 @@ async function findValidEntrypoint(workPath, candidates) {
|
|
|
7725
7742
|
if (!await fileExists(absPath))
|
|
7726
7743
|
continue;
|
|
7727
7744
|
const content = await import_fs8.default.promises.readFile(absPath, "utf-8");
|
|
7728
|
-
const varName = await (0,
|
|
7745
|
+
const varName = await (0, import_python_analysis8.findAppOrHandler)(content);
|
|
7729
7746
|
if (varName) {
|
|
7730
7747
|
(0, import_build_utils10.debug)(`Detected Python entrypoint: ${candidate} (variable: ${varName})`);
|
|
7731
7748
|
return {
|
|
@@ -8120,7 +8137,7 @@ var import_util2 = require("util");
|
|
|
8120
8137
|
var import_build_utils15 = require("@vercel/build-utils");
|
|
8121
8138
|
var import_get_port = __toESM(require_get_port());
|
|
8122
8139
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
8123
|
-
var
|
|
8140
|
+
var import_python_analysis9 = require("@vercel/python-analysis");
|
|
8124
8141
|
|
|
8125
8142
|
// src/subscribers.ts
|
|
8126
8143
|
var import_path12 = require("path");
|
|
@@ -9041,7 +9058,7 @@ async function syncDependencies({
|
|
|
9041
9058
|
const syncDir = (0, import_path13.join)(workPath, ".vercel", "python", "sync");
|
|
9042
9059
|
(0, import_fs13.mkdirSync)(syncDir, { recursive: true });
|
|
9043
9060
|
const tempPyproject = (0, import_path13.join)(syncDir, "pyproject.toml");
|
|
9044
|
-
const content = (0,
|
|
9061
|
+
const content = (0, import_python_analysis9.stringifyManifest)(manifest.data);
|
|
9045
9062
|
(0, import_fs13.writeFileSync)(tempPyproject, content, "utf8");
|
|
9046
9063
|
manifestPath = tempPyproject;
|
|
9047
9064
|
(0, import_build_utils15.debug)(
|
|
@@ -9529,7 +9546,7 @@ var startProxyDevServer = async ({
|
|
|
9529
9546
|
restoreWarnings = silenceNodeWarnings();
|
|
9530
9547
|
installGlobalCleanupHandlers();
|
|
9531
9548
|
const proxySource = (0, import_fs13.readFileSync)((0, import_path13.join)(workPath, entrypoint), "utf8");
|
|
9532
|
-
if (!await (0,
|
|
9549
|
+
if (!await (0, import_python_analysis9.containsTopLevelCallable)(proxySource, handlerFunction)) {
|
|
9533
9550
|
throw new import_build_utils15.NowBuildError({
|
|
9534
9551
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
9535
9552
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
@@ -9978,7 +9995,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
9978
9995
|
|
|
9979
9996
|
// src/quirks/index.ts
|
|
9980
9997
|
var import_build_utils18 = require("@vercel/build-utils");
|
|
9981
|
-
var
|
|
9998
|
+
var import_python_analysis11 = require("@vercel/python-analysis");
|
|
9982
9999
|
|
|
9983
10000
|
// src/quirks/matplotlib.ts
|
|
9984
10001
|
var matplotlibQuirk = {
|
|
@@ -10058,7 +10075,7 @@ var import_fs15 = __toESM(require("fs"));
|
|
|
10058
10075
|
var import_path15 = require("path");
|
|
10059
10076
|
var import_execa7 = __toESM(require_execa());
|
|
10060
10077
|
var import_build_utils17 = require("@vercel/build-utils");
|
|
10061
|
-
var
|
|
10078
|
+
var import_python_analysis10 = require("@vercel/python-analysis");
|
|
10062
10079
|
function execErrorMessage(err) {
|
|
10063
10080
|
if (err != null && typeof err === "object" && "stderr" in err) {
|
|
10064
10081
|
const stderr = String(err.stderr);
|
|
@@ -10318,7 +10335,7 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
10318
10335
|
(0, import_path15.join)(sitePackages, "prisma"),
|
|
10319
10336
|
sitePackages
|
|
10320
10337
|
);
|
|
10321
|
-
const count = await (0,
|
|
10338
|
+
const count = await (0, import_python_analysis10.extendDistRecord)(sitePackages, "prisma", allFiles);
|
|
10322
10339
|
if (count > 0) {
|
|
10323
10340
|
(0, import_build_utils17.debug)(`Appended ${count} entries to prisma RECORD`);
|
|
10324
10341
|
}
|
|
@@ -10343,7 +10360,7 @@ var quirks = [litellmQuirk, prismaQuirk, matplotlibQuirk];
|
|
|
10343
10360
|
function toposortQuirks(activated) {
|
|
10344
10361
|
const nameToQuirk = /* @__PURE__ */ new Map();
|
|
10345
10362
|
for (const q of activated) {
|
|
10346
|
-
nameToQuirk.set((0,
|
|
10363
|
+
nameToQuirk.set((0, import_python_analysis11.normalizePackageName)(q.dependency), q);
|
|
10347
10364
|
}
|
|
10348
10365
|
const adj = /* @__PURE__ */ new Map();
|
|
10349
10366
|
const inDegree = /* @__PURE__ */ new Map();
|
|
@@ -10354,7 +10371,7 @@ function toposortQuirks(activated) {
|
|
|
10354
10371
|
for (const q of activated) {
|
|
10355
10372
|
if (q.runsBefore) {
|
|
10356
10373
|
for (const dep of q.runsBefore) {
|
|
10357
|
-
const target = nameToQuirk.get((0,
|
|
10374
|
+
const target = nameToQuirk.get((0, import_python_analysis11.normalizePackageName)(dep));
|
|
10358
10375
|
if (target) {
|
|
10359
10376
|
adj.get(q).add(target);
|
|
10360
10377
|
inDegree.set(target, inDegree.get(target) + 1);
|
|
@@ -10363,7 +10380,7 @@ function toposortQuirks(activated) {
|
|
|
10363
10380
|
}
|
|
10364
10381
|
if (q.runsAfter) {
|
|
10365
10382
|
for (const dep of q.runsAfter) {
|
|
10366
|
-
const source = nameToQuirk.get((0,
|
|
10383
|
+
const source = nameToQuirk.get((0, import_python_analysis11.normalizePackageName)(dep));
|
|
10367
10384
|
if (source) {
|
|
10368
10385
|
adj.get(source).add(q);
|
|
10369
10386
|
inDegree.set(q, inDegree.get(q) + 1);
|
|
@@ -10404,14 +10421,14 @@ async function runQuirks(ctx) {
|
|
|
10404
10421
|
const installedNames = /* @__PURE__ */ new Set();
|
|
10405
10422
|
const sitePackageDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
10406
10423
|
for (const dir of sitePackageDirs) {
|
|
10407
|
-
const distributions = await (0,
|
|
10424
|
+
const distributions = await (0, import_python_analysis11.scanDistributions)(dir);
|
|
10408
10425
|
for (const name of distributions.keys()) {
|
|
10409
|
-
installedNames.add((0,
|
|
10426
|
+
installedNames.add((0, import_python_analysis11.normalizePackageName)(name));
|
|
10410
10427
|
}
|
|
10411
10428
|
}
|
|
10412
10429
|
const activated = quirks.filter((quirk) => {
|
|
10413
10430
|
const installed = installedNames.has(
|
|
10414
|
-
(0,
|
|
10431
|
+
(0, import_python_analysis11.normalizePackageName)(quirk.dependency)
|
|
10415
10432
|
);
|
|
10416
10433
|
if (!installed) {
|
|
10417
10434
|
(0, import_build_utils18.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
|
|
@@ -10625,7 +10642,7 @@ function fastapiStaticOptions(installedDistributions) {
|
|
|
10625
10642
|
}
|
|
10626
10643
|
|
|
10627
10644
|
// src/index.ts
|
|
10628
|
-
var
|
|
10645
|
+
var import_python_analysis13 = require("@vercel/python-analysis");
|
|
10629
10646
|
|
|
10630
10647
|
// src/bytecode-packing.ts
|
|
10631
10648
|
function isBytecodeAnalysisDisabled() {
|
|
@@ -10925,7 +10942,7 @@ async function collectAppBytecodeFiles({
|
|
|
10925
10942
|
var import_fs19 = __toESM(require("fs"));
|
|
10926
10943
|
var import_path19 = require("path");
|
|
10927
10944
|
var import_build_utils22 = require("@vercel/build-utils");
|
|
10928
|
-
var
|
|
10945
|
+
var import_python_analysis12 = require("@vercel/python-analysis");
|
|
10929
10946
|
var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
10930
10947
|
"py.typed",
|
|
10931
10948
|
"WHEEL",
|
|
@@ -10951,7 +10968,7 @@ function getDistributionFileGroups({
|
|
|
10951
10968
|
if (includePackages?.length === 0) {
|
|
10952
10969
|
return [];
|
|
10953
10970
|
}
|
|
10954
|
-
const includeSet = includePackages ? new Set(includePackages.map(
|
|
10971
|
+
const includeSet = includePackages ? new Set(includePackages.map(import_python_analysis12.normalizePackageName)) : null;
|
|
10955
10972
|
const groups = [];
|
|
10956
10973
|
for (const dir of sitePackageDirs) {
|
|
10957
10974
|
const dirDistributions = distributions.get(dir);
|
|
@@ -10959,7 +10976,7 @@ function getDistributionFileGroups({
|
|
|
10959
10976
|
continue;
|
|
10960
10977
|
const sitePackagesDir = (0, import_path19.resolve)(dir);
|
|
10961
10978
|
for (const [name, distribution] of dirDistributions) {
|
|
10962
|
-
const packageName = (0,
|
|
10979
|
+
const packageName = (0, import_python_analysis12.normalizePackageName)(name);
|
|
10963
10980
|
if (includeSet && !includeSet.has(packageName))
|
|
10964
10981
|
continue;
|
|
10965
10982
|
const files = [];
|
|
@@ -10979,11 +10996,28 @@ function getDistributionFileGroups({
|
|
|
10979
10996
|
}
|
|
10980
10997
|
return groups;
|
|
10981
10998
|
}
|
|
10999
|
+
function withoutPackages(distributions, packageNames) {
|
|
11000
|
+
if (packageNames.length === 0) {
|
|
11001
|
+
return distributions;
|
|
11002
|
+
}
|
|
11003
|
+
const excluded = new Set(packageNames.map(import_python_analysis12.normalizePackageName));
|
|
11004
|
+
const filtered = /* @__PURE__ */ new Map();
|
|
11005
|
+
for (const [dir, index] of distributions) {
|
|
11006
|
+
filtered.set(
|
|
11007
|
+
dir,
|
|
11008
|
+
new Map(
|
|
11009
|
+
[...index].filter(([name]) => !excluded.has((0, import_python_analysis12.normalizePackageName)(name)))
|
|
11010
|
+
)
|
|
11011
|
+
);
|
|
11012
|
+
}
|
|
11013
|
+
return filtered;
|
|
11014
|
+
}
|
|
10982
11015
|
var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
10983
11016
|
static async load({
|
|
10984
11017
|
venvPath,
|
|
10985
11018
|
pythonMajor,
|
|
10986
|
-
pythonMinor
|
|
11019
|
+
pythonMinor,
|
|
11020
|
+
excludePackages
|
|
10987
11021
|
}) {
|
|
10988
11022
|
const sitePackageDirs = await getVenvSitePackagesDirs(venvPath);
|
|
10989
11023
|
const distributions = /* @__PURE__ */ new Map();
|
|
@@ -10993,18 +11027,22 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10993
11027
|
} catch {
|
|
10994
11028
|
continue;
|
|
10995
11029
|
}
|
|
10996
|
-
distributions.set(dir, await (0,
|
|
11030
|
+
distributions.set(dir, await (0, import_python_analysis12.scanDistributions)(dir));
|
|
10997
11031
|
}
|
|
10998
11032
|
return new _InstalledPythonDistributions({
|
|
10999
11033
|
sitePackageDirs,
|
|
11000
11034
|
distributions,
|
|
11001
11035
|
pythonMajor,
|
|
11002
|
-
pythonMinor
|
|
11036
|
+
pythonMinor,
|
|
11037
|
+
excludePackages
|
|
11003
11038
|
});
|
|
11004
11039
|
}
|
|
11005
11040
|
constructor(options) {
|
|
11006
11041
|
this.sitePackageDirs = options.sitePackageDirs;
|
|
11007
|
-
this.distributions =
|
|
11042
|
+
this.distributions = withoutPackages(
|
|
11043
|
+
options.distributions,
|
|
11044
|
+
options.excludePackages ?? []
|
|
11045
|
+
);
|
|
11008
11046
|
this.pythonMajor = options.pythonMajor;
|
|
11009
11047
|
this.pythonMinor = options.pythonMinor;
|
|
11010
11048
|
}
|
|
@@ -11020,7 +11058,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
11020
11058
|
* normalization), or null when the package is not found in the venv.
|
|
11021
11059
|
*/
|
|
11022
11060
|
getInstalledVersion(packageName) {
|
|
11023
|
-
const target = (0,
|
|
11061
|
+
const target = (0, import_python_analysis12.normalizePackageName)(packageName);
|
|
11024
11062
|
for (const index of this.distributions.values()) {
|
|
11025
11063
|
const dist = index.get(target);
|
|
11026
11064
|
if (dist)
|
|
@@ -11867,7 +11905,10 @@ async function packFunctionBundle({
|
|
|
11867
11905
|
const installedDistributions2 = await InstalledPythonDistributions.load({
|
|
11868
11906
|
venvPath,
|
|
11869
11907
|
pythonMajor: pythonVersion.major,
|
|
11870
|
-
pythonMinor: pythonVersion.minor
|
|
11908
|
+
pythonMinor: pythonVersion.minor,
|
|
11909
|
+
// Without a uv.lock (custom install commands), a seeded package may
|
|
11910
|
+
// be one the project installed on purpose, so it stays bundled.
|
|
11911
|
+
excludePackages: uvLockPath ? await getSeedPackagesMissingFromLock(uvLockPath) : []
|
|
11871
11912
|
});
|
|
11872
11913
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
11873
11914
|
installedDistributions: installedDistributions2,
|
|
@@ -11928,7 +11969,7 @@ async function packFunctionBundle({
|
|
|
11928
11969
|
try {
|
|
11929
11970
|
const sitePackageDirs = installedDistributions2.getSitePackageDirs();
|
|
11930
11971
|
const closure = await withTimeout(
|
|
11931
|
-
(0,
|
|
11972
|
+
(0, import_python_analysis13.collectImportClosure)(
|
|
11932
11973
|
getImportClosureOptions({
|
|
11933
11974
|
workPath,
|
|
11934
11975
|
entrypoint,
|
|
@@ -12194,7 +12235,7 @@ async function buildProxyMiddleware({
|
|
|
12194
12235
|
(0, import_path21.join)(workPath, entrypoint),
|
|
12195
12236
|
"utf-8"
|
|
12196
12237
|
);
|
|
12197
|
-
if (!await (0,
|
|
12238
|
+
if (!await (0, import_python_analysis13.containsTopLevelCallable)(proxySource, proxyHandlerFunction)) {
|
|
12198
12239
|
throw new import_build_utils24.NowBuildError({
|
|
12199
12240
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
12200
12241
|
message: `Handler function "${proxyHandlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
@@ -12770,7 +12811,7 @@ var build = async ({
|
|
|
12770
12811
|
if (handlerFunction) {
|
|
12771
12812
|
const entrypointPath = (0, import_path21.join)(workPath, entrypoint);
|
|
12772
12813
|
const source = await import_fs20.default.promises.readFile(entrypointPath, "utf-8");
|
|
12773
|
-
const found = await (0,
|
|
12814
|
+
const found = await (0, import_python_analysis13.containsTopLevelCallable)(source, handlerFunction);
|
|
12774
12815
|
if (!found) {
|
|
12775
12816
|
throw new import_build_utils24.NowBuildError({
|
|
12776
12817
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "25.1.
|
|
3
|
+
"version": "25.1.3",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@vercel/python-analysis": "0.15.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@vercel/build-utils": "14.21.
|
|
20
|
+
"@vercel/build-utils": "14.21.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@renovatebot/pep440": "4.2.1",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"smol-toml": "1.5.2",
|
|
38
38
|
"vitest": "4.1.10",
|
|
39
39
|
"which": "3.0.0",
|
|
40
|
+
"@vercel/build-utils": "14.21.3",
|
|
40
41
|
"@vercel/error-utils": "2.2.1",
|
|
41
|
-
"@vercel/
|
|
42
|
-
"@vercel/python-runtime": "0.23.2"
|
|
42
|
+
"@vercel/python-runtime": "0.23.3"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ../../utils/build-builder.mjs",
|