@vercel/python 6.43.2 → 6.44.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.
- package/dist/index.js +716 -401
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ var require_windows = __commonJS({
|
|
|
48
48
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
|
|
49
49
|
module2.exports = isexe;
|
|
50
50
|
isexe.sync = sync;
|
|
51
|
-
var
|
|
51
|
+
var fs13 = require("fs");
|
|
52
52
|
function checkPathExt(path, options) {
|
|
53
53
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
54
54
|
if (!pathext) {
|
|
@@ -73,12 +73,12 @@ var require_windows = __commonJS({
|
|
|
73
73
|
return checkPathExt(path, options);
|
|
74
74
|
}
|
|
75
75
|
function isexe(path, options, cb) {
|
|
76
|
-
|
|
76
|
+
fs13.stat(path, function(er, stat) {
|
|
77
77
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function sync(path, options) {
|
|
81
|
-
return checkStat(
|
|
81
|
+
return checkStat(fs13.statSync(path), path, options);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
});
|
|
@@ -88,14 +88,14 @@ var require_mode = __commonJS({
|
|
|
88
88
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
|
|
89
89
|
module2.exports = isexe;
|
|
90
90
|
isexe.sync = sync;
|
|
91
|
-
var
|
|
91
|
+
var fs13 = require("fs");
|
|
92
92
|
function isexe(path, options, cb) {
|
|
93
|
-
|
|
93
|
+
fs13.stat(path, function(er, stat) {
|
|
94
94
|
cb(er, er ? false : checkStat(stat, options));
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function sync(path, options) {
|
|
98
|
-
return checkStat(
|
|
98
|
+
return checkStat(fs13.statSync(path), options);
|
|
99
99
|
}
|
|
100
100
|
function checkStat(stat, options) {
|
|
101
101
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
|
|
|
119
119
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
120
120
|
var require_isexe = __commonJS({
|
|
121
121
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
|
|
122
|
-
var
|
|
122
|
+
var fs13 = require("fs");
|
|
123
123
|
var core;
|
|
124
124
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
125
125
|
core = require_windows();
|
|
@@ -395,7 +395,7 @@ var require_shebang_command = __commonJS({
|
|
|
395
395
|
var require_readShebang = __commonJS({
|
|
396
396
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
|
|
397
397
|
"use strict";
|
|
398
|
-
var
|
|
398
|
+
var fs13 = require("fs");
|
|
399
399
|
var shebangCommand = require_shebang_command();
|
|
400
400
|
function readShebang(command) {
|
|
401
401
|
const size = 150;
|
|
@@ -408,9 +408,9 @@ var require_readShebang = __commonJS({
|
|
|
408
408
|
}
|
|
409
409
|
let fd;
|
|
410
410
|
try {
|
|
411
|
-
fd =
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
fd = fs13.openSync(command, "r");
|
|
412
|
+
fs13.readSync(fd, buffer, 0, size, 0);
|
|
413
|
+
fs13.closeSync(fd);
|
|
414
414
|
} catch (e) {
|
|
415
415
|
}
|
|
416
416
|
return shebangCommand(buffer.toString());
|
|
@@ -423,15 +423,15 @@ var require_readShebang = __commonJS({
|
|
|
423
423
|
var require_semver = __commonJS({
|
|
424
424
|
"../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js"(exports, module2) {
|
|
425
425
|
exports = module2.exports = SemVer;
|
|
426
|
-
var
|
|
426
|
+
var debug13;
|
|
427
427
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
428
|
-
|
|
428
|
+
debug13 = function() {
|
|
429
429
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
430
430
|
args.unshift("SEMVER");
|
|
431
431
|
console.log.apply(console, args);
|
|
432
432
|
};
|
|
433
433
|
} else {
|
|
434
|
-
|
|
434
|
+
debug13 = function() {
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
437
|
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
@@ -540,7 +540,7 @@ var require_semver = __commonJS({
|
|
|
540
540
|
var STAR = R++;
|
|
541
541
|
src[STAR] = "(<|>)?=?\\s*\\*";
|
|
542
542
|
for (i = 0; i < R; i++) {
|
|
543
|
-
|
|
543
|
+
debug13(i, src[i]);
|
|
544
544
|
if (!re[i]) {
|
|
545
545
|
re[i] = new RegExp(src[i]);
|
|
546
546
|
safeRe[i] = new RegExp(makeSafeRe(src[i]));
|
|
@@ -607,7 +607,7 @@ var require_semver = __commonJS({
|
|
|
607
607
|
if (!(this instanceof SemVer)) {
|
|
608
608
|
return new SemVer(version2, options);
|
|
609
609
|
}
|
|
610
|
-
|
|
610
|
+
debug13("SemVer", version2, options);
|
|
611
611
|
this.options = options;
|
|
612
612
|
this.loose = !!options.loose;
|
|
613
613
|
var m = version2.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
|
|
@@ -654,7 +654,7 @@ var require_semver = __commonJS({
|
|
|
654
654
|
return this.version;
|
|
655
655
|
};
|
|
656
656
|
SemVer.prototype.compare = function(other) {
|
|
657
|
-
|
|
657
|
+
debug13("SemVer.compare", this.version, this.options, other);
|
|
658
658
|
if (!(other instanceof SemVer)) {
|
|
659
659
|
other = new SemVer(other, this.options);
|
|
660
660
|
}
|
|
@@ -681,7 +681,7 @@ var require_semver = __commonJS({
|
|
|
681
681
|
do {
|
|
682
682
|
var a = this.prerelease[i2];
|
|
683
683
|
var b = other.prerelease[i2];
|
|
684
|
-
|
|
684
|
+
debug13("prerelease compare", i2, a, b);
|
|
685
685
|
if (a === void 0 && b === void 0) {
|
|
686
686
|
return 0;
|
|
687
687
|
} else if (b === void 0) {
|
|
@@ -935,7 +935,7 @@ var require_semver = __commonJS({
|
|
|
935
935
|
return new Comparator(comp, options);
|
|
936
936
|
}
|
|
937
937
|
comp = comp.trim().split(/\s+/).join(" ");
|
|
938
|
-
|
|
938
|
+
debug13("comparator", comp, options);
|
|
939
939
|
this.options = options;
|
|
940
940
|
this.loose = !!options.loose;
|
|
941
941
|
this.parse(comp);
|
|
@@ -944,7 +944,7 @@ var require_semver = __commonJS({
|
|
|
944
944
|
} else {
|
|
945
945
|
this.value = this.operator + this.semver.version;
|
|
946
946
|
}
|
|
947
|
-
|
|
947
|
+
debug13("comp", this);
|
|
948
948
|
}
|
|
949
949
|
var ANY = {};
|
|
950
950
|
Comparator.prototype.parse = function(comp) {
|
|
@@ -967,7 +967,7 @@ var require_semver = __commonJS({
|
|
|
967
967
|
return this.value;
|
|
968
968
|
};
|
|
969
969
|
Comparator.prototype.test = function(version2) {
|
|
970
|
-
|
|
970
|
+
debug13("Comparator.test", version2, this.options.loose);
|
|
971
971
|
if (this.semver === ANY) {
|
|
972
972
|
return true;
|
|
973
973
|
}
|
|
@@ -1050,9 +1050,9 @@ var require_semver = __commonJS({
|
|
|
1050
1050
|
var loose = this.options.loose;
|
|
1051
1051
|
var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
|
|
1052
1052
|
range = range.replace(hr, hyphenReplace);
|
|
1053
|
-
|
|
1053
|
+
debug13("hyphen replace", range);
|
|
1054
1054
|
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
|
|
1055
|
-
|
|
1055
|
+
debug13("comparator trim", range, safeRe[COMPARATORTRIM]);
|
|
1056
1056
|
range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
|
|
1057
1057
|
range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
|
|
1058
1058
|
var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
|
|
@@ -1092,15 +1092,15 @@ var require_semver = __commonJS({
|
|
|
1092
1092
|
});
|
|
1093
1093
|
}
|
|
1094
1094
|
function parseComparator(comp, options) {
|
|
1095
|
-
|
|
1095
|
+
debug13("comp", comp, options);
|
|
1096
1096
|
comp = replaceCarets(comp, options);
|
|
1097
|
-
|
|
1097
|
+
debug13("caret", comp);
|
|
1098
1098
|
comp = replaceTildes(comp, options);
|
|
1099
|
-
|
|
1099
|
+
debug13("tildes", comp);
|
|
1100
1100
|
comp = replaceXRanges(comp, options);
|
|
1101
|
-
|
|
1101
|
+
debug13("xrange", comp);
|
|
1102
1102
|
comp = replaceStars(comp, options);
|
|
1103
|
-
|
|
1103
|
+
debug13("stars", comp);
|
|
1104
1104
|
return comp;
|
|
1105
1105
|
}
|
|
1106
1106
|
function isX(id) {
|
|
@@ -1114,7 +1114,7 @@ var require_semver = __commonJS({
|
|
|
1114
1114
|
function replaceTilde(comp, options) {
|
|
1115
1115
|
var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
|
|
1116
1116
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
1117
|
-
|
|
1117
|
+
debug13("tilde", comp, _, M, m, p, pr);
|
|
1118
1118
|
var ret;
|
|
1119
1119
|
if (isX(M)) {
|
|
1120
1120
|
ret = "";
|
|
@@ -1123,12 +1123,12 @@ var require_semver = __commonJS({
|
|
|
1123
1123
|
} else if (isX(p)) {
|
|
1124
1124
|
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
1125
1125
|
} else if (pr) {
|
|
1126
|
-
|
|
1126
|
+
debug13("replaceTilde pr", pr);
|
|
1127
1127
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
|
|
1128
1128
|
} else {
|
|
1129
1129
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
1130
1130
|
}
|
|
1131
|
-
|
|
1131
|
+
debug13("tilde return", ret);
|
|
1132
1132
|
return ret;
|
|
1133
1133
|
});
|
|
1134
1134
|
}
|
|
@@ -1138,10 +1138,10 @@ var require_semver = __commonJS({
|
|
|
1138
1138
|
}).join(" ");
|
|
1139
1139
|
}
|
|
1140
1140
|
function replaceCaret(comp, options) {
|
|
1141
|
-
|
|
1141
|
+
debug13("caret", comp, options);
|
|
1142
1142
|
var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
|
|
1143
1143
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
1144
|
-
|
|
1144
|
+
debug13("caret", comp, _, M, m, p, pr);
|
|
1145
1145
|
var ret;
|
|
1146
1146
|
if (isX(M)) {
|
|
1147
1147
|
ret = "";
|
|
@@ -1154,7 +1154,7 @@ var require_semver = __commonJS({
|
|
|
1154
1154
|
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
|
|
1155
1155
|
}
|
|
1156
1156
|
} else if (pr) {
|
|
1157
|
-
|
|
1157
|
+
debug13("replaceCaret pr", pr);
|
|
1158
1158
|
if (M === "0") {
|
|
1159
1159
|
if (m === "0") {
|
|
1160
1160
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -1165,7 +1165,7 @@ var require_semver = __commonJS({
|
|
|
1165
1165
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
|
|
1166
1166
|
}
|
|
1167
1167
|
} else {
|
|
1168
|
-
|
|
1168
|
+
debug13("no pr");
|
|
1169
1169
|
if (M === "0") {
|
|
1170
1170
|
if (m === "0") {
|
|
1171
1171
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -1176,12 +1176,12 @@ var require_semver = __commonJS({
|
|
|
1176
1176
|
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
|
|
1179
|
+
debug13("caret return", ret);
|
|
1180
1180
|
return ret;
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
function replaceXRanges(comp, options) {
|
|
1184
|
-
|
|
1184
|
+
debug13("replaceXRanges", comp, options);
|
|
1185
1185
|
return comp.split(/\s+/).map(function(comp2) {
|
|
1186
1186
|
return replaceXRange(comp2, options);
|
|
1187
1187
|
}).join(" ");
|
|
@@ -1190,7 +1190,7 @@ var require_semver = __commonJS({
|
|
|
1190
1190
|
comp = comp.trim();
|
|
1191
1191
|
var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
|
|
1192
1192
|
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
|
|
1193
|
-
|
|
1193
|
+
debug13("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1194
1194
|
var xM = isX(M);
|
|
1195
1195
|
var xm = xM || isX(m);
|
|
1196
1196
|
var xp = xm || isX(p);
|
|
@@ -1233,12 +1233,12 @@ var require_semver = __commonJS({
|
|
|
1233
1233
|
} else if (xp) {
|
|
1234
1234
|
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
1235
1235
|
}
|
|
1236
|
-
|
|
1236
|
+
debug13("xRange return", ret);
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
function replaceStars(comp, options) {
|
|
1241
|
-
|
|
1241
|
+
debug13("replaceStars", comp, options);
|
|
1242
1242
|
return comp.trim().replace(safeRe[STAR], "");
|
|
1243
1243
|
}
|
|
1244
1244
|
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
@@ -1286,7 +1286,7 @@ var require_semver = __commonJS({
|
|
|
1286
1286
|
}
|
|
1287
1287
|
if (version2.prerelease.length && !options.includePrerelease) {
|
|
1288
1288
|
for (i2 = 0; i2 < set.length; i2++) {
|
|
1289
|
-
|
|
1289
|
+
debug13(set[i2].semver);
|
|
1290
1290
|
if (set[i2].semver === ANY) {
|
|
1291
1291
|
continue;
|
|
1292
1292
|
}
|
|
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
|
|
|
1895
1895
|
"../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
|
|
1896
1896
|
var once = require_once();
|
|
1897
1897
|
var eos = require_end_of_stream();
|
|
1898
|
-
var
|
|
1898
|
+
var fs13;
|
|
1899
1899
|
try {
|
|
1900
|
-
|
|
1900
|
+
fs13 = require("fs");
|
|
1901
1901
|
} catch (e) {
|
|
1902
1902
|
}
|
|
1903
1903
|
var noop = function() {
|
|
@@ -1909,9 +1909,9 @@ var require_pump = __commonJS({
|
|
|
1909
1909
|
var isFS = function(stream) {
|
|
1910
1910
|
if (!ancient)
|
|
1911
1911
|
return false;
|
|
1912
|
-
if (!
|
|
1912
|
+
if (!fs13)
|
|
1913
1913
|
return false;
|
|
1914
|
-
return (stream instanceof (
|
|
1914
|
+
return (stream instanceof (fs13.ReadStream || noop) || stream instanceof (fs13.WriteStream || noop)) && isFn(stream.close);
|
|
1915
1915
|
};
|
|
1916
1916
|
var isRequest = function(stream) {
|
|
1917
1917
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -2651,9 +2651,9 @@ ${stderr}${stdout}`;
|
|
|
2651
2651
|
var require_lib = __commonJS({
|
|
2652
2652
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
2653
2653
|
var isexe = require_isexe();
|
|
2654
|
-
var { join:
|
|
2654
|
+
var { join: join14, delimiter: delimiter2, sep: sep3, posix } = require("path");
|
|
2655
2655
|
var isWindows = process.platform === "win32";
|
|
2656
|
-
var rSlash = new RegExp(`[${posix.sep}${
|
|
2656
|
+
var rSlash = new RegExp(`[${posix.sep}${sep3 === posix.sep ? "" : sep3}]`.replace(/(\\)/g, "\\$1"));
|
|
2657
2657
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
2658
2658
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
2659
2659
|
var getPathInfo = (cmd, {
|
|
@@ -2680,7 +2680,7 @@ var require_lib = __commonJS({
|
|
|
2680
2680
|
var getPathPart = (raw, cmd) => {
|
|
2681
2681
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2682
2682
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2683
|
-
return prefix +
|
|
2683
|
+
return prefix + join14(pathPart, cmd);
|
|
2684
2684
|
};
|
|
2685
2685
|
var which2 = async (cmd, opt = {}) => {
|
|
2686
2686
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -2762,27 +2762,27 @@ var require_process = __commonJS({
|
|
|
2762
2762
|
var require_filesystem = __commonJS({
|
|
2763
2763
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
|
|
2764
2764
|
"use strict";
|
|
2765
|
-
var
|
|
2765
|
+
var fs13 = require("fs");
|
|
2766
2766
|
var LDD_PATH = "/usr/bin/ldd";
|
|
2767
2767
|
var SELF_PATH = "/proc/self/exe";
|
|
2768
2768
|
var MAX_LENGTH = 2048;
|
|
2769
2769
|
var readFileSync2 = (path) => {
|
|
2770
|
-
const fd =
|
|
2770
|
+
const fd = fs13.openSync(path, "r");
|
|
2771
2771
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2772
|
-
const bytesRead =
|
|
2773
|
-
|
|
2772
|
+
const bytesRead = fs13.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
2773
|
+
fs13.close(fd, () => {
|
|
2774
2774
|
});
|
|
2775
2775
|
return buffer.subarray(0, bytesRead);
|
|
2776
2776
|
};
|
|
2777
2777
|
var readFile2 = (path) => new Promise((resolve3, reject) => {
|
|
2778
|
-
|
|
2778
|
+
fs13.open(path, "r", (err, fd) => {
|
|
2779
2779
|
if (err) {
|
|
2780
2780
|
reject(err);
|
|
2781
2781
|
} else {
|
|
2782
2782
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2783
|
-
|
|
2783
|
+
fs13.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
2784
2784
|
resolve3(buffer.subarray(0, bytesRead));
|
|
2785
|
-
|
|
2785
|
+
fs13.close(fd, () => {
|
|
2786
2786
|
});
|
|
2787
2787
|
});
|
|
2788
2788
|
}
|
|
@@ -3227,15 +3227,15 @@ __export(src_exports, {
|
|
|
3227
3227
|
module.exports = __toCommonJS(src_exports);
|
|
3228
3228
|
var import_assert = __toESM(require("assert"));
|
|
3229
3229
|
var import_child_process3 = require("child_process");
|
|
3230
|
-
var
|
|
3231
|
-
var
|
|
3230
|
+
var import_fs14 = __toESM(require("fs"));
|
|
3231
|
+
var import_path14 = require("path");
|
|
3232
3232
|
|
|
3233
3233
|
// src/package-versions.ts
|
|
3234
3234
|
var VERCEL_RUNTIME_VERSION = "0.14.1";
|
|
3235
3235
|
var VERCEL_WORKERS_VERSION = "0.0.24";
|
|
3236
3236
|
|
|
3237
3237
|
// src/index.ts
|
|
3238
|
-
var
|
|
3238
|
+
var import_build_utils18 = require("@vercel/build-utils");
|
|
3239
3239
|
|
|
3240
3240
|
// src/install.ts
|
|
3241
3241
|
var import_execa3 = __toESM(require_execa());
|
|
@@ -4455,12 +4455,142 @@ async function installRequirementsFile({
|
|
|
4455
4455
|
}
|
|
4456
4456
|
|
|
4457
4457
|
// src/dependency-externalizer.ts
|
|
4458
|
-
var
|
|
4458
|
+
var import_fs6 = __toESM(require("fs"));
|
|
4459
4459
|
var import_util = require("util");
|
|
4460
|
-
var
|
|
4461
|
-
var
|
|
4460
|
+
var import_path7 = require("path");
|
|
4461
|
+
var import_build_utils7 = require("@vercel/build-utils");
|
|
4462
4462
|
var import_python_analysis3 = require("@vercel/python-analysis");
|
|
4463
|
-
|
|
4463
|
+
|
|
4464
|
+
// src/compileall.ts
|
|
4465
|
+
var import_execa4 = __toESM(require_execa());
|
|
4466
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
4467
|
+
var import_fs5 = __toESM(require("fs"));
|
|
4468
|
+
var import_path6 = require("path");
|
|
4469
|
+
function isCompileAllEnabled() {
|
|
4470
|
+
const val = process.env.VERCEL_PYTHON_COMPILEALL;
|
|
4471
|
+
if (val !== void 0 && val !== "") {
|
|
4472
|
+
const lower = val.toLowerCase();
|
|
4473
|
+
return lower === "1" || lower === "true";
|
|
4474
|
+
}
|
|
4475
|
+
const hive = process.env.VERCEL_PYTHON_ON_HIVE;
|
|
4476
|
+
if (hive === "1" || hive === "true") {
|
|
4477
|
+
return true;
|
|
4478
|
+
}
|
|
4479
|
+
return false;
|
|
4480
|
+
}
|
|
4481
|
+
function shouldUseCompileAll({
|
|
4482
|
+
isDev,
|
|
4483
|
+
hasCustomCommand
|
|
4484
|
+
}) {
|
|
4485
|
+
if (isDev)
|
|
4486
|
+
return false;
|
|
4487
|
+
const val = process.env.VERCEL_PYTHON_COMPILEALL;
|
|
4488
|
+
if (val !== void 0 && val !== "") {
|
|
4489
|
+
const lower = val.toLowerCase();
|
|
4490
|
+
return lower === "1" || lower === "true";
|
|
4491
|
+
}
|
|
4492
|
+
if (hasCustomCommand)
|
|
4493
|
+
return false;
|
|
4494
|
+
return isCompileAllEnabled();
|
|
4495
|
+
}
|
|
4496
|
+
async function runCompileAll({
|
|
4497
|
+
pythonBin,
|
|
4498
|
+
filesOrDirectories,
|
|
4499
|
+
env,
|
|
4500
|
+
excludeRegex
|
|
4501
|
+
}) {
|
|
4502
|
+
if (filesOrDirectories.length === 0)
|
|
4503
|
+
return;
|
|
4504
|
+
const args = [
|
|
4505
|
+
"-m",
|
|
4506
|
+
"compileall",
|
|
4507
|
+
"-q",
|
|
4508
|
+
"-j",
|
|
4509
|
+
"0",
|
|
4510
|
+
"--invalidation-mode",
|
|
4511
|
+
"unchecked-hash",
|
|
4512
|
+
...excludeRegex ? ["-x", excludeRegex] : [],
|
|
4513
|
+
...filesOrDirectories
|
|
4514
|
+
];
|
|
4515
|
+
try {
|
|
4516
|
+
await (0, import_execa4.default)(pythonBin, args, { env: env || process.env });
|
|
4517
|
+
} catch (err) {
|
|
4518
|
+
(0, import_build_utils6.debug)(`compileall error details: ${JSON.stringify(err)}`);
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
function derivePycPath(pyRelPath, pythonMajor, pythonMinor) {
|
|
4522
|
+
if (!pyRelPath.endsWith(".py"))
|
|
4523
|
+
return null;
|
|
4524
|
+
const lastSlash = pyRelPath.lastIndexOf("/");
|
|
4525
|
+
const dir = lastSlash === -1 ? "" : pyRelPath.slice(0, lastSlash + 1);
|
|
4526
|
+
const baseName = pyRelPath.slice(lastSlash + 1, -3);
|
|
4527
|
+
return `${dir}__pycache__/${baseName}.cpython-${pythonMajor}${pythonMinor}.pyc`;
|
|
4528
|
+
}
|
|
4529
|
+
var COMPILEALL_APP_EXCLUDED_DIRS = [
|
|
4530
|
+
".git",
|
|
4531
|
+
".vercel",
|
|
4532
|
+
".pnpm-store",
|
|
4533
|
+
"node_modules",
|
|
4534
|
+
".next",
|
|
4535
|
+
".nuxt",
|
|
4536
|
+
".venv",
|
|
4537
|
+
"venv",
|
|
4538
|
+
"__pycache__",
|
|
4539
|
+
".mypy_cache",
|
|
4540
|
+
".ruff_cache",
|
|
4541
|
+
"public"
|
|
4542
|
+
];
|
|
4543
|
+
function escapePythonRegex(value) {
|
|
4544
|
+
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
4545
|
+
}
|
|
4546
|
+
function getCompileAllAppExcludeRegex(workPath) {
|
|
4547
|
+
const excludedDirs = COMPILEALL_APP_EXCLUDED_DIRS.map(escapePythonRegex).join("|");
|
|
4548
|
+
return `${escapePythonRegex(workPath)}[/\\\\](?:${excludedDirs})(?:[/\\\\]|$)`;
|
|
4549
|
+
}
|
|
4550
|
+
async function collectAppBytecodeFiles({
|
|
4551
|
+
workPath,
|
|
4552
|
+
files: appFiles,
|
|
4553
|
+
pythonMajor,
|
|
4554
|
+
pythonMinor
|
|
4555
|
+
}) {
|
|
4556
|
+
const pending = [];
|
|
4557
|
+
for (const bundlePath of Object.keys(appFiles)) {
|
|
4558
|
+
const pycRel = derivePycPath(bundlePath, pythonMajor, pythonMinor);
|
|
4559
|
+
if (!pycRel)
|
|
4560
|
+
continue;
|
|
4561
|
+
pending.push({
|
|
4562
|
+
bundlePath: pycRel,
|
|
4563
|
+
srcFsPath: (0, import_path6.join)(workPath, pycRel.replaceAll("/", import_path6.sep))
|
|
4564
|
+
});
|
|
4565
|
+
}
|
|
4566
|
+
const results = await Promise.all(
|
|
4567
|
+
pending.map(async ({ bundlePath, srcFsPath }) => {
|
|
4568
|
+
try {
|
|
4569
|
+
const stats = await import_fs5.default.promises.stat(srcFsPath);
|
|
4570
|
+
return { bundlePath, srcFsPath, size: stats.size };
|
|
4571
|
+
} catch {
|
|
4572
|
+
return null;
|
|
4573
|
+
}
|
|
4574
|
+
})
|
|
4575
|
+
);
|
|
4576
|
+
const files = {};
|
|
4577
|
+
const perItemSizes = /* @__PURE__ */ new Map();
|
|
4578
|
+
let totalSize = 0;
|
|
4579
|
+
for (const result of results) {
|
|
4580
|
+
if (!result)
|
|
4581
|
+
continue;
|
|
4582
|
+
files[result.bundlePath] = new import_build_utils6.FileFsRef({
|
|
4583
|
+
fsPath: result.srcFsPath,
|
|
4584
|
+
size: result.size
|
|
4585
|
+
});
|
|
4586
|
+
perItemSizes.set(result.bundlePath, result.size);
|
|
4587
|
+
totalSize += result.size;
|
|
4588
|
+
}
|
|
4589
|
+
return { files, totalSize, perItemSizes };
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4592
|
+
// src/dependency-externalizer.ts
|
|
4593
|
+
var readFile = (0, import_util.promisify)(import_fs6.default.readFile);
|
|
4464
4594
|
var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
4465
4595
|
"py.typed",
|
|
4466
4596
|
"WHEEL",
|
|
@@ -4468,7 +4598,7 @@ var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
|
4468
4598
|
"direct_url.json"
|
|
4469
4599
|
]);
|
|
4470
4600
|
function shouldStripVendorFile(filePath) {
|
|
4471
|
-
const segments = filePath.split(
|
|
4601
|
+
const segments = filePath.split(import_path7.sep);
|
|
4472
4602
|
if (segments.includes("__pycache__"))
|
|
4473
4603
|
return true;
|
|
4474
4604
|
const name = segments[segments.length - 1] ?? "";
|
|
@@ -4478,7 +4608,9 @@ function shouldStripVendorFile(filePath) {
|
|
|
4478
4608
|
return true;
|
|
4479
4609
|
return false;
|
|
4480
4610
|
}
|
|
4481
|
-
var
|
|
4611
|
+
var LAMBDA_BASE_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
|
|
4612
|
+
var OTEL_LAYER_RESERVATION_BYTES = 5 * 1024 * 1024;
|
|
4613
|
+
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;
|
|
4482
4614
|
var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
|
|
4483
4615
|
var HIVE_LAMBDA_SIZE_BYTES = 1 * 1024 * 1024 * 1024;
|
|
4484
4616
|
var FUNCTIONS_BETA_CTA = "Run `vercel deploy --functions-beta` to use extended function limits (up to 1 GB), or reduce your dependency footprint.";
|
|
@@ -4531,7 +4663,7 @@ var PythonDependencyExternalizer = class {
|
|
|
4531
4663
|
this.distributions = /* @__PURE__ */ new Map();
|
|
4532
4664
|
for (const dir of this.sitePackageDirs) {
|
|
4533
4665
|
try {
|
|
4534
|
-
await
|
|
4666
|
+
await import_fs6.default.promises.access(dir);
|
|
4535
4667
|
} catch {
|
|
4536
4668
|
continue;
|
|
4537
4669
|
}
|
|
@@ -4547,12 +4679,12 @@ var PythonDependencyExternalizer = class {
|
|
|
4547
4679
|
this.totalBundleSize = await calculateBundleSize(tempFilesForSizing);
|
|
4548
4680
|
this.analyzed = true;
|
|
4549
4681
|
const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
|
|
4550
|
-
(0,
|
|
4682
|
+
(0, import_build_utils7.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
|
|
4551
4683
|
const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
|
|
4552
4684
|
const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
|
|
4553
4685
|
if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
|
|
4554
4686
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4555
|
-
throw new
|
|
4687
|
+
throw new import_build_utils7.NowBuildError({
|
|
4556
4688
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4557
4689
|
message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
|
|
4558
4690
|
|
|
@@ -4570,7 +4702,7 @@ dependencies, you can:
|
|
|
4570
4702
|
}
|
|
4571
4703
|
if (pythonOnHiveEnabled && this.totalBundleSize > HIVE_LAMBDA_SIZE_BYTES) {
|
|
4572
4704
|
const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
|
|
4573
|
-
throw new
|
|
4705
|
+
throw new import_build_utils7.NowBuildError({
|
|
4574
4706
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4575
4707
|
message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
|
|
4576
4708
|
|
|
@@ -4601,7 +4733,7 @@ application into smaller functions.`,
|
|
|
4601
4733
|
);
|
|
4602
4734
|
}
|
|
4603
4735
|
if (!this.uvLockPath || !this.uvProjectDir) {
|
|
4604
|
-
throw new
|
|
4736
|
+
throw new import_build_utils7.NowBuildError({
|
|
4605
4737
|
code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
|
|
4606
4738
|
message: "Runtime dependency installation requires a uv.lock file and project directory."
|
|
4607
4739
|
});
|
|
@@ -4612,7 +4744,7 @@ application into smaller functions.`,
|
|
|
4612
4744
|
);
|
|
4613
4745
|
if (this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
|
|
4614
4746
|
const ephemeralLimitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(0);
|
|
4615
|
-
throw new
|
|
4747
|
+
throw new import_build_utils7.NowBuildError({
|
|
4616
4748
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4617
4749
|
message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the ephemeral storage limit (${ephemeralLimitMB} MB).
|
|
4618
4750
|
|
|
@@ -4639,7 +4771,7 @@ your application into smaller functions.`,
|
|
|
4639
4771
|
`Failed to read uv.lock file at "${this.uvLockPath}": ${String(error)}`
|
|
4640
4772
|
);
|
|
4641
4773
|
}
|
|
4642
|
-
throw new
|
|
4774
|
+
throw new import_build_utils7.NowBuildError({
|
|
4643
4775
|
code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
|
|
4644
4776
|
message: `Failed to read uv.lock file at "${this.uvLockPath}"`
|
|
4645
4777
|
});
|
|
@@ -4655,7 +4787,7 @@ your application into smaller functions.`,
|
|
|
4655
4787
|
${error.fileContent}`
|
|
4656
4788
|
);
|
|
4657
4789
|
}
|
|
4658
|
-
throw new
|
|
4790
|
+
throw new import_build_utils7.NowBuildError({
|
|
4659
4791
|
code: error.code,
|
|
4660
4792
|
message: error.message
|
|
4661
4793
|
});
|
|
@@ -4665,7 +4797,7 @@ ${error.fileContent}`
|
|
|
4665
4797
|
const excludePackages = [];
|
|
4666
4798
|
if (this.projectName) {
|
|
4667
4799
|
excludePackages.push(this.projectName);
|
|
4668
|
-
(0,
|
|
4800
|
+
(0, import_build_utils7.debug)(
|
|
4669
4801
|
`Excluding project package "${this.projectName}" from runtime installation`
|
|
4670
4802
|
);
|
|
4671
4803
|
}
|
|
@@ -4673,7 +4805,7 @@ ${error.fileContent}`
|
|
|
4673
4805
|
lockFile,
|
|
4674
4806
|
excludePackages
|
|
4675
4807
|
});
|
|
4676
|
-
(0,
|
|
4808
|
+
(0, import_build_utils7.debug)(
|
|
4677
4809
|
`Package classification: ${classification.privatePackages.length} private, ${classification.publicPackages.length} public`
|
|
4678
4810
|
);
|
|
4679
4811
|
const forceBundledDueToWheels = await this.findPackagesWithoutCompatibleWheels(
|
|
@@ -4692,7 +4824,7 @@ ${error.fileContent}`
|
|
|
4692
4824
|
(name) => !forceBundledSet.has((0, import_python_analysis3.normalizePackageName)(name))
|
|
4693
4825
|
);
|
|
4694
4826
|
if (externalizablePublic.length === 0) {
|
|
4695
|
-
throw new
|
|
4827
|
+
throw new import_build_utils7.NowBuildError({
|
|
4696
4828
|
code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
|
|
4697
4829
|
message: `Bundle size exceeds the Lambda limit and requires runtime
|
|
4698
4830
|
dependency installation, but no public packages have compatible
|
|
@@ -4727,26 +4859,26 @@ To fix this, either:
|
|
|
4727
4859
|
let runtimeToolingOverhead = 0;
|
|
4728
4860
|
try {
|
|
4729
4861
|
const uvBinaryPath = await this.resolveUvBinaryForBundling();
|
|
4730
|
-
const uvStats = await
|
|
4862
|
+
const uvStats = await import_fs6.default.promises.stat(uvBinaryPath);
|
|
4731
4863
|
runtimeToolingOverhead = uvStats.size;
|
|
4732
4864
|
} catch {
|
|
4733
4865
|
runtimeToolingOverhead = 50 * 1024 * 1024;
|
|
4734
4866
|
}
|
|
4735
4867
|
runtimeToolingOverhead += 4 * 1024;
|
|
4736
|
-
const projectDirRel = (0,
|
|
4737
|
-
const uvLockRel = (0,
|
|
4868
|
+
const projectDirRel = (0, import_path7.relative)(this.workPath, this.uvProjectDir);
|
|
4869
|
+
const uvLockRel = (0, import_path7.relative)(this.workPath, this.uvLockPath);
|
|
4738
4870
|
const isOutsideWorkPath = projectDirRel.startsWith("..") || uvLockRel.startsWith("..");
|
|
4739
4871
|
if (isOutsideWorkPath) {
|
|
4740
|
-
const pyprojectPath = (0,
|
|
4741
|
-
const pyprojectStats = await
|
|
4742
|
-
const uvLockStats = await
|
|
4872
|
+
const pyprojectPath = (0, import_path7.join)(this.uvProjectDir, "pyproject.toml");
|
|
4873
|
+
const pyprojectStats = await import_fs6.default.promises.stat(pyprojectPath).catch(() => null);
|
|
4874
|
+
const uvLockStats = await import_fs6.default.promises.stat(this.uvLockPath).catch(() => null);
|
|
4743
4875
|
if (pyprojectStats)
|
|
4744
4876
|
runtimeToolingOverhead += pyprojectStats.size;
|
|
4745
4877
|
if (uvLockStats)
|
|
4746
4878
|
runtimeToolingOverhead += uvLockStats.size;
|
|
4747
4879
|
}
|
|
4748
4880
|
const remainingCapacity = LAMBDA_SIZE_THRESHOLD_BYTES - fixedOverhead - runtimeToolingOverhead;
|
|
4749
|
-
(0,
|
|
4881
|
+
(0, import_build_utils7.debug)(
|
|
4750
4882
|
`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`
|
|
4751
4883
|
);
|
|
4752
4884
|
const externalizableSet = new Set(
|
|
@@ -4773,11 +4905,11 @@ To fix this, either:
|
|
|
4773
4905
|
...forceBundledDueToWheels
|
|
4774
4906
|
];
|
|
4775
4907
|
if (isOutsideWorkPath) {
|
|
4776
|
-
const srcPyproject = (0,
|
|
4777
|
-
files[`${UV_BUNDLE_DIR}/pyproject.toml`] = new
|
|
4908
|
+
const srcPyproject = (0, import_path7.join)(this.uvProjectDir, "pyproject.toml");
|
|
4909
|
+
files[`${UV_BUNDLE_DIR}/pyproject.toml`] = new import_build_utils7.FileFsRef({
|
|
4778
4910
|
fsPath: srcPyproject
|
|
4779
4911
|
});
|
|
4780
|
-
files[`${UV_BUNDLE_DIR}/uv.lock`] = new
|
|
4912
|
+
files[`${UV_BUNDLE_DIR}/uv.lock`] = new import_build_utils7.FileFsRef({
|
|
4781
4913
|
fsPath: this.uvLockPath
|
|
4782
4914
|
});
|
|
4783
4915
|
}
|
|
@@ -4785,24 +4917,24 @@ To fix this, either:
|
|
|
4785
4917
|
projectDir: isOutsideWorkPath ? UV_BUNDLE_DIR : projectDirRel,
|
|
4786
4918
|
bundledPackages: bundledPackagesForConfig
|
|
4787
4919
|
});
|
|
4788
|
-
files[`${UV_BUNDLE_DIR}/_runtime_config.json`] = new
|
|
4920
|
+
files[`${UV_BUNDLE_DIR}/_runtime_config.json`] = new import_build_utils7.FileBlob({
|
|
4789
4921
|
data: runtimeConfigData
|
|
4790
4922
|
});
|
|
4791
4923
|
try {
|
|
4792
4924
|
const uvBinaryPath = await this.resolveUvBinaryForBundling();
|
|
4793
|
-
const uvBundleDir = (0,
|
|
4794
|
-
const uvLocalPath = (0,
|
|
4795
|
-
await
|
|
4796
|
-
await
|
|
4797
|
-
await
|
|
4925
|
+
const uvBundleDir = (0, import_path7.join)(this.workPath, UV_BUNDLE_DIR);
|
|
4926
|
+
const uvLocalPath = (0, import_path7.join)(uvBundleDir, "uv");
|
|
4927
|
+
await import_fs6.default.promises.mkdir(uvBundleDir, { recursive: true });
|
|
4928
|
+
await import_fs6.default.promises.copyFile(uvBinaryPath, uvLocalPath);
|
|
4929
|
+
await import_fs6.default.promises.chmod(uvLocalPath, 493);
|
|
4798
4930
|
const uvBundlePath = `${UV_BUNDLE_DIR}/uv`;
|
|
4799
|
-
files[uvBundlePath] = new
|
|
4931
|
+
files[uvBundlePath] = new import_build_utils7.FileFsRef({
|
|
4800
4932
|
fsPath: uvLocalPath,
|
|
4801
4933
|
mode: 33261
|
|
4802
4934
|
});
|
|
4803
|
-
(0,
|
|
4935
|
+
(0, import_build_utils7.debug)(`Bundled uv binary from ${uvBinaryPath} to ${uvLocalPath}`);
|
|
4804
4936
|
} catch (err) {
|
|
4805
|
-
throw new
|
|
4937
|
+
throw new import_build_utils7.NowBuildError({
|
|
4806
4938
|
code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
|
|
4807
4939
|
message: `Failed to bundle uv binary for runtime installation: ${err instanceof Error ? err.message : String(err)}`
|
|
4808
4940
|
});
|
|
@@ -4811,7 +4943,7 @@ To fix this, either:
|
|
|
4811
4943
|
if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES + 100 * 1024) {
|
|
4812
4944
|
const finalSizeMB = (finalBundleSize / (1024 * 1024)).toFixed(2);
|
|
4813
4945
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4814
|
-
throw new
|
|
4946
|
+
throw new import_build_utils7.NowBuildError({
|
|
4815
4947
|
code: "LAMBDA_SIZE_EXCEEDED",
|
|
4816
4948
|
message: shouldShowFunctionsBetaHint() ? `Total bundle size (${finalSizeMB} MB) exceeds the size limit (${limitMB} MB).
|
|
4817
4949
|
|
|
@@ -4839,7 +4971,7 @@ splitting your application.`,
|
|
|
4839
4971
|
async findPackagesWithoutCompatibleWheels(lockFile, publicPackageNames) {
|
|
4840
4972
|
const platform = detectTargetPlatform();
|
|
4841
4973
|
if (this.pythonMajor === void 0 || this.pythonMinor === void 0) {
|
|
4842
|
-
(0,
|
|
4974
|
+
(0, import_build_utils7.debug)("Skipping wheel compatibility check: dev mode");
|
|
4843
4975
|
return [];
|
|
4844
4976
|
}
|
|
4845
4977
|
const reachable = await getPackagesReachableOnPlatform(
|
|
@@ -4854,7 +4986,7 @@ splitting your application.`,
|
|
|
4854
4986
|
(name) => reachable.has((0, import_python_analysis3.normalizePackageName)(name))
|
|
4855
4987
|
) : publicPackageNames;
|
|
4856
4988
|
if (relevantPackages.length < publicPackageNames.length) {
|
|
4857
|
-
(0,
|
|
4989
|
+
(0, import_build_utils7.debug)(
|
|
4858
4990
|
`Skipping wheel check for ${publicPackageNames.length - relevantPackages.length} package(s) not reachable on the target platform`
|
|
4859
4991
|
);
|
|
4860
4992
|
}
|
|
@@ -4894,7 +5026,7 @@ splitting your application.`,
|
|
|
4894
5026
|
break;
|
|
4895
5027
|
}
|
|
4896
5028
|
} catch (err) {
|
|
4897
|
-
(0,
|
|
5029
|
+
(0, import_build_utils7.debug)(
|
|
4898
5030
|
`Failed to check wheel compatibility for ${filename}: ${err instanceof Error ? err.message : String(err)}`
|
|
4899
5031
|
);
|
|
4900
5032
|
}
|
|
@@ -4911,7 +5043,7 @@ splitting your application.`,
|
|
|
4911
5043
|
return getUvBinaryForBundling(this.pythonPath);
|
|
4912
5044
|
}
|
|
4913
5045
|
return downloadUvBinaryForTarget(
|
|
4914
|
-
(0,
|
|
5046
|
+
(0, import_path7.join)(this.workPath, ".vercel", "python", "cache")
|
|
4915
5047
|
);
|
|
4916
5048
|
}
|
|
4917
5049
|
/**
|
|
@@ -4938,21 +5070,21 @@ splitting your application.`,
|
|
|
4938
5070
|
const dirDistributions = this.distributions.get(dir);
|
|
4939
5071
|
if (!dirDistributions)
|
|
4940
5072
|
continue;
|
|
4941
|
-
const resolvedDir = (0,
|
|
4942
|
-
const dirPrefix = resolvedDir +
|
|
5073
|
+
const resolvedDir = (0, import_path7.resolve)(dir);
|
|
5074
|
+
const dirPrefix = resolvedDir + import_path7.sep;
|
|
4943
5075
|
for (const [name, dist] of dirDistributions) {
|
|
4944
5076
|
if (includeSet && !includeSet.has(name))
|
|
4945
5077
|
continue;
|
|
4946
5078
|
for (const { path: rawPath, size: recordSize } of dist.files) {
|
|
4947
|
-
const filePath = rawPath.replaceAll("/",
|
|
4948
|
-
if (!(0,
|
|
5079
|
+
const filePath = rawPath.replaceAll("/", import_path7.sep);
|
|
5080
|
+
if (!(0, import_path7.resolve)(resolvedDir, filePath).startsWith(dirPrefix)) {
|
|
4949
5081
|
continue;
|
|
4950
5082
|
}
|
|
4951
5083
|
if (shouldStripVendorFile(filePath)) {
|
|
4952
5084
|
continue;
|
|
4953
5085
|
}
|
|
4954
|
-
const srcFsPath = (0,
|
|
4955
|
-
const bundlePath = (0,
|
|
5086
|
+
const srcFsPath = (0, import_path7.join)(dir, filePath);
|
|
5087
|
+
const bundlePath = (0, import_path7.join)(vendorDirName, filePath).replace(/\\/g, "/");
|
|
4956
5088
|
pending.push({
|
|
4957
5089
|
bundlePath,
|
|
4958
5090
|
srcFsPath,
|
|
@@ -4966,14 +5098,14 @@ splitting your application.`,
|
|
|
4966
5098
|
pending.map(async ({ bundlePath, srcFsPath, recordSize }) => {
|
|
4967
5099
|
if (recordSize !== void 0) {
|
|
4968
5100
|
try {
|
|
4969
|
-
await
|
|
5101
|
+
await import_fs6.default.promises.access(srcFsPath);
|
|
4970
5102
|
return { bundlePath, srcFsPath, size: recordSize };
|
|
4971
5103
|
} catch {
|
|
4972
5104
|
return null;
|
|
4973
5105
|
}
|
|
4974
5106
|
} else {
|
|
4975
5107
|
try {
|
|
4976
|
-
const stats = await
|
|
5108
|
+
const stats = await import_fs6.default.promises.stat(srcFsPath);
|
|
4977
5109
|
return { bundlePath, srcFsPath, size: stats.size };
|
|
4978
5110
|
} catch {
|
|
4979
5111
|
return null;
|
|
@@ -4983,13 +5115,13 @@ splitting your application.`,
|
|
|
4983
5115
|
);
|
|
4984
5116
|
for (const result of results) {
|
|
4985
5117
|
if (result) {
|
|
4986
|
-
vendorFiles[result.bundlePath] = new
|
|
5118
|
+
vendorFiles[result.bundlePath] = new import_build_utils7.FileFsRef({
|
|
4987
5119
|
fsPath: result.srcFsPath,
|
|
4988
5120
|
size: result.size
|
|
4989
5121
|
});
|
|
4990
5122
|
}
|
|
4991
5123
|
}
|
|
4992
|
-
(0,
|
|
5124
|
+
(0, import_build_utils7.debug)(
|
|
4993
5125
|
`Mirrored ${Object.keys(vendorFiles).length} files` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
4994
5126
|
);
|
|
4995
5127
|
return vendorFiles;
|
|
@@ -5007,14 +5139,14 @@ splitting your application.`,
|
|
|
5007
5139
|
const dirDistributions = this.distributions.get(dir);
|
|
5008
5140
|
if (!dirDistributions)
|
|
5009
5141
|
continue;
|
|
5010
|
-
const resolvedDir = (0,
|
|
5011
|
-
const dirPrefix = resolvedDir +
|
|
5142
|
+
const resolvedDir = (0, import_path7.resolve)(dir);
|
|
5143
|
+
const dirPrefix = resolvedDir + import_path7.sep;
|
|
5012
5144
|
for (const [name, dist] of dirDistributions) {
|
|
5013
5145
|
let knownSize = 0;
|
|
5014
5146
|
const statPromises = [];
|
|
5015
5147
|
for (const { path: rawPath, size: recordSize } of dist.files) {
|
|
5016
|
-
const filePath = rawPath.replaceAll("/",
|
|
5017
|
-
if (!(0,
|
|
5148
|
+
const filePath = rawPath.replaceAll("/", import_path7.sep);
|
|
5149
|
+
if (!(0, import_path7.resolve)(resolvedDir, filePath).startsWith(dirPrefix)) {
|
|
5018
5150
|
continue;
|
|
5019
5151
|
}
|
|
5020
5152
|
if (shouldStripVendorFile(filePath)) {
|
|
@@ -5024,7 +5156,7 @@ splitting your application.`,
|
|
|
5024
5156
|
knownSize += Number(recordSize);
|
|
5025
5157
|
} else {
|
|
5026
5158
|
statPromises.push(
|
|
5027
|
-
|
|
5159
|
+
import_fs6.default.promises.stat((0, import_path7.join)(dir, filePath)).then((stats) => stats.size).catch(() => 0)
|
|
5028
5160
|
);
|
|
5029
5161
|
}
|
|
5030
5162
|
}
|
|
@@ -5038,6 +5170,85 @@ splitting your application.`,
|
|
|
5038
5170
|
}
|
|
5039
5171
|
return sizes;
|
|
5040
5172
|
}
|
|
5173
|
+
/**
|
|
5174
|
+
* Collect pre-compiled `.pyc` bytecode files for vendor packages.
|
|
5175
|
+
*
|
|
5176
|
+
* For each `.py` file listed in a package's RECORD, derives the expected
|
|
5177
|
+
* `__pycache__/*.cpython-XY.pyc` path and checks whether it exists on
|
|
5178
|
+
* disk (i.e. whether `compileall` produced it). Files that do not exist
|
|
5179
|
+
* are silently skipped.
|
|
5180
|
+
*
|
|
5181
|
+
* Must be called after `analyze()` which populates `sitePackageDirs` and
|
|
5182
|
+
* `distributions`.
|
|
5183
|
+
*/
|
|
5184
|
+
async collectBytecodeFiles({
|
|
5185
|
+
vendorDirName,
|
|
5186
|
+
includePackages
|
|
5187
|
+
}) {
|
|
5188
|
+
if (!this.sitePackageDirs || !this.distributions) {
|
|
5189
|
+
throw new Error("collectBytecodeFiles() must be called after analyze()");
|
|
5190
|
+
}
|
|
5191
|
+
if (this.pythonMajor == null || this.pythonMinor == null) {
|
|
5192
|
+
return { files: {}, totalSize: 0, perItemSizes: /* @__PURE__ */ new Map() };
|
|
5193
|
+
}
|
|
5194
|
+
const includeSet = includePackages ? new Set(includePackages.map(import_python_analysis3.normalizePackageName)) : null;
|
|
5195
|
+
const pending = [];
|
|
5196
|
+
for (const dir of this.sitePackageDirs) {
|
|
5197
|
+
const dirDistributions = this.distributions.get(dir);
|
|
5198
|
+
if (!dirDistributions)
|
|
5199
|
+
continue;
|
|
5200
|
+
for (const [name, dist] of dirDistributions) {
|
|
5201
|
+
if (includeSet && !includeSet.has(name))
|
|
5202
|
+
continue;
|
|
5203
|
+
for (const { path: rawPath } of dist.files) {
|
|
5204
|
+
const pycRel = derivePycPath(
|
|
5205
|
+
rawPath,
|
|
5206
|
+
this.pythonMajor,
|
|
5207
|
+
this.pythonMinor
|
|
5208
|
+
);
|
|
5209
|
+
if (!pycRel)
|
|
5210
|
+
continue;
|
|
5211
|
+
const pycFilePath = pycRel.replaceAll("/", import_path7.sep);
|
|
5212
|
+
const srcFsPath = (0, import_path7.join)(dir, pycFilePath);
|
|
5213
|
+
const bundlePath = (0, import_path7.join)(vendorDirName, pycFilePath).replace(
|
|
5214
|
+
/\\/g,
|
|
5215
|
+
"/"
|
|
5216
|
+
);
|
|
5217
|
+
pending.push({ bundlePath, srcFsPath, packageName: name });
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
const results = await Promise.all(
|
|
5222
|
+
pending.map(async ({ bundlePath, srcFsPath, packageName }) => {
|
|
5223
|
+
try {
|
|
5224
|
+
const stats = await import_fs6.default.promises.stat(srcFsPath);
|
|
5225
|
+
return { bundlePath, srcFsPath, size: stats.size, packageName };
|
|
5226
|
+
} catch {
|
|
5227
|
+
return null;
|
|
5228
|
+
}
|
|
5229
|
+
})
|
|
5230
|
+
);
|
|
5231
|
+
const files = {};
|
|
5232
|
+
let totalSize = 0;
|
|
5233
|
+
const perItemSizes = /* @__PURE__ */ new Map();
|
|
5234
|
+
for (const result of results) {
|
|
5235
|
+
if (!result)
|
|
5236
|
+
continue;
|
|
5237
|
+
files[result.bundlePath] = new import_build_utils7.FileFsRef({
|
|
5238
|
+
fsPath: result.srcFsPath,
|
|
5239
|
+
size: result.size
|
|
5240
|
+
});
|
|
5241
|
+
totalSize += result.size;
|
|
5242
|
+
perItemSizes.set(
|
|
5243
|
+
result.packageName,
|
|
5244
|
+
(perItemSizes.get(result.packageName) ?? 0) + result.size
|
|
5245
|
+
);
|
|
5246
|
+
}
|
|
5247
|
+
(0, import_build_utils7.debug)(
|
|
5248
|
+
`Collected ${Object.keys(files).length} bytecode files (${(totalSize / (1024 * 1024)).toFixed(2)} MB)` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
5249
|
+
);
|
|
5250
|
+
return { files, totalSize, perItemSizes };
|
|
5251
|
+
}
|
|
5041
5252
|
};
|
|
5042
5253
|
async function getPackagesReachableOnPlatform(lockFile, projectName, pythonMajor, pythonMinor, sysPlatform, platformMachine) {
|
|
5043
5254
|
if (!projectName)
|
|
@@ -5070,13 +5281,13 @@ async function getPackagesReachableOnPlatform(lockFile, projectName, pythonMajor
|
|
|
5070
5281
|
platformMachine
|
|
5071
5282
|
);
|
|
5072
5283
|
if (!compatible) {
|
|
5073
|
-
(0,
|
|
5284
|
+
(0, import_build_utils7.debug)(
|
|
5074
5285
|
`Skipping dependency ${dep.name}: marker "${dep.marker}" not satisfied on ${sysPlatform}`
|
|
5075
5286
|
);
|
|
5076
5287
|
continue;
|
|
5077
5288
|
}
|
|
5078
5289
|
} catch (err) {
|
|
5079
|
-
(0,
|
|
5290
|
+
(0, import_build_utils7.debug)(
|
|
5080
5291
|
`Failed to evaluate marker "${dep.marker}" for ${dep.name}, including conservatively: ${err instanceof Error ? err.message : String(err)}`
|
|
5081
5292
|
);
|
|
5082
5293
|
}
|
|
@@ -5108,7 +5319,7 @@ async function calculateBundleSize(files) {
|
|
|
5108
5319
|
knownSize += fsRef.size;
|
|
5109
5320
|
} else {
|
|
5110
5321
|
statPromises.push(
|
|
5111
|
-
|
|
5322
|
+
import_fs6.default.promises.stat(fsRef.fsPath).then((stats) => stats.size).catch((err) => {
|
|
5112
5323
|
console.warn(
|
|
5113
5324
|
`Warning: Failed to stat file ${fsRef.fsPath}, size will not be included in bundle calculation: ${err}`
|
|
5114
5325
|
);
|
|
@@ -5145,8 +5356,8 @@ function lambdaKnapsack(packages, capacity) {
|
|
|
5145
5356
|
}
|
|
5146
5357
|
|
|
5147
5358
|
// src/diagnostics.ts
|
|
5148
|
-
var
|
|
5149
|
-
var
|
|
5359
|
+
var import_fs7 = __toESM(require("fs"));
|
|
5360
|
+
var import_build_utils8 = require("@vercel/build-utils");
|
|
5150
5361
|
var import_python_analysis4 = require("@vercel/python-analysis");
|
|
5151
5362
|
function isDependencyGroupInclude(entry) {
|
|
5152
5363
|
return typeof entry === "object" && "include-group" in entry;
|
|
@@ -5260,7 +5471,7 @@ async function generateProjectManifest({
|
|
|
5260
5471
|
const directEntries = [];
|
|
5261
5472
|
const transitiveEntries = [];
|
|
5262
5473
|
{
|
|
5263
|
-
const content = await
|
|
5474
|
+
const content = await import_fs7.default.promises.readFile(uvLockPath, "utf-8");
|
|
5264
5475
|
const uvLock = (0, import_python_analysis4.parseUvLock)(content, uvLockPath);
|
|
5265
5476
|
const projectName = project?.name;
|
|
5266
5477
|
const excludeSet = new Set(
|
|
@@ -5351,7 +5562,7 @@ async function generateProjectManifest({
|
|
|
5351
5562
|
}
|
|
5352
5563
|
}
|
|
5353
5564
|
const manifest = {
|
|
5354
|
-
version:
|
|
5565
|
+
version: import_build_utils8.MANIFEST_VERSION,
|
|
5355
5566
|
runtime: "python",
|
|
5356
5567
|
...framework ? { framework } : {},
|
|
5357
5568
|
...serviceType ? { serviceType } : {},
|
|
@@ -5365,22 +5576,22 @@ async function generateProjectManifest({
|
|
|
5365
5576
|
...transitiveEntries.sort((a, b) => a.name.localeCompare(b.name))
|
|
5366
5577
|
]
|
|
5367
5578
|
};
|
|
5368
|
-
await (0,
|
|
5579
|
+
await (0, import_build_utils8.writeProjectManifest)(manifest, workPath, "python");
|
|
5369
5580
|
}
|
|
5370
|
-
var diagnostics = (0,
|
|
5581
|
+
var diagnostics = (0, import_build_utils8.createDiagnostics)("python");
|
|
5371
5582
|
|
|
5372
5583
|
// src/crons.ts
|
|
5373
|
-
var
|
|
5374
|
-
var
|
|
5375
|
-
var
|
|
5376
|
-
var
|
|
5584
|
+
var import_fs9 = __toESM(require("fs"));
|
|
5585
|
+
var import_path9 = require("path");
|
|
5586
|
+
var import_execa5 = __toESM(require_execa());
|
|
5587
|
+
var import_build_utils12 = require("@vercel/build-utils");
|
|
5377
5588
|
|
|
5378
5589
|
// src/entrypoint.ts
|
|
5379
|
-
var
|
|
5380
|
-
var
|
|
5381
|
-
var import_build_utils8 = require("@vercel/build-utils");
|
|
5590
|
+
var import_fs8 = __toESM(require("fs"));
|
|
5591
|
+
var import_path8 = require("path");
|
|
5382
5592
|
var import_build_utils9 = require("@vercel/build-utils");
|
|
5383
5593
|
var import_build_utils10 = require("@vercel/build-utils");
|
|
5594
|
+
var import_build_utils11 = require("@vercel/build-utils");
|
|
5384
5595
|
var import_python_analysis5 = require("@vercel/python-analysis");
|
|
5385
5596
|
var PYTHON_ENTRYPOINT_FILENAMES = [
|
|
5386
5597
|
"app",
|
|
@@ -5399,13 +5610,13 @@ var SKIP_DIRS = /* @__PURE__ */ new Set(["__pycache__", "node_modules"]);
|
|
|
5399
5610
|
function getCandidateEntrypointsInDirs(dirs) {
|
|
5400
5611
|
return dirs.flatMap(
|
|
5401
5612
|
(dir) => PYTHON_ENTRYPOINT_FILENAMES.map(
|
|
5402
|
-
(filename) =>
|
|
5613
|
+
(filename) => import_path8.posix.join(dir, `${filename}.py`)
|
|
5403
5614
|
)
|
|
5404
5615
|
);
|
|
5405
5616
|
}
|
|
5406
5617
|
async function fileExists(filePath) {
|
|
5407
5618
|
try {
|
|
5408
|
-
const stat = await
|
|
5619
|
+
const stat = await import_fs8.default.promises.stat(filePath);
|
|
5409
5620
|
return stat.isFile();
|
|
5410
5621
|
} catch {
|
|
5411
5622
|
return false;
|
|
@@ -5460,28 +5671,28 @@ function entrypointToModule(entrypoint) {
|
|
|
5460
5671
|
return entrypoint.replace(/\\/g, "/").replace(/\.py$/i, "").replace(/\//g, ".");
|
|
5461
5672
|
}
|
|
5462
5673
|
async function checkEntrypoint(workPath, relPath) {
|
|
5463
|
-
const absPath = (0,
|
|
5674
|
+
const absPath = (0, import_path8.join)(workPath, relPath);
|
|
5464
5675
|
if (!await fileExists(absPath))
|
|
5465
5676
|
return null;
|
|
5466
|
-
const content = await
|
|
5677
|
+
const content = await import_fs8.default.promises.readFile(absPath, "utf-8");
|
|
5467
5678
|
return (0, import_python_analysis5.findAppOrHandler)(content);
|
|
5468
5679
|
}
|
|
5469
5680
|
async function findPythonFilesRecursive(dir, rootDir) {
|
|
5470
5681
|
const results = [];
|
|
5471
5682
|
let entries;
|
|
5472
5683
|
try {
|
|
5473
|
-
entries = await
|
|
5684
|
+
entries = await import_fs8.default.promises.readdir(dir, { withFileTypes: true });
|
|
5474
5685
|
} catch {
|
|
5475
5686
|
return results;
|
|
5476
5687
|
}
|
|
5477
5688
|
for (const entry of entries) {
|
|
5478
5689
|
if (entry.name.startsWith(".") || SKIP_DIRS.has(entry.name))
|
|
5479
5690
|
continue;
|
|
5480
|
-
const fullPath = (0,
|
|
5691
|
+
const fullPath = (0, import_path8.join)(dir, entry.name);
|
|
5481
5692
|
if (entry.isDirectory()) {
|
|
5482
5693
|
results.push(...await findPythonFilesRecursive(fullPath, rootDir));
|
|
5483
5694
|
} else if (entry.isFile() && entry.name.endsWith(".py")) {
|
|
5484
|
-
results.push((0,
|
|
5695
|
+
results.push((0, import_path8.relative)(rootDir, fullPath).replace(/\\/g, "/"));
|
|
5485
5696
|
}
|
|
5486
5697
|
}
|
|
5487
5698
|
return results;
|
|
@@ -5491,8 +5702,8 @@ async function findEntrypointCandidates(workPath) {
|
|
|
5491
5702
|
const candidates = [];
|
|
5492
5703
|
for (const relPath of pyFiles) {
|
|
5493
5704
|
try {
|
|
5494
|
-
const content = await
|
|
5495
|
-
(0,
|
|
5705
|
+
const content = await import_fs8.default.promises.readFile(
|
|
5706
|
+
(0, import_path8.join)(workPath, relPath),
|
|
5496
5707
|
"utf-8"
|
|
5497
5708
|
);
|
|
5498
5709
|
const varName = await (0, import_python_analysis5.findAppOrHandler)(content);
|
|
@@ -5527,14 +5738,14 @@ async function resolveModuleAttrEntrypoint(workPath, value) {
|
|
|
5527
5738
|
const relPath = modulePath.replace(/\./g, "/");
|
|
5528
5739
|
const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];
|
|
5529
5740
|
for (const candidate of candidates) {
|
|
5530
|
-
if (await fileExists((0,
|
|
5741
|
+
if (await fileExists((0, import_path8.join)(workPath, candidate))) {
|
|
5531
5742
|
return { entrypoint: candidate, variableName };
|
|
5532
5743
|
}
|
|
5533
5744
|
}
|
|
5534
5745
|
return null;
|
|
5535
5746
|
}
|
|
5536
5747
|
async function getVercelToolsEntrypoint(workPath) {
|
|
5537
|
-
const pyprojectData = await (0,
|
|
5748
|
+
const pyprojectData = await (0, import_build_utils11.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
|
|
5538
5749
|
if (!pyprojectData)
|
|
5539
5750
|
return null;
|
|
5540
5751
|
const vercelEntrypoint = pyprojectData.tool?.vercel?.entrypoint;
|
|
@@ -5543,7 +5754,7 @@ async function getVercelToolsEntrypoint(workPath) {
|
|
|
5543
5754
|
return resolveModuleAttrEntrypoint(workPath, vercelEntrypoint);
|
|
5544
5755
|
}
|
|
5545
5756
|
async function getPyprojectEntrypointWithDiagnostics(workPath) {
|
|
5546
|
-
const pyprojectData = await (0,
|
|
5757
|
+
const pyprojectData = await (0, import_build_utils11.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
|
|
5547
5758
|
if (!pyprojectData)
|
|
5548
5759
|
return { entrypoint: null };
|
|
5549
5760
|
const scripts = pyprojectData.project?.scripts;
|
|
@@ -5558,7 +5769,7 @@ async function getPyprojectEntrypointWithDiagnostics(workPath) {
|
|
|
5558
5769
|
const relPath = modulePath.replace(/\./g, "/");
|
|
5559
5770
|
const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];
|
|
5560
5771
|
for (const candidate of candidates) {
|
|
5561
|
-
if (await fileExists((0,
|
|
5772
|
+
if (await fileExists((0, import_path8.join)(workPath, candidate))) {
|
|
5562
5773
|
return { entrypoint: { entrypoint: candidate, variableName } };
|
|
5563
5774
|
}
|
|
5564
5775
|
}
|
|
@@ -5567,13 +5778,13 @@ async function getPyprojectEntrypointWithDiagnostics(workPath) {
|
|
|
5567
5778
|
async function findValidEntrypoint(workPath, candidates) {
|
|
5568
5779
|
const existingWithoutEntrypoint = [];
|
|
5569
5780
|
for (const candidate of candidates) {
|
|
5570
|
-
const absPath = (0,
|
|
5781
|
+
const absPath = (0, import_path8.join)(workPath, candidate);
|
|
5571
5782
|
if (!await fileExists(absPath))
|
|
5572
5783
|
continue;
|
|
5573
|
-
const content = await
|
|
5784
|
+
const content = await import_fs8.default.promises.readFile(absPath, "utf-8");
|
|
5574
5785
|
const varName = await (0, import_python_analysis5.findAppOrHandler)(content);
|
|
5575
5786
|
if (varName) {
|
|
5576
|
-
(0,
|
|
5787
|
+
(0, import_build_utils10.debug)(`Detected Python entrypoint: ${candidate} (variable: ${varName})`);
|
|
5577
5788
|
return {
|
|
5578
5789
|
entrypoint: { entrypoint: candidate, variableName: varName },
|
|
5579
5790
|
existingWithoutEntrypoint
|
|
@@ -5584,12 +5795,12 @@ async function findValidEntrypoint(workPath, candidates) {
|
|
|
5584
5795
|
return { entrypoint: null, existingWithoutEntrypoint };
|
|
5585
5796
|
}
|
|
5586
5797
|
async function checkDjangoManage(workPath) {
|
|
5587
|
-
const managePath = (0,
|
|
5798
|
+
const managePath = (0, import_path8.join)(workPath, "manage.py");
|
|
5588
5799
|
try {
|
|
5589
|
-
const content = await
|
|
5800
|
+
const content = await import_fs8.default.promises.readFile(managePath, "utf-8");
|
|
5590
5801
|
if (!content.includes("DJANGO_SETTINGS_MODULE"))
|
|
5591
5802
|
return false;
|
|
5592
|
-
(0,
|
|
5803
|
+
(0, import_build_utils10.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
|
|
5593
5804
|
return true;
|
|
5594
5805
|
} catch {
|
|
5595
5806
|
return false;
|
|
@@ -5597,7 +5808,7 @@ async function checkDjangoManage(workPath) {
|
|
|
5597
5808
|
}
|
|
5598
5809
|
async function getSubdirectories(workPath) {
|
|
5599
5810
|
try {
|
|
5600
|
-
const entries = await
|
|
5811
|
+
const entries = await import_fs8.default.promises.readdir(workPath, {
|
|
5601
5812
|
withFileTypes: true
|
|
5602
5813
|
});
|
|
5603
5814
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
@@ -5642,7 +5853,7 @@ ${suggestion}`;
|
|
|
5642
5853
|
const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
5643
5854
|
message = `No ${displayName} entrypoint found. Set "tool.vercel.entrypoint" in pyproject.toml or define an entrypoint in one of: ${searchedList}.`;
|
|
5644
5855
|
}
|
|
5645
|
-
return new
|
|
5856
|
+
return new import_build_utils9.NowBuildError({ code, message, link, action });
|
|
5646
5857
|
}
|
|
5647
5858
|
async function detectGenericPythonEntrypoint(workPath) {
|
|
5648
5859
|
try {
|
|
@@ -5655,7 +5866,7 @@ async function detectGenericPythonEntrypoint(workPath) {
|
|
|
5655
5866
|
findDiagnostics: result
|
|
5656
5867
|
};
|
|
5657
5868
|
} catch {
|
|
5658
|
-
(0,
|
|
5869
|
+
(0, import_build_utils10.debug)("Failed to discover Python entrypoint");
|
|
5659
5870
|
return {
|
|
5660
5871
|
detected: null,
|
|
5661
5872
|
findDiagnostics: { entrypoint: null, existingWithoutEntrypoint: [] }
|
|
@@ -5674,7 +5885,7 @@ async function detectDjangoPythonEntrypoint(workPath) {
|
|
|
5674
5885
|
const subdirs = await getSubdirectories(workPath);
|
|
5675
5886
|
const rootDirs = ["", ...subdirs];
|
|
5676
5887
|
for (const rootDir of rootDirs) {
|
|
5677
|
-
const currPath = (0,
|
|
5888
|
+
const currPath = (0, import_path8.join)(workPath, rootDir);
|
|
5678
5889
|
const isDjango = await checkDjangoManage(currPath);
|
|
5679
5890
|
if (isDjango) {
|
|
5680
5891
|
return {
|
|
@@ -5690,7 +5901,7 @@ async function detectDjangoPythonEntrypoint(workPath) {
|
|
|
5690
5901
|
findDiagnostics: result
|
|
5691
5902
|
};
|
|
5692
5903
|
} catch {
|
|
5693
|
-
(0,
|
|
5904
|
+
(0, import_build_utils10.debug)("Failed to discover Django Python entrypoint");
|
|
5694
5905
|
return emptyResult;
|
|
5695
5906
|
}
|
|
5696
5907
|
}
|
|
@@ -5698,10 +5909,10 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint,
|
|
|
5698
5909
|
if (configuredEntrypoint) {
|
|
5699
5910
|
const { filePath: configEntryFile, varName: configEntryVar } = configuredEntrypoint;
|
|
5700
5911
|
const entrypoint = configEntryFile.endsWith(".py") ? configEntryFile : `${configEntryFile}.py`;
|
|
5701
|
-
const entrypointExists = await fileExists((0,
|
|
5912
|
+
const entrypointExists = await fileExists((0, import_path8.join)(workPath, entrypoint));
|
|
5702
5913
|
if (!entrypointExists) {
|
|
5703
5914
|
return {
|
|
5704
|
-
error: new
|
|
5915
|
+
error: new import_build_utils9.NowBuildError({
|
|
5705
5916
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
5706
5917
|
message: `Configured Python entrypoint "${entrypoint}" was not found.`,
|
|
5707
5918
|
link: PYTHON_ENTRYPOINT_DOCS_URL,
|
|
@@ -5711,17 +5922,17 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint,
|
|
|
5711
5922
|
}
|
|
5712
5923
|
let varName = configEntryVar ?? await checkEntrypoint(workPath, entrypoint);
|
|
5713
5924
|
if (!varName) {
|
|
5714
|
-
const needsDynamicApp = !!service && ((0,
|
|
5925
|
+
const needsDynamicApp = !!service && ((0, import_build_utils9.isScheduleTriggeredService)(service) || (0, import_build_utils9.isQueueTriggeredService)(service) || (0, import_build_utils9.isWorkflowTriggeredService)(service));
|
|
5715
5926
|
if (needsDynamicApp) {
|
|
5716
5927
|
varName = "app";
|
|
5717
5928
|
}
|
|
5718
5929
|
}
|
|
5719
5930
|
if (varName) {
|
|
5720
|
-
(0,
|
|
5931
|
+
(0, import_build_utils10.debug)(`Using configured Python entrypoint: ${entrypoint}`);
|
|
5721
5932
|
return { entrypoint: { entrypoint, variableName: varName } };
|
|
5722
5933
|
} else {
|
|
5723
5934
|
return {
|
|
5724
|
-
error: new
|
|
5935
|
+
error: new import_build_utils9.NowBuildError({
|
|
5725
5936
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
5726
5937
|
message: `Could not find a top-level "app", "application", or "handler" in "${entrypoint}".`,
|
|
5727
5938
|
link: PYTHON_ENTRYPOINT_DOCS_URL,
|
|
@@ -5771,7 +5982,7 @@ var detectEntrypoint = async ({
|
|
|
5771
5982
|
workPath,
|
|
5772
5983
|
framework
|
|
5773
5984
|
}) => {
|
|
5774
|
-
if (!(0,
|
|
5985
|
+
if (!(0, import_build_utils9.isPythonFramework)(framework))
|
|
5775
5986
|
return null;
|
|
5776
5987
|
const detected = await detectPythonEntrypoint(
|
|
5777
5988
|
framework,
|
|
@@ -5788,8 +5999,8 @@ var detectEntrypoint = async ({
|
|
|
5788
5999
|
|
|
5789
6000
|
// src/crons.ts
|
|
5790
6001
|
var DYNAMIC_SCHEDULE = "<dynamic>";
|
|
5791
|
-
var scriptPath = (0,
|
|
5792
|
-
var script =
|
|
6002
|
+
var scriptPath = (0, import_path9.join)(__dirname, "..", "templates", "vc_cron_detect.py");
|
|
6003
|
+
var script = import_fs9.default.readFileSync(scriptPath, "utf-8");
|
|
5793
6004
|
function buildCronRouteTable(crons) {
|
|
5794
6005
|
const table = {};
|
|
5795
6006
|
for (const cron of crons) {
|
|
@@ -5799,13 +6010,13 @@ function buildCronRouteTable(crons) {
|
|
|
5799
6010
|
}
|
|
5800
6011
|
async function getServiceCrons(opts) {
|
|
5801
6012
|
const { service, entrypoint, rawEntrypoint, handlerFunction } = opts;
|
|
5802
|
-
const isScheduledService = !!service && (0,
|
|
6013
|
+
const isScheduledService = !!service && (0, import_build_utils12.isScheduleTriggeredService)(service);
|
|
5803
6014
|
if (!isScheduledService || !service.name || typeof service.schedule !== "string" && !Array.isArray(service.schedule)) {
|
|
5804
6015
|
return void 0;
|
|
5805
6016
|
}
|
|
5806
6017
|
const cronEntrypoint = entrypoint || rawEntrypoint;
|
|
5807
6018
|
if (!cronEntrypoint) {
|
|
5808
|
-
throw new
|
|
6019
|
+
throw new import_build_utils12.NowBuildError({
|
|
5809
6020
|
code: "PYTHON_CRON_NO_ENTRYPOINT",
|
|
5810
6021
|
message: "Cron service is missing an entrypoint."
|
|
5811
6022
|
});
|
|
@@ -5820,7 +6031,7 @@ async function getServiceCrons(opts) {
|
|
|
5820
6031
|
workPath: opts.workPath
|
|
5821
6032
|
});
|
|
5822
6033
|
}
|
|
5823
|
-
const cronPath = (0,
|
|
6034
|
+
const cronPath = (0, import_build_utils12.getInternalServiceCronPath)(
|
|
5824
6035
|
service.name,
|
|
5825
6036
|
cronEntrypoint,
|
|
5826
6037
|
handlerFunction || "cron"
|
|
@@ -5844,7 +6055,7 @@ async function getServiceCronsDynamic(opts) {
|
|
|
5844
6055
|
workPath
|
|
5845
6056
|
} = opts;
|
|
5846
6057
|
if (!handlerFunction) {
|
|
5847
|
-
throw new
|
|
6058
|
+
throw new import_build_utils12.NowBuildError({
|
|
5848
6059
|
code: "PYTHON_DYNAMIC_CRON_NO_HANDLER",
|
|
5849
6060
|
message: 'Dynamic cron detection requires a "module:object" entrypoint where the object has a get_crons() method.'
|
|
5850
6061
|
});
|
|
@@ -5861,7 +6072,7 @@ async function getServiceCronsDynamic(opts) {
|
|
|
5861
6072
|
`Detected ${entries.length} cron entry(s): ${entries.map((e) => `${e.module_function} (${e.schedule})`).join(", ")}`
|
|
5862
6073
|
);
|
|
5863
6074
|
if (entries.length === 0) {
|
|
5864
|
-
throw new
|
|
6075
|
+
throw new import_build_utils12.NowBuildError({
|
|
5865
6076
|
code: "PYTHON_DYNAMIC_CRON_EMPTY",
|
|
5866
6077
|
message: `Dynamic cron detection returned no entries. "${moduleName}.${handlerFunction}.get_crons()" returned an empty iterable.`
|
|
5867
6078
|
});
|
|
@@ -5882,7 +6093,7 @@ async function detectDynamicCrons(opts) {
|
|
|
5882
6093
|
const { pythonBin, env, workPath, moduleName, attrName } = opts;
|
|
5883
6094
|
let stdout;
|
|
5884
6095
|
try {
|
|
5885
|
-
const result = await (0,
|
|
6096
|
+
const result = await (0, import_execa5.default)(
|
|
5886
6097
|
pythonBin,
|
|
5887
6098
|
["-c", script, moduleName, attrName],
|
|
5888
6099
|
{ env, cwd: workPath }
|
|
@@ -5896,7 +6107,7 @@ async function detectDynamicCrons(opts) {
|
|
|
5896
6107
|
detail = parsed2.error;
|
|
5897
6108
|
} catch {
|
|
5898
6109
|
}
|
|
5899
|
-
throw new
|
|
6110
|
+
throw new import_build_utils12.NowBuildError({
|
|
5900
6111
|
code: "PYTHON_DYNAMIC_CRON_DETECTION_FAILED",
|
|
5901
6112
|
message: `Failed to detect dynamic cron entries: ${detail}`
|
|
5902
6113
|
});
|
|
@@ -5905,7 +6116,7 @@ async function detectDynamicCrons(opts) {
|
|
|
5905
6116
|
try {
|
|
5906
6117
|
parsed = JSON.parse(stdout);
|
|
5907
6118
|
} catch {
|
|
5908
|
-
throw new
|
|
6119
|
+
throw new import_build_utils12.NowBuildError({
|
|
5909
6120
|
code: "PYTHON_DYNAMIC_CRON_DETECTION_FAILED",
|
|
5910
6121
|
message: `Dynamic cron detection returned invalid JSON: ${stdout}`
|
|
5911
6122
|
});
|
|
@@ -5915,7 +6126,7 @@ async function detectDynamicCrons(opts) {
|
|
|
5915
6126
|
function moduleColonFuncToCronPath(serviceName, moduleFunction) {
|
|
5916
6127
|
const colonIdx = moduleFunction.indexOf(":");
|
|
5917
6128
|
if (colonIdx === -1) {
|
|
5918
|
-
throw new
|
|
6129
|
+
throw new import_build_utils12.NowBuildError({
|
|
5919
6130
|
code: "PYTHON_DYNAMIC_CRON_INVALID_FORMAT",
|
|
5920
6131
|
message: `Dynamic cron entry must use "module:function" format, got: "${moduleFunction}"`
|
|
5921
6132
|
});
|
|
@@ -5923,14 +6134,14 @@ function moduleColonFuncToCronPath(serviceName, moduleFunction) {
|
|
|
5923
6134
|
const modulePart = moduleFunction.slice(0, colonIdx);
|
|
5924
6135
|
const funcPart = moduleFunction.slice(colonIdx + 1);
|
|
5925
6136
|
const entrypointPath = modulePart.replace(/\./g, "/");
|
|
5926
|
-
return (0,
|
|
6137
|
+
return (0, import_build_utils12.getInternalServiceCronPath)(serviceName, entrypointPath, funcPart);
|
|
5927
6138
|
}
|
|
5928
6139
|
|
|
5929
6140
|
// src/start-dev-server.ts
|
|
5930
6141
|
var import_child_process2 = require("child_process");
|
|
5931
|
-
var
|
|
5932
|
-
var
|
|
5933
|
-
var
|
|
6142
|
+
var import_fs10 = require("fs");
|
|
6143
|
+
var import_path10 = require("path");
|
|
6144
|
+
var import_build_utils13 = require("@vercel/build-utils");
|
|
5934
6145
|
var import_get_port = __toESM(require_get_port());
|
|
5935
6146
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
5936
6147
|
var import_python_analysis6 = require("@vercel/python-analysis");
|
|
@@ -6019,17 +6230,17 @@ async function syncDependencies({
|
|
|
6019
6230
|
let { manifestPath } = installInfo;
|
|
6020
6231
|
const manifest = pythonPackage.manifest;
|
|
6021
6232
|
if (!manifestType || !manifestPath) {
|
|
6022
|
-
(0,
|
|
6233
|
+
(0, import_build_utils13.debug)("No Python project manifest found, skipping dependency sync");
|
|
6023
6234
|
return;
|
|
6024
6235
|
}
|
|
6025
6236
|
if (manifest?.origin && manifestType === "pyproject.toml") {
|
|
6026
|
-
const syncDir = (0,
|
|
6027
|
-
(0,
|
|
6028
|
-
const tempPyproject = (0,
|
|
6237
|
+
const syncDir = (0, import_path10.join)(workPath, ".vercel", "python", "sync");
|
|
6238
|
+
(0, import_fs10.mkdirSync)(syncDir, { recursive: true });
|
|
6239
|
+
const tempPyproject = (0, import_path10.join)(syncDir, "pyproject.toml");
|
|
6029
6240
|
const content = (0, import_python_analysis6.stringifyManifest)(manifest.data);
|
|
6030
|
-
(0,
|
|
6241
|
+
(0, import_fs10.writeFileSync)(tempPyproject, content, "utf8");
|
|
6031
6242
|
manifestPath = tempPyproject;
|
|
6032
|
-
(0,
|
|
6243
|
+
(0, import_build_utils13.debug)(
|
|
6033
6244
|
`Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
|
|
6034
6245
|
);
|
|
6035
6246
|
}
|
|
@@ -6062,7 +6273,7 @@ async function syncDependencies({
|
|
|
6062
6273
|
for (const [channel, chunk] of captured) {
|
|
6063
6274
|
(channel === "stdout" ? writeOut : writeErr)(chunk.toString());
|
|
6064
6275
|
}
|
|
6065
|
-
throw new
|
|
6276
|
+
throw new import_build_utils13.NowBuildError({
|
|
6066
6277
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
6067
6278
|
message: `Failed to install Python dependencies from ${manifestType}: ${err instanceof Error ? err.message : String(err)}`
|
|
6068
6279
|
});
|
|
@@ -6077,14 +6288,14 @@ async function runSync({
|
|
|
6077
6288
|
onStdout,
|
|
6078
6289
|
onStderr
|
|
6079
6290
|
}) {
|
|
6080
|
-
const projectDir = (0,
|
|
6291
|
+
const projectDir = (0, import_path10.dirname)(manifestPath);
|
|
6081
6292
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
6082
6293
|
let spawnCmd;
|
|
6083
6294
|
let spawnArgs;
|
|
6084
6295
|
switch (manifestType) {
|
|
6085
6296
|
case "uv.lock": {
|
|
6086
6297
|
if (!uvPath) {
|
|
6087
|
-
throw new
|
|
6298
|
+
throw new import_build_utils13.NowBuildError({
|
|
6088
6299
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
6089
6300
|
message: "uv is required to install dependencies from uv.lock.",
|
|
6090
6301
|
link: "https://docs.astral.sh/uv/getting-started/installation/",
|
|
@@ -6106,11 +6317,11 @@ async function runSync({
|
|
|
6106
6317
|
break;
|
|
6107
6318
|
}
|
|
6108
6319
|
default:
|
|
6109
|
-
(0,
|
|
6320
|
+
(0, import_build_utils13.debug)(`Unknown manifest type: ${manifestType}`);
|
|
6110
6321
|
return;
|
|
6111
6322
|
}
|
|
6112
6323
|
await new Promise((resolve3, reject) => {
|
|
6113
|
-
(0,
|
|
6324
|
+
(0, import_build_utils13.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
|
|
6114
6325
|
const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
|
|
6115
6326
|
cwd: projectDir,
|
|
6116
6327
|
env: getProtectedUvEnv(env),
|
|
@@ -6154,7 +6365,7 @@ async function installVercelRuntime({
|
|
|
6154
6365
|
onStdout,
|
|
6155
6366
|
onStderr
|
|
6156
6367
|
}) {
|
|
6157
|
-
const targetDir = (0,
|
|
6368
|
+
const targetDir = (0, import_path10.join)(workPath, ".vercel", "python");
|
|
6158
6369
|
let pending = PENDING_RUNTIME_INSTALLS.get(targetDir);
|
|
6159
6370
|
if (!pending) {
|
|
6160
6371
|
pending = doInstallVercelRuntime({
|
|
@@ -6180,8 +6391,8 @@ async function doInstallVercelRuntime({
|
|
|
6180
6391
|
onStdout,
|
|
6181
6392
|
onStderr
|
|
6182
6393
|
}) {
|
|
6183
|
-
(0,
|
|
6184
|
-
const localRuntimeDir = (0,
|
|
6394
|
+
(0, import_fs10.mkdirSync)(targetDir, { recursive: true });
|
|
6395
|
+
const localRuntimeDir = (0, import_path10.join)(
|
|
6185
6396
|
__dirname,
|
|
6186
6397
|
"..",
|
|
6187
6398
|
"..",
|
|
@@ -6189,21 +6400,21 @@ async function doInstallVercelRuntime({
|
|
|
6189
6400
|
"python",
|
|
6190
6401
|
"vercel-runtime"
|
|
6191
6402
|
);
|
|
6192
|
-
const isLocalDev = (0,
|
|
6403
|
+
const isLocalDev = (0, import_fs10.existsSync)((0, import_path10.join)(localRuntimeDir, "pyproject.toml"));
|
|
6193
6404
|
const runtimeDep = env.VERCEL_RUNTIME_PYTHON || (isLocalDev ? localRuntimeDir : `vercel-runtime==${VERCEL_RUNTIME_VERSION}`);
|
|
6194
6405
|
if (!isLocalDev && !env.VERCEL_RUNTIME_PYTHON) {
|
|
6195
|
-
const distInfo = (0,
|
|
6406
|
+
const distInfo = (0, import_path10.join)(
|
|
6196
6407
|
targetDir,
|
|
6197
6408
|
`vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
|
|
6198
6409
|
);
|
|
6199
|
-
if ((0,
|
|
6200
|
-
(0,
|
|
6410
|
+
if ((0, import_fs10.existsSync)(distInfo)) {
|
|
6411
|
+
(0, import_build_utils13.debug)(
|
|
6201
6412
|
`vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
|
|
6202
6413
|
);
|
|
6203
6414
|
return;
|
|
6204
6415
|
}
|
|
6205
6416
|
}
|
|
6206
|
-
(0,
|
|
6417
|
+
(0, import_build_utils13.debug)(
|
|
6207
6418
|
`Installing vercel-runtime into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${runtimeDep})`
|
|
6208
6419
|
);
|
|
6209
6420
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
@@ -6218,14 +6429,14 @@ async function doInstallVercelRuntime({
|
|
|
6218
6429
|
if (onStdout) {
|
|
6219
6430
|
onStdout(data);
|
|
6220
6431
|
} else {
|
|
6221
|
-
(0,
|
|
6432
|
+
(0, import_build_utils13.debug)(data.toString());
|
|
6222
6433
|
}
|
|
6223
6434
|
});
|
|
6224
6435
|
child.stderr?.on("data", (data) => {
|
|
6225
6436
|
if (onStderr) {
|
|
6226
6437
|
onStderr(data);
|
|
6227
6438
|
} else {
|
|
6228
|
-
(0,
|
|
6439
|
+
(0, import_build_utils13.debug)(data.toString());
|
|
6229
6440
|
}
|
|
6230
6441
|
});
|
|
6231
6442
|
child.on("error", reject);
|
|
@@ -6250,7 +6461,7 @@ async function installVercelWorkers({
|
|
|
6250
6461
|
onStdout,
|
|
6251
6462
|
onStderr
|
|
6252
6463
|
}) {
|
|
6253
|
-
const targetDir = (0,
|
|
6464
|
+
const targetDir = (0, import_path10.join)(workPath, ".vercel", "python");
|
|
6254
6465
|
let pending = PENDING_WORKERS_INSTALLS.get(targetDir);
|
|
6255
6466
|
if (!pending) {
|
|
6256
6467
|
pending = doInstallVercelWorkers({
|
|
@@ -6276,8 +6487,8 @@ async function doInstallVercelWorkers({
|
|
|
6276
6487
|
onStdout,
|
|
6277
6488
|
onStderr
|
|
6278
6489
|
}) {
|
|
6279
|
-
(0,
|
|
6280
|
-
const localWorkersDir = (0,
|
|
6490
|
+
(0, import_fs10.mkdirSync)(targetDir, { recursive: true });
|
|
6491
|
+
const localWorkersDir = (0, import_path10.join)(
|
|
6281
6492
|
__dirname,
|
|
6282
6493
|
"..",
|
|
6283
6494
|
"..",
|
|
@@ -6285,21 +6496,21 @@ async function doInstallVercelWorkers({
|
|
|
6285
6496
|
"python",
|
|
6286
6497
|
"vercel-workers"
|
|
6287
6498
|
);
|
|
6288
|
-
const isLocalDev = (0,
|
|
6499
|
+
const isLocalDev = (0, import_fs10.existsSync)((0, import_path10.join)(localWorkersDir, "pyproject.toml"));
|
|
6289
6500
|
const workersDep = env.VERCEL_WORKERS_PYTHON || (isLocalDev ? localWorkersDir : `vercel-workers==${VERCEL_WORKERS_VERSION}`);
|
|
6290
6501
|
if (!isLocalDev && !env.VERCEL_WORKERS_PYTHON) {
|
|
6291
|
-
const distInfo = (0,
|
|
6502
|
+
const distInfo = (0, import_path10.join)(
|
|
6292
6503
|
targetDir,
|
|
6293
6504
|
`vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
|
|
6294
6505
|
);
|
|
6295
|
-
if ((0,
|
|
6296
|
-
(0,
|
|
6506
|
+
if ((0, import_fs10.existsSync)(distInfo)) {
|
|
6507
|
+
(0, import_build_utils13.debug)(
|
|
6297
6508
|
`vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
|
|
6298
6509
|
);
|
|
6299
6510
|
return;
|
|
6300
6511
|
}
|
|
6301
6512
|
}
|
|
6302
|
-
(0,
|
|
6513
|
+
(0, import_build_utils13.debug)(
|
|
6303
6514
|
`Installing vercel-workers into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${workersDep})`
|
|
6304
6515
|
);
|
|
6305
6516
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
@@ -6314,14 +6525,14 @@ async function doInstallVercelWorkers({
|
|
|
6314
6525
|
if (onStdout) {
|
|
6315
6526
|
onStdout(data);
|
|
6316
6527
|
} else {
|
|
6317
|
-
(0,
|
|
6528
|
+
(0, import_build_utils13.debug)(data.toString());
|
|
6318
6529
|
}
|
|
6319
6530
|
});
|
|
6320
6531
|
child.stderr?.on("data", (data) => {
|
|
6321
6532
|
if (onStderr) {
|
|
6322
6533
|
onStderr(data);
|
|
6323
6534
|
} else {
|
|
6324
|
-
(0,
|
|
6535
|
+
(0, import_build_utils13.debug)(data.toString());
|
|
6325
6536
|
}
|
|
6326
6537
|
});
|
|
6327
6538
|
child.on("error", reject);
|
|
@@ -6351,12 +6562,12 @@ function installGlobalCleanupHandlers() {
|
|
|
6351
6562
|
try {
|
|
6352
6563
|
process.kill(info.pid, "SIGTERM");
|
|
6353
6564
|
} catch (err) {
|
|
6354
|
-
(0,
|
|
6565
|
+
(0, import_build_utils13.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
6355
6566
|
}
|
|
6356
6567
|
try {
|
|
6357
6568
|
process.kill(info.pid, "SIGKILL");
|
|
6358
6569
|
} catch (err) {
|
|
6359
|
-
(0,
|
|
6570
|
+
(0, import_build_utils13.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
6360
6571
|
}
|
|
6361
6572
|
PERSISTENT_SERVERS.delete(key);
|
|
6362
6573
|
}
|
|
@@ -6364,7 +6575,7 @@ function installGlobalCleanupHandlers() {
|
|
|
6364
6575
|
try {
|
|
6365
6576
|
restoreWarnings();
|
|
6366
6577
|
} catch (err) {
|
|
6367
|
-
(0,
|
|
6578
|
+
(0, import_build_utils13.debug)(`Error restoring warnings: ${err}`);
|
|
6368
6579
|
}
|
|
6369
6580
|
restoreWarnings = null;
|
|
6370
6581
|
}
|
|
@@ -6381,55 +6592,55 @@ function installGlobalCleanupHandlers() {
|
|
|
6381
6592
|
}
|
|
6382
6593
|
function createDevShim(workPath, entry, modulePath, serviceName, framework, variableName) {
|
|
6383
6594
|
try {
|
|
6384
|
-
const vercelPythonDir = serviceName ? (0,
|
|
6385
|
-
(0,
|
|
6595
|
+
const vercelPythonDir = serviceName ? (0, import_path10.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path10.join)(workPath, ".vercel", "python");
|
|
6596
|
+
(0, import_fs10.mkdirSync)(vercelPythonDir, { recursive: true });
|
|
6386
6597
|
let qualifiedModule = modulePath;
|
|
6387
6598
|
let extraPythonPath;
|
|
6388
|
-
if ((0,
|
|
6389
|
-
const pkgName = (0,
|
|
6599
|
+
if ((0, import_fs10.existsSync)((0, import_path10.join)(workPath, "__init__.py"))) {
|
|
6600
|
+
const pkgName = (0, import_path10.basename)(workPath);
|
|
6390
6601
|
qualifiedModule = `${pkgName}.${modulePath}`;
|
|
6391
|
-
extraPythonPath = (0,
|
|
6602
|
+
extraPythonPath = (0, import_path10.dirname)(workPath);
|
|
6392
6603
|
}
|
|
6393
|
-
const entryAbs = (0,
|
|
6394
|
-
const shimPath = (0,
|
|
6395
|
-
const templatePath = (0,
|
|
6604
|
+
const entryAbs = (0, import_path10.join)(workPath, entry);
|
|
6605
|
+
const shimPath = (0, import_path10.join)(vercelPythonDir, `${DEV_SHIM_MODULE}.py`);
|
|
6606
|
+
const templatePath = (0, import_path10.join)(
|
|
6396
6607
|
__dirname,
|
|
6397
6608
|
"..",
|
|
6398
6609
|
"templates",
|
|
6399
6610
|
`${DEV_SHIM_MODULE}.py`
|
|
6400
6611
|
);
|
|
6401
|
-
const template = (0,
|
|
6612
|
+
const template = (0, import_fs10.readFileSync)(templatePath, "utf8");
|
|
6402
6613
|
const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs).replace(/__VC_DEV_FRAMEWORK__/g, framework).replace(/__VC_DEV_VARIABLE_NAME__/g, variableName);
|
|
6403
|
-
(0,
|
|
6404
|
-
(0,
|
|
6614
|
+
(0, import_fs10.writeFileSync)(shimPath, shimSource, "utf8");
|
|
6615
|
+
(0, import_build_utils13.debug)(`Prepared Python dev shim at ${shimPath}`);
|
|
6405
6616
|
return {
|
|
6406
6617
|
module: DEV_SHIM_MODULE,
|
|
6407
6618
|
extraPythonPath,
|
|
6408
6619
|
shimDir: vercelPythonDir
|
|
6409
6620
|
};
|
|
6410
6621
|
} catch (err) {
|
|
6411
|
-
(0,
|
|
6622
|
+
(0, import_build_utils13.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
|
|
6412
6623
|
return null;
|
|
6413
6624
|
}
|
|
6414
6625
|
}
|
|
6415
6626
|
async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath) {
|
|
6416
6627
|
const { pythonCmd, venvRoot } = useVirtualEnv(workPath, env, systemPython);
|
|
6417
6628
|
if (venvRoot) {
|
|
6418
|
-
(0,
|
|
6629
|
+
(0, import_build_utils13.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
|
|
6419
6630
|
return { command: pythonCmd, args: [] };
|
|
6420
6631
|
}
|
|
6421
|
-
const venvPath = (0,
|
|
6632
|
+
const venvPath = (0, import_path10.join)(workPath, ".venv");
|
|
6422
6633
|
await ensureVenv({
|
|
6423
6634
|
pythonVersion: { pythonPath: systemPython },
|
|
6424
6635
|
venvPath,
|
|
6425
6636
|
uvPath,
|
|
6426
6637
|
quiet: true
|
|
6427
6638
|
});
|
|
6428
|
-
(0,
|
|
6639
|
+
(0, import_build_utils13.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
|
|
6429
6640
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
6430
6641
|
const binDir = getVenvBinDir(venvPath);
|
|
6431
6642
|
env.VIRTUAL_ENV = venvPath;
|
|
6432
|
-
env.PATH = `${binDir}${
|
|
6643
|
+
env.PATH = `${binDir}${import_path10.delimiter}${env.PATH || ""}`;
|
|
6433
6644
|
return { command: pythonBin, args: [] };
|
|
6434
6645
|
}
|
|
6435
6646
|
var startDevServer = async (opts) => {
|
|
@@ -6483,7 +6694,7 @@ var startDevServer = async (opts) => {
|
|
|
6483
6694
|
filePath: entrypoint,
|
|
6484
6695
|
// Schedule-triggered services create their own "app" wrapper dynamically.
|
|
6485
6696
|
// Other services use handlerFunction as the entrypoint variable name.
|
|
6486
|
-
varName: service && (0,
|
|
6697
|
+
varName: service && (0, import_build_utils13.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
6487
6698
|
} : void 0,
|
|
6488
6699
|
service
|
|
6489
6700
|
);
|
|
@@ -6492,7 +6703,7 @@ var startDevServer = async (opts) => {
|
|
|
6492
6703
|
} else {
|
|
6493
6704
|
const hookResult = await runFrameworkHook(framework, {
|
|
6494
6705
|
pythonEnv: env,
|
|
6495
|
-
projectDir: (0,
|
|
6706
|
+
projectDir: (0, import_path10.join)(workPath, detected?.baseDir ?? ""),
|
|
6496
6707
|
workPath,
|
|
6497
6708
|
entrypoint,
|
|
6498
6709
|
detected: detected ?? void 0
|
|
@@ -6503,7 +6714,7 @@ var startDevServer = async (opts) => {
|
|
|
6503
6714
|
if (detected?.error) {
|
|
6504
6715
|
throw detected.error;
|
|
6505
6716
|
}
|
|
6506
|
-
throw new
|
|
6717
|
+
throw new import_build_utils13.NowBuildError({
|
|
6507
6718
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
6508
6719
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
6509
6720
|
});
|
|
@@ -6532,7 +6743,7 @@ var startDevServer = async (opts) => {
|
|
|
6532
6743
|
const yellow = "\x1B[33m";
|
|
6533
6744
|
const white = "\x1B[1m";
|
|
6534
6745
|
const reset = "\x1B[0m";
|
|
6535
|
-
throw new
|
|
6746
|
+
throw new import_build_utils13.NowBuildError({
|
|
6536
6747
|
code: "PYTHON_EXTERNAL_VENV_DETECTED",
|
|
6537
6748
|
message: `Detected activated venv at ${yellow}${venv}${reset}, ${white}vercel dev${reset} manages virtual environments automatically.
|
|
6538
6749
|
Run ${white}deactivate${reset} and try again.`
|
|
@@ -6549,11 +6760,11 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
6549
6760
|
);
|
|
6550
6761
|
spawnCommand = runner.command;
|
|
6551
6762
|
spawnArgsPrefix = runner.args;
|
|
6552
|
-
(0,
|
|
6763
|
+
(0, import_build_utils13.debug)(
|
|
6553
6764
|
`Multi-service Python runner: ${spawnCommand} ${spawnArgsPrefix.join(" ")}`
|
|
6554
6765
|
);
|
|
6555
6766
|
} else if (venv) {
|
|
6556
|
-
(0,
|
|
6767
|
+
(0, import_build_utils13.debug)(`Running in virtualenv at ${venv}`);
|
|
6557
6768
|
} else {
|
|
6558
6769
|
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
6559
6770
|
workPath,
|
|
@@ -6562,9 +6773,9 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
6562
6773
|
);
|
|
6563
6774
|
spawnCommand = venvPythonCmd;
|
|
6564
6775
|
if (venvRoot) {
|
|
6565
|
-
(0,
|
|
6776
|
+
(0, import_build_utils13.debug)(`Using virtualenv at ${venvRoot}`);
|
|
6566
6777
|
} else {
|
|
6567
|
-
(0,
|
|
6778
|
+
(0, import_build_utils13.debug)("No virtualenv found");
|
|
6568
6779
|
try {
|
|
6569
6780
|
const yellow = "\x1B[33m";
|
|
6570
6781
|
const reset = "\x1B[0m";
|
|
@@ -6628,7 +6839,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
6628
6839
|
const port = typeof meta.port === "number" ? meta.port : await (0, import_get_port.default)();
|
|
6629
6840
|
env.PORT = `${port}`;
|
|
6630
6841
|
if (entry) {
|
|
6631
|
-
env.__VC_HANDLER_ENTRYPOINT_ABS = (0,
|
|
6842
|
+
env.__VC_HANDLER_ENTRYPOINT_ABS = (0, import_path10.join)(workPath, entry);
|
|
6632
6843
|
}
|
|
6633
6844
|
const devShim = createDevShim(
|
|
6634
6845
|
workPath,
|
|
@@ -6639,8 +6850,8 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
6639
6850
|
variableName ?? ""
|
|
6640
6851
|
);
|
|
6641
6852
|
if (devShim) {
|
|
6642
|
-
const shimDir = devShim.shimDir || (0,
|
|
6643
|
-
const runtimeDir = (0,
|
|
6853
|
+
const shimDir = devShim.shimDir || (0, import_path10.join)(workPath, ".vercel", "python");
|
|
6854
|
+
const runtimeDir = (0, import_path10.join)(workPath, ".vercel", "python");
|
|
6644
6855
|
const pathParts = shimDir !== runtimeDir ? [shimDir, runtimeDir] : [shimDir];
|
|
6645
6856
|
if (devShim.extraPythonPath) {
|
|
6646
6857
|
pathParts.push(devShim.extraPythonPath);
|
|
@@ -6649,12 +6860,12 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
6649
6860
|
if (existingPythonPath) {
|
|
6650
6861
|
pathParts.push(existingPythonPath);
|
|
6651
6862
|
}
|
|
6652
|
-
env.PYTHONPATH = pathParts.join(
|
|
6863
|
+
env.PYTHONPATH = pathParts.join(import_path10.delimiter);
|
|
6653
6864
|
}
|
|
6654
6865
|
const moduleToRun = devShim?.module || modulePath;
|
|
6655
6866
|
const pythonArgs = ["-u", "-m", moduleToRun];
|
|
6656
6867
|
const argv = [...spawnArgsPrefix, ...pythonArgs];
|
|
6657
|
-
(0,
|
|
6868
|
+
(0, import_build_utils13.debug)(
|
|
6658
6869
|
`Starting Python dev server (${framework}): ${spawnCommand} ${argv.join(" ")} [PORT=${port}]`
|
|
6659
6870
|
);
|
|
6660
6871
|
if (process.stdout.columns) {
|
|
@@ -6708,7 +6919,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
6708
6919
|
};
|
|
6709
6920
|
|
|
6710
6921
|
// src/quirks/index.ts
|
|
6711
|
-
var
|
|
6922
|
+
var import_build_utils16 = require("@vercel/build-utils");
|
|
6712
6923
|
var import_python_analysis8 = require("@vercel/python-analysis");
|
|
6713
6924
|
|
|
6714
6925
|
// src/quirks/matplotlib.ts
|
|
@@ -6722,9 +6933,9 @@ var matplotlibQuirk = {
|
|
|
6722
6933
|
};
|
|
6723
6934
|
|
|
6724
6935
|
// src/quirks/litellm.ts
|
|
6725
|
-
var
|
|
6726
|
-
var
|
|
6727
|
-
var
|
|
6936
|
+
var import_fs11 = __toESM(require("fs"));
|
|
6937
|
+
var import_path11 = require("path");
|
|
6938
|
+
var import_build_utils14 = require("@vercel/build-utils");
|
|
6728
6939
|
var LAMBDA_ROOT = "/var/task";
|
|
6729
6940
|
var CONFIG_CANDIDATES = [
|
|
6730
6941
|
"litellm_config.yaml",
|
|
@@ -6734,9 +6945,9 @@ var CONFIG_CANDIDATES = [
|
|
|
6734
6945
|
];
|
|
6735
6946
|
async function findConfigFile(workPath) {
|
|
6736
6947
|
for (const name of CONFIG_CANDIDATES) {
|
|
6737
|
-
const candidate = (0,
|
|
6948
|
+
const candidate = (0, import_path11.join)(workPath, name);
|
|
6738
6949
|
try {
|
|
6739
|
-
await
|
|
6950
|
+
await import_fs11.default.promises.access(candidate);
|
|
6740
6951
|
return name;
|
|
6741
6952
|
} catch {
|
|
6742
6953
|
}
|
|
@@ -6751,32 +6962,32 @@ var litellmQuirk = {
|
|
|
6751
6962
|
const env = {};
|
|
6752
6963
|
const sitePackagesDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
6753
6964
|
for (const sitePackages of sitePackagesDirs) {
|
|
6754
|
-
const schemaPath = (0,
|
|
6965
|
+
const schemaPath = (0, import_path11.join)(
|
|
6755
6966
|
sitePackages,
|
|
6756
6967
|
"litellm",
|
|
6757
6968
|
"proxy",
|
|
6758
6969
|
"schema.prisma"
|
|
6759
6970
|
);
|
|
6760
6971
|
try {
|
|
6761
|
-
await
|
|
6762
|
-
(0,
|
|
6972
|
+
await import_fs11.default.promises.access(schemaPath);
|
|
6973
|
+
(0, import_build_utils14.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
|
|
6763
6974
|
buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
|
|
6764
6975
|
break;
|
|
6765
6976
|
} catch {
|
|
6766
6977
|
}
|
|
6767
6978
|
}
|
|
6768
6979
|
if (!buildEnv.PRISMA_SCHEMA_PATH) {
|
|
6769
|
-
(0,
|
|
6980
|
+
(0, import_build_utils14.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
|
|
6770
6981
|
}
|
|
6771
6982
|
if (!process.env.CONFIG_FILE_PATH) {
|
|
6772
6983
|
const configName = await findConfigFile(ctx.workPath);
|
|
6773
6984
|
if (configName) {
|
|
6774
|
-
(0,
|
|
6775
|
-
buildEnv.CONFIG_FILE_PATH = (0,
|
|
6776
|
-
env.CONFIG_FILE_PATH = (0,
|
|
6985
|
+
(0, import_build_utils14.debug)(`LiteLLM quirk: found config at ${configName}`);
|
|
6986
|
+
buildEnv.CONFIG_FILE_PATH = (0, import_path11.join)(ctx.workPath, configName);
|
|
6987
|
+
env.CONFIG_FILE_PATH = (0, import_path11.join)(LAMBDA_ROOT, configName);
|
|
6777
6988
|
}
|
|
6778
6989
|
} else {
|
|
6779
|
-
(0,
|
|
6990
|
+
(0, import_build_utils14.debug)(
|
|
6780
6991
|
`LiteLLM quirk: CONFIG_FILE_PATH already set to ${process.env.CONFIG_FILE_PATH}`
|
|
6781
6992
|
);
|
|
6782
6993
|
}
|
|
@@ -6785,10 +6996,10 @@ var litellmQuirk = {
|
|
|
6785
6996
|
};
|
|
6786
6997
|
|
|
6787
6998
|
// src/quirks/prisma.ts
|
|
6788
|
-
var
|
|
6789
|
-
var
|
|
6790
|
-
var
|
|
6791
|
-
var
|
|
6999
|
+
var import_fs12 = __toESM(require("fs"));
|
|
7000
|
+
var import_path12 = require("path");
|
|
7001
|
+
var import_execa6 = __toESM(require_execa());
|
|
7002
|
+
var import_build_utils15 = require("@vercel/build-utils");
|
|
6792
7003
|
var import_python_analysis7 = require("@vercel/python-analysis");
|
|
6793
7004
|
function execErrorMessage(err) {
|
|
6794
7005
|
if (err != null && typeof err === "object" && "stderr" in err) {
|
|
@@ -6826,22 +7037,22 @@ model DummyModel {
|
|
|
6826
7037
|
async function findUserSchema(workPath) {
|
|
6827
7038
|
const envPath = process.env.PRISMA_SCHEMA_PATH;
|
|
6828
7039
|
if (envPath) {
|
|
6829
|
-
const resolved = (0,
|
|
7040
|
+
const resolved = (0, import_path12.isAbsolute)(envPath) ? envPath : (0, import_path12.join)(workPath, envPath);
|
|
6830
7041
|
try {
|
|
6831
|
-
await
|
|
7042
|
+
await import_fs12.default.promises.access(resolved);
|
|
6832
7043
|
return resolved;
|
|
6833
7044
|
} catch {
|
|
6834
|
-
(0,
|
|
7045
|
+
(0, import_build_utils15.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
|
|
6835
7046
|
return null;
|
|
6836
7047
|
}
|
|
6837
7048
|
}
|
|
6838
7049
|
const candidates = [
|
|
6839
|
-
(0,
|
|
6840
|
-
(0,
|
|
7050
|
+
(0, import_path12.join)(workPath, "schema.prisma"),
|
|
7051
|
+
(0, import_path12.join)(workPath, "prisma", "schema.prisma")
|
|
6841
7052
|
];
|
|
6842
7053
|
for (const candidate of candidates) {
|
|
6843
7054
|
try {
|
|
6844
|
-
await
|
|
7055
|
+
await import_fs12.default.promises.access(candidate);
|
|
6845
7056
|
return candidate;
|
|
6846
7057
|
} catch {
|
|
6847
7058
|
}
|
|
@@ -6852,32 +7063,32 @@ async function collectFiles(dir, base) {
|
|
|
6852
7063
|
const result = [];
|
|
6853
7064
|
let entries;
|
|
6854
7065
|
try {
|
|
6855
|
-
entries = await
|
|
7066
|
+
entries = await import_fs12.default.promises.readdir(dir, { withFileTypes: true });
|
|
6856
7067
|
} catch {
|
|
6857
7068
|
return result;
|
|
6858
7069
|
}
|
|
6859
7070
|
for (const entry of entries) {
|
|
6860
7071
|
if (entry.name === "__pycache__")
|
|
6861
7072
|
continue;
|
|
6862
|
-
const full = (0,
|
|
7073
|
+
const full = (0, import_path12.join)(dir, entry.name);
|
|
6863
7074
|
if (entry.isDirectory()) {
|
|
6864
7075
|
result.push(...await collectFiles(full, base));
|
|
6865
7076
|
} else {
|
|
6866
|
-
result.push((0,
|
|
7077
|
+
result.push((0, import_path12.relative)(base, full));
|
|
6867
7078
|
}
|
|
6868
7079
|
}
|
|
6869
7080
|
return result;
|
|
6870
7081
|
}
|
|
6871
7082
|
async function cleanCacheArtifacts(cacheDir, extras = []) {
|
|
6872
7083
|
const paths = [
|
|
6873
|
-
(0,
|
|
6874
|
-
(0,
|
|
6875
|
-
(0,
|
|
7084
|
+
(0, import_path12.join)(cacheDir, "node_modules"),
|
|
7085
|
+
(0, import_path12.join)(cacheDir, "package.json"),
|
|
7086
|
+
(0, import_path12.join)(cacheDir, "package-lock.json"),
|
|
6876
7087
|
...extras
|
|
6877
7088
|
];
|
|
6878
7089
|
for (const p of paths) {
|
|
6879
7090
|
try {
|
|
6880
|
-
await
|
|
7091
|
+
await import_fs12.default.promises.rm(p, { recursive: true, force: true });
|
|
6881
7092
|
} catch (err) {
|
|
6882
7093
|
console.warn(
|
|
6883
7094
|
`could not clean up ${p}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -6887,7 +7098,7 @@ async function cleanCacheArtifacts(cacheDir, extras = []) {
|
|
|
6887
7098
|
}
|
|
6888
7099
|
async function isClientGenerated(pythonPath, env) {
|
|
6889
7100
|
try {
|
|
6890
|
-
await (0,
|
|
7101
|
+
await (0, import_execa6.default)(pythonPath, ["-c", "import prisma.client"], {
|
|
6891
7102
|
env,
|
|
6892
7103
|
stdio: "pipe"
|
|
6893
7104
|
});
|
|
@@ -6901,7 +7112,7 @@ var prismaQuirk = {
|
|
|
6901
7112
|
async run(ctx) {
|
|
6902
7113
|
const { venvPath, pythonEnv, workPath } = ctx;
|
|
6903
7114
|
const pythonPath = getVenvPythonBin(venvPath);
|
|
6904
|
-
const runtimeCacheDir = (0,
|
|
7115
|
+
const runtimeCacheDir = (0, import_path12.join)(
|
|
6905
7116
|
LAMBDA_ROOT2,
|
|
6906
7117
|
resolveVendorDir(),
|
|
6907
7118
|
"prisma",
|
|
@@ -6911,7 +7122,7 @@ var prismaQuirk = {
|
|
|
6911
7122
|
let sitePackages;
|
|
6912
7123
|
for (const dir of sitePackagesDirs) {
|
|
6913
7124
|
try {
|
|
6914
|
-
await
|
|
7125
|
+
await import_fs12.default.promises.access((0, import_path12.join)(dir, "prisma"));
|
|
6915
7126
|
sitePackages = dir;
|
|
6916
7127
|
break;
|
|
6917
7128
|
} catch {
|
|
@@ -6923,21 +7134,21 @@ var prismaQuirk = {
|
|
|
6923
7134
|
);
|
|
6924
7135
|
return {};
|
|
6925
7136
|
}
|
|
6926
|
-
const cacheDir = (0,
|
|
6927
|
-
await
|
|
7137
|
+
const cacheDir = (0, import_path12.join)(sitePackages, "prisma", "__bincache__");
|
|
7138
|
+
await import_fs12.default.promises.mkdir(cacheDir, { recursive: true });
|
|
6928
7139
|
const generateEnv = {
|
|
6929
7140
|
...pythonEnv,
|
|
6930
7141
|
PRISMA_BINARY_CACHE_DIR: cacheDir
|
|
6931
7142
|
};
|
|
6932
|
-
const generatedDir = (0,
|
|
6933
|
-
const dummySchemaPath = (0,
|
|
6934
|
-
await
|
|
7143
|
+
const generatedDir = (0, import_path12.join)(workPath, "_prisma_generated");
|
|
7144
|
+
const dummySchemaPath = (0, import_path12.join)(workPath, DUMMY_SCHEMA_NAME);
|
|
7145
|
+
await import_fs12.default.promises.writeFile(
|
|
6935
7146
|
dummySchemaPath,
|
|
6936
7147
|
buildDummySchema(generatedDir)
|
|
6937
7148
|
);
|
|
6938
|
-
(0,
|
|
7149
|
+
(0, import_build_utils15.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
|
|
6939
7150
|
try {
|
|
6940
|
-
const dummyResult = await (0,
|
|
7151
|
+
const dummyResult = await (0, import_execa6.default)(
|
|
6941
7152
|
pythonPath,
|
|
6942
7153
|
["-m", "prisma", "generate", `--schema=${dummySchemaPath}`],
|
|
6943
7154
|
{
|
|
@@ -6947,11 +7158,11 @@ var prismaQuirk = {
|
|
|
6947
7158
|
}
|
|
6948
7159
|
);
|
|
6949
7160
|
if (dummyResult.stdout)
|
|
6950
|
-
(0,
|
|
7161
|
+
(0, import_build_utils15.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
|
|
6951
7162
|
if (dummyResult.stderr)
|
|
6952
|
-
(0,
|
|
7163
|
+
(0, import_build_utils15.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
|
|
6953
7164
|
} catch (err) {
|
|
6954
|
-
throw new
|
|
7165
|
+
throw new import_build_utils15.NowBuildError({
|
|
6955
7166
|
code: "PRISMA_GENERATE_FAILED",
|
|
6956
7167
|
message: `Prisma engine download failed during \`prisma generate\`. Check that your prisma version is compatible with this Python version.
|
|
6957
7168
|
` + execErrorMessage(err)
|
|
@@ -6959,47 +7170,47 @@ var prismaQuirk = {
|
|
|
6959
7170
|
}
|
|
6960
7171
|
const srcBinaryPrefix = `query-engine-${getLambdaBinaryTarget()}`;
|
|
6961
7172
|
const runtimeName = `prisma-query-engine-rhel-openssl-${RUNTIME_OPENSSL_VERSION}.x`;
|
|
6962
|
-
const nodeModulesDir = (0,
|
|
7173
|
+
const nodeModulesDir = (0, import_path12.join)(cacheDir, "node_modules", "prisma");
|
|
6963
7174
|
let engineCopied = false;
|
|
6964
7175
|
try {
|
|
6965
|
-
const entries = await
|
|
7176
|
+
const entries = await import_fs12.default.promises.readdir(nodeModulesDir);
|
|
6966
7177
|
for (const entry of entries) {
|
|
6967
7178
|
if (!entry.startsWith(srcBinaryPrefix))
|
|
6968
7179
|
continue;
|
|
6969
|
-
const srcPath = (0,
|
|
6970
|
-
const destPath = (0,
|
|
7180
|
+
const srcPath = (0, import_path12.join)(nodeModulesDir, entry);
|
|
7181
|
+
const destPath = (0, import_path12.join)(cacheDir, runtimeName);
|
|
6971
7182
|
try {
|
|
6972
|
-
await
|
|
6973
|
-
(0,
|
|
7183
|
+
await import_fs12.default.promises.access(destPath);
|
|
7184
|
+
(0, import_build_utils15.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
|
|
6974
7185
|
} catch {
|
|
6975
|
-
(0,
|
|
6976
|
-
await
|
|
7186
|
+
(0, import_build_utils15.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
|
|
7187
|
+
await import_fs12.default.promises.copyFile(srcPath, destPath);
|
|
6977
7188
|
}
|
|
6978
7189
|
engineCopied = true;
|
|
6979
7190
|
}
|
|
6980
7191
|
} catch (err) {
|
|
6981
|
-
throw new
|
|
7192
|
+
throw new import_build_utils15.NowBuildError({
|
|
6982
7193
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
6983
7194
|
message: `could not read Prisma engine directory "${nodeModulesDir}". This may indicate an incompatible prisma version.
|
|
6984
7195
|
` + (err instanceof Error ? err.message : String(err))
|
|
6985
7196
|
});
|
|
6986
7197
|
}
|
|
6987
7198
|
if (!engineCopied) {
|
|
6988
|
-
throw new
|
|
7199
|
+
throw new import_build_utils15.NowBuildError({
|
|
6989
7200
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
6990
7201
|
message: `could not find engine binary matching "${srcBinaryPrefix}*" in "${nodeModulesDir}". This may indicate an incompatible prisma version or an unsupported platform (${process.arch}).`
|
|
6991
7202
|
});
|
|
6992
7203
|
}
|
|
6993
|
-
const shimPath = (0,
|
|
6994
|
-
await
|
|
7204
|
+
const shimPath = (0, import_path12.join)(cacheDir, "openssl");
|
|
7205
|
+
await import_fs12.default.promises.writeFile(
|
|
6995
7206
|
shimPath,
|
|
6996
7207
|
`#!/bin/sh
|
|
6997
7208
|
echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIME_OPENSSL_VERSION}.0)"
|
|
6998
7209
|
`
|
|
6999
7210
|
);
|
|
7000
|
-
await
|
|
7211
|
+
await import_fs12.default.promises.chmod(shimPath, 493);
|
|
7001
7212
|
for (const p of [generatedDir, dummySchemaPath]) {
|
|
7002
|
-
await
|
|
7213
|
+
await import_fs12.default.promises.rm(p, { recursive: true, force: true });
|
|
7003
7214
|
}
|
|
7004
7215
|
await cleanCacheArtifacts(cacheDir);
|
|
7005
7216
|
const generateMode = (process.env.VERCEL_PRISMA_GENERATE_CLIENT ?? "auto").toLowerCase();
|
|
@@ -7012,16 +7223,16 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
7012
7223
|
pythonEnv
|
|
7013
7224
|
);
|
|
7014
7225
|
if (clientAlreadyGenerated) {
|
|
7015
|
-
(0,
|
|
7226
|
+
(0, import_build_utils15.debug)(
|
|
7016
7227
|
"Prisma quirk: client already generated, skipping user schema generate"
|
|
7017
7228
|
);
|
|
7018
7229
|
shouldGenerate = false;
|
|
7019
7230
|
}
|
|
7020
7231
|
}
|
|
7021
7232
|
if (shouldGenerate) {
|
|
7022
|
-
(0,
|
|
7233
|
+
(0, import_build_utils15.debug)(`Running prisma generate with user schema: ${userSchema}`);
|
|
7023
7234
|
try {
|
|
7024
|
-
const userResult = await (0,
|
|
7235
|
+
const userResult = await (0, import_execa6.default)(
|
|
7025
7236
|
pythonPath,
|
|
7026
7237
|
["-m", "prisma", "generate", `--schema=${userSchema}`],
|
|
7027
7238
|
{
|
|
@@ -7031,11 +7242,11 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
7031
7242
|
}
|
|
7032
7243
|
);
|
|
7033
7244
|
if (userResult.stdout)
|
|
7034
|
-
(0,
|
|
7245
|
+
(0, import_build_utils15.debug)(`prisma generate stdout: ${userResult.stdout}`);
|
|
7035
7246
|
if (userResult.stderr)
|
|
7036
|
-
(0,
|
|
7247
|
+
(0, import_build_utils15.debug)(`prisma generate stderr: ${userResult.stderr}`);
|
|
7037
7248
|
} catch (err) {
|
|
7038
|
-
throw new
|
|
7249
|
+
throw new import_build_utils15.NowBuildError({
|
|
7039
7250
|
code: "PRISMA_GENERATE_FAILED",
|
|
7040
7251
|
message: `\`prisma generate\` failed for schema "${userSchema}".
|
|
7041
7252
|
` + execErrorMessage(err)
|
|
@@ -7046,12 +7257,12 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
7046
7257
|
}
|
|
7047
7258
|
try {
|
|
7048
7259
|
const allFiles = await collectFiles(
|
|
7049
|
-
(0,
|
|
7260
|
+
(0, import_path12.join)(sitePackages, "prisma"),
|
|
7050
7261
|
sitePackages
|
|
7051
7262
|
);
|
|
7052
7263
|
const count = await (0, import_python_analysis7.extendDistRecord)(sitePackages, "prisma", allFiles);
|
|
7053
7264
|
if (count > 0) {
|
|
7054
|
-
(0,
|
|
7265
|
+
(0, import_build_utils15.debug)(`Appended ${count} entries to prisma RECORD`);
|
|
7055
7266
|
}
|
|
7056
7267
|
} catch (err) {
|
|
7057
7268
|
console.warn(
|
|
@@ -7145,13 +7356,13 @@ async function runQuirks(ctx) {
|
|
|
7145
7356
|
(0, import_python_analysis8.normalizePackageName)(quirk.dependency)
|
|
7146
7357
|
);
|
|
7147
7358
|
if (!installed) {
|
|
7148
|
-
(0,
|
|
7359
|
+
(0, import_build_utils16.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
|
|
7149
7360
|
}
|
|
7150
7361
|
return installed;
|
|
7151
7362
|
});
|
|
7152
7363
|
const sorted = toposortQuirks(activated);
|
|
7153
7364
|
for (const quirk of sorted) {
|
|
7154
|
-
(0,
|
|
7365
|
+
(0, import_build_utils16.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
|
|
7155
7366
|
const result = await quirk.run(ctx);
|
|
7156
7367
|
if (result.env) {
|
|
7157
7368
|
Object.assign(mergedEnv, result.env);
|
|
@@ -7172,14 +7383,14 @@ async function runQuirks(ctx) {
|
|
|
7172
7383
|
}
|
|
7173
7384
|
|
|
7174
7385
|
// src/django.ts
|
|
7175
|
-
var
|
|
7176
|
-
var
|
|
7177
|
-
var
|
|
7178
|
-
var
|
|
7179
|
-
var scriptPath2 = (0,
|
|
7180
|
-
var script2 =
|
|
7386
|
+
var import_fs13 = __toESM(require("fs"));
|
|
7387
|
+
var import_path13 = require("path");
|
|
7388
|
+
var import_execa7 = __toESM(require_execa());
|
|
7389
|
+
var import_build_utils17 = require("@vercel/build-utils");
|
|
7390
|
+
var scriptPath2 = (0, import_path13.join)(__dirname, "..", "templates", "vc_django_settings.py");
|
|
7391
|
+
var script2 = import_fs13.default.readFileSync(scriptPath2, "utf-8");
|
|
7181
7392
|
async function getDjangoSettings(projectDir, env) {
|
|
7182
|
-
const { stdout } = await (0,
|
|
7393
|
+
const { stdout } = await (0, import_execa7.default)("python", ["-c", script2], {
|
|
7183
7394
|
env,
|
|
7184
7395
|
cwd: projectDir
|
|
7185
7396
|
});
|
|
@@ -7205,21 +7416,21 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7205
7416
|
const installedApps = djangoSettings["INSTALLED_APPS"] ?? [];
|
|
7206
7417
|
const staticfilesDirs = djangoSettings["STATICFILES_DIRS"] ?? [];
|
|
7207
7418
|
const staticSourceDirs = [
|
|
7208
|
-
...installedApps.map((app) => (0,
|
|
7419
|
+
...installedApps.map((app) => (0, import_path13.join)(workPath, ...app.split("."), "static")),
|
|
7209
7420
|
// TODO: Deal with optional prefixes in STATICFILES_DIRS.
|
|
7210
7421
|
...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
|
|
7211
|
-
].filter((d) =>
|
|
7422
|
+
].filter((d) => import_fs13.default.existsSync(d));
|
|
7212
7423
|
if (storageBackend.startsWith("storages.backends.")) {
|
|
7213
7424
|
console.log(
|
|
7214
7425
|
"django-storages detected \u2014 running collectstatic with original settings"
|
|
7215
7426
|
);
|
|
7216
|
-
await (0,
|
|
7427
|
+
await (0, import_execa7.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
|
|
7217
7428
|
env: { ...env, DJANGO_SETTINGS_MODULE: settingsModule },
|
|
7218
7429
|
cwd: workPath
|
|
7219
7430
|
});
|
|
7220
7431
|
return {
|
|
7221
7432
|
staticSourceDirs,
|
|
7222
|
-
staticRoot: staticRoot ? (0,
|
|
7433
|
+
staticRoot: staticRoot ? (0, import_path13.resolve)(workPath, staticRoot) : null,
|
|
7223
7434
|
cdnOutputDir: null,
|
|
7224
7435
|
manifestRelPath: null
|
|
7225
7436
|
};
|
|
@@ -7231,9 +7442,9 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7231
7442
|
return null;
|
|
7232
7443
|
}
|
|
7233
7444
|
const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
|
|
7234
|
-
const staticOutputDir = (0,
|
|
7235
|
-
await
|
|
7236
|
-
const shimPath = (0,
|
|
7445
|
+
const staticOutputDir = (0, import_path13.join)(outputStaticDir, staticUrlPath);
|
|
7446
|
+
await import_fs13.default.promises.mkdir(staticOutputDir, { recursive: true });
|
|
7447
|
+
const shimPath = (0, import_path13.join)(workPath, "_vercel_collectstatic_settings.py");
|
|
7237
7448
|
const shimLines = [
|
|
7238
7449
|
`from ${settingsModule} import *`,
|
|
7239
7450
|
`STATIC_ROOT = ${JSON.stringify(staticOutputDir)}`
|
|
@@ -7241,10 +7452,10 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7241
7452
|
if (whitenoiseUseFinders) {
|
|
7242
7453
|
shimLines.push(`WHITENOISE_USE_FINDERS = False`);
|
|
7243
7454
|
}
|
|
7244
|
-
await
|
|
7455
|
+
await import_fs13.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
|
|
7245
7456
|
try {
|
|
7246
7457
|
console.log("Running collectstatic...");
|
|
7247
|
-
await (0,
|
|
7458
|
+
await (0, import_execa7.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
|
|
7248
7459
|
env: {
|
|
7249
7460
|
...env,
|
|
7250
7461
|
DJANGO_SETTINGS_MODULE: "_vercel_collectstatic_settings"
|
|
@@ -7252,7 +7463,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7252
7463
|
cwd: workPath
|
|
7253
7464
|
});
|
|
7254
7465
|
} finally {
|
|
7255
|
-
await
|
|
7466
|
+
await import_fs13.default.promises.unlink(shimPath).catch(() => {
|
|
7256
7467
|
});
|
|
7257
7468
|
}
|
|
7258
7469
|
const MANIFEST_STORAGE_BACKENDS = [
|
|
@@ -7261,17 +7472,17 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7261
7472
|
];
|
|
7262
7473
|
let manifestRelPath = null;
|
|
7263
7474
|
if (MANIFEST_STORAGE_BACKENDS.includes(storageBackend) && staticRoot) {
|
|
7264
|
-
const manifestSrc = (0,
|
|
7265
|
-
const resolvedStaticRoot = (0,
|
|
7266
|
-
const manifestDest = (0,
|
|
7267
|
-
await
|
|
7268
|
-
await
|
|
7269
|
-
manifestRelPath = (0,
|
|
7270
|
-
(0,
|
|
7475
|
+
const manifestSrc = (0, import_path13.join)(staticOutputDir, "staticfiles.json");
|
|
7476
|
+
const resolvedStaticRoot = (0, import_path13.resolve)(workPath, staticRoot);
|
|
7477
|
+
const manifestDest = (0, import_path13.join)(resolvedStaticRoot, "staticfiles.json");
|
|
7478
|
+
await import_fs13.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
|
|
7479
|
+
await import_fs13.default.promises.copyFile(manifestSrc, manifestDest);
|
|
7480
|
+
manifestRelPath = (0, import_path13.relative)(workPath, manifestDest);
|
|
7481
|
+
(0, import_build_utils17.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
|
|
7271
7482
|
}
|
|
7272
7483
|
return {
|
|
7273
7484
|
staticSourceDirs,
|
|
7274
|
-
staticRoot: staticRoot ? (0,
|
|
7485
|
+
staticRoot: staticRoot ? (0, import_path13.resolve)(workPath, staticRoot) : null,
|
|
7275
7486
|
cdnOutputDir: outputStaticDir,
|
|
7276
7487
|
manifestRelPath
|
|
7277
7488
|
};
|
|
@@ -7279,9 +7490,57 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
7279
7490
|
|
|
7280
7491
|
// src/index.ts
|
|
7281
7492
|
var import_python_analysis9 = require("@vercel/python-analysis");
|
|
7282
|
-
var writeFile =
|
|
7493
|
+
var writeFile = import_fs14.default.promises.writeFile;
|
|
7283
7494
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
7284
7495
|
var version = -1;
|
|
7496
|
+
function addFiles(target, source) {
|
|
7497
|
+
for (const [p, f] of Object.entries(source)) {
|
|
7498
|
+
target[p] = f;
|
|
7499
|
+
}
|
|
7500
|
+
}
|
|
7501
|
+
function addBytecodeWithinCapacity(files, bytecodeInfo, capacity) {
|
|
7502
|
+
if (!bytecodeInfo || bytecodeInfo.totalSize <= 0 || capacity <= 0) {
|
|
7503
|
+
return capacity;
|
|
7504
|
+
}
|
|
7505
|
+
if (bytecodeInfo.totalSize <= capacity) {
|
|
7506
|
+
addFiles(files, bytecodeInfo.files);
|
|
7507
|
+
return capacity - bytecodeInfo.totalSize;
|
|
7508
|
+
}
|
|
7509
|
+
const selected = lambdaKnapsack(bytecodeInfo.perItemSizes, capacity);
|
|
7510
|
+
let remainingCapacity = capacity;
|
|
7511
|
+
for (const p of selected) {
|
|
7512
|
+
const file = bytecodeInfo.files[p];
|
|
7513
|
+
if (!file)
|
|
7514
|
+
continue;
|
|
7515
|
+
files[p] = file;
|
|
7516
|
+
remainingCapacity -= bytecodeInfo.perItemSizes.get(p) ?? 0;
|
|
7517
|
+
}
|
|
7518
|
+
return remainingCapacity;
|
|
7519
|
+
}
|
|
7520
|
+
async function addVendorBytecodeWithinCapacity({
|
|
7521
|
+
files,
|
|
7522
|
+
depExternalizer,
|
|
7523
|
+
vendorDir,
|
|
7524
|
+
bytecodeInfo,
|
|
7525
|
+
capacity
|
|
7526
|
+
}) {
|
|
7527
|
+
if (!bytecodeInfo || bytecodeInfo.totalSize <= 0 || capacity <= 0) {
|
|
7528
|
+
return capacity;
|
|
7529
|
+
}
|
|
7530
|
+
if (bytecodeInfo.totalSize <= capacity) {
|
|
7531
|
+
addFiles(files, bytecodeInfo.files);
|
|
7532
|
+
return capacity - bytecodeInfo.totalSize;
|
|
7533
|
+
}
|
|
7534
|
+
const selectedPkgs = lambdaKnapsack(bytecodeInfo.perItemSizes, capacity);
|
|
7535
|
+
if (selectedPkgs.length === 0)
|
|
7536
|
+
return capacity;
|
|
7537
|
+
const selectedBytecode = await depExternalizer.collectBytecodeFiles({
|
|
7538
|
+
vendorDirName: vendorDir,
|
|
7539
|
+
includePackages: selectedPkgs
|
|
7540
|
+
});
|
|
7541
|
+
addFiles(files, selectedBytecode.files);
|
|
7542
|
+
return capacity - selectedBytecode.totalSize;
|
|
7543
|
+
}
|
|
7285
7544
|
async function runFrameworkHook(framework, ctx) {
|
|
7286
7545
|
const hook = framework ? frameworkHooks[framework] : void 0;
|
|
7287
7546
|
return hook?.(ctx);
|
|
@@ -7295,7 +7554,7 @@ var frameworkHooks = {
|
|
|
7295
7554
|
detected
|
|
7296
7555
|
}) => {
|
|
7297
7556
|
if (detected?.baseDir === void 0) {
|
|
7298
|
-
(0,
|
|
7557
|
+
(0, import_build_utils18.debug)("Django hook: no manage.py detected, skipping");
|
|
7299
7558
|
return;
|
|
7300
7559
|
}
|
|
7301
7560
|
let settingsResult;
|
|
@@ -7309,13 +7568,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
7309
7568
|
} else {
|
|
7310
7569
|
detail = err?.stderr || err?.message || String(err);
|
|
7311
7570
|
}
|
|
7312
|
-
throw new
|
|
7571
|
+
throw new import_build_utils18.NowBuildError({
|
|
7313
7572
|
code: "DJANGO_SETTINGS_FAILED",
|
|
7314
7573
|
message: `Failed to read Django application settings from ${projectDir}/manage.py:
|
|
7315
7574
|
${detail}`
|
|
7316
7575
|
});
|
|
7317
7576
|
}
|
|
7318
|
-
(0,
|
|
7577
|
+
(0, import_build_utils18.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
7319
7578
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
7320
7579
|
if (djangoVersion) {
|
|
7321
7580
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -7328,7 +7587,7 @@ ${detail}`
|
|
|
7328
7587
|
const variableName = parts.at(-1);
|
|
7329
7588
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7330
7589
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7331
|
-
(0,
|
|
7590
|
+
(0, import_build_utils18.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
7332
7591
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
7333
7592
|
} else {
|
|
7334
7593
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -7337,7 +7596,7 @@ ${detail}`
|
|
|
7337
7596
|
const variableName = parts.at(-1);
|
|
7338
7597
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
7339
7598
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
7340
|
-
(0,
|
|
7599
|
+
(0, import_build_utils18.debug)(
|
|
7341
7600
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
7342
7601
|
);
|
|
7343
7602
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -7345,7 +7604,7 @@ ${detail}`
|
|
|
7345
7604
|
}
|
|
7346
7605
|
let djangoStatic = null;
|
|
7347
7606
|
if (workPath && venvPath) {
|
|
7348
|
-
const outputStaticDir = (0,
|
|
7607
|
+
const outputStaticDir = (0, import_path14.join)(workPath, ".vercel", "output", "static");
|
|
7349
7608
|
djangoStatic = await runDjangoCollectStatic(
|
|
7350
7609
|
venvPath,
|
|
7351
7610
|
workPath,
|
|
@@ -7365,23 +7624,23 @@ async function downloadFilesInWorkPath({
|
|
|
7365
7624
|
files,
|
|
7366
7625
|
meta = {}
|
|
7367
7626
|
}) {
|
|
7368
|
-
(0,
|
|
7369
|
-
let downloadedFiles = await (0,
|
|
7627
|
+
(0, import_build_utils18.debug)("Downloading user files...");
|
|
7628
|
+
let downloadedFiles = await (0, import_build_utils18.download)(files, workPath, meta);
|
|
7370
7629
|
if (meta.isDev && entrypoint) {
|
|
7371
7630
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
7372
7631
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
7373
|
-
throw new
|
|
7632
|
+
throw new import_build_utils18.NowBuildError({
|
|
7374
7633
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7375
7634
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
7376
7635
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
7377
7636
|
action: "Learn More"
|
|
7378
7637
|
});
|
|
7379
7638
|
}
|
|
7380
|
-
const { devCacheDir = (0,
|
|
7381
|
-
const cacheKey = (0,
|
|
7382
|
-
const destCache = (0,
|
|
7383
|
-
await (0,
|
|
7384
|
-
downloadedFiles = await (0,
|
|
7639
|
+
const { devCacheDir = (0, import_path14.join)(workPath, ".now", "cache") } = meta;
|
|
7640
|
+
const cacheKey = (0, import_path14.basename)(entrypoint).replace(/\./g, "_");
|
|
7641
|
+
const destCache = (0, import_path14.join)(devCacheDir, cacheKey);
|
|
7642
|
+
await (0, import_build_utils18.download)(downloadedFiles, destCache);
|
|
7643
|
+
downloadedFiles = await (0, import_build_utils18.glob)("**", destCache);
|
|
7385
7644
|
workPath = destCache;
|
|
7386
7645
|
}
|
|
7387
7646
|
return workPath;
|
|
@@ -7417,14 +7676,14 @@ var build = async ({
|
|
|
7417
7676
|
registerPreDeploy
|
|
7418
7677
|
}) => {
|
|
7419
7678
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
7420
|
-
const builderSpan = parentSpan ?? new
|
|
7679
|
+
const builderSpan = parentSpan ?? new import_build_utils18.Span({ name: "vc.builder" });
|
|
7421
7680
|
const framework = config?.framework;
|
|
7422
7681
|
const shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
7423
7682
|
let spawnEnv;
|
|
7424
7683
|
let projectInstallCommand;
|
|
7425
7684
|
let hasCustomCommand = false;
|
|
7426
7685
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
7427
|
-
(0,
|
|
7686
|
+
(0, import_build_utils18.debug)(`workPath: ${workPath}`);
|
|
7428
7687
|
workPath = await downloadFilesInWorkPath({
|
|
7429
7688
|
workPath,
|
|
7430
7689
|
files: originalFiles,
|
|
@@ -7433,7 +7692,7 @@ var build = async ({
|
|
|
7433
7692
|
});
|
|
7434
7693
|
try {
|
|
7435
7694
|
if (meta.isDev) {
|
|
7436
|
-
const setupCfg = (0,
|
|
7695
|
+
const setupCfg = (0, import_path14.join)(workPath, "setup.cfg");
|
|
7437
7696
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
7438
7697
|
}
|
|
7439
7698
|
} catch (err) {
|
|
@@ -7449,15 +7708,15 @@ var build = async ({
|
|
|
7449
7708
|
filePath: entrypoint,
|
|
7450
7709
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
7451
7710
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
7452
|
-
varName: service && (0,
|
|
7711
|
+
varName: service && (0, import_build_utils18.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
7453
7712
|
} : void 0,
|
|
7454
7713
|
service
|
|
7455
7714
|
) ?? void 0;
|
|
7456
7715
|
if (detected?.error && detected?.baseDir === void 0) {
|
|
7457
7716
|
throw detected?.error;
|
|
7458
7717
|
}
|
|
7459
|
-
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0,
|
|
7460
|
-
const entrypointAbsDir = (0,
|
|
7718
|
+
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path14.dirname)(entrypoint) : ".");
|
|
7719
|
+
const entrypointAbsDir = (0, import_path14.join)(workPath, entryDirectory);
|
|
7461
7720
|
const rootDir = repoRootPath ?? workPath;
|
|
7462
7721
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
7463
7722
|
() => discoverPackage({
|
|
@@ -7500,12 +7759,12 @@ var build = async ({
|
|
|
7500
7759
|
`uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
|
|
7501
7760
|
);
|
|
7502
7761
|
}
|
|
7503
|
-
const venvPath = service?.name ? (0,
|
|
7504
|
-
const hasCachedVenv =
|
|
7505
|
-
const hasCachedUv =
|
|
7762
|
+
const venvPath = service?.name ? (0, import_path14.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path14.join)(workPath, ".vercel", "python", ".venv");
|
|
7763
|
+
const hasCachedVenv = import_fs14.default.existsSync((0, import_path14.join)(venvPath, "pyvenv.cfg"));
|
|
7764
|
+
const hasCachedUv = import_fs14.default.existsSync(uvCacheDir);
|
|
7506
7765
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
7507
7766
|
if (hasCachedVenv || hasCachedUv) {
|
|
7508
|
-
(0,
|
|
7767
|
+
(0, import_build_utils18.debug)(
|
|
7509
7768
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
7510
7769
|
);
|
|
7511
7770
|
}
|
|
@@ -7517,14 +7776,14 @@ var build = async ({
|
|
|
7517
7776
|
uvCacheDir
|
|
7518
7777
|
});
|
|
7519
7778
|
});
|
|
7520
|
-
if ((0,
|
|
7779
|
+
if ((0, import_build_utils18.isPythonFramework)(framework)) {
|
|
7521
7780
|
const {
|
|
7522
7781
|
cliType,
|
|
7523
7782
|
lockfileVersion,
|
|
7524
7783
|
packageJsonPackageManager,
|
|
7525
7784
|
turboSupportsCorepackHome
|
|
7526
|
-
} = await (0,
|
|
7527
|
-
spawnEnv = (0,
|
|
7785
|
+
} = await (0, import_build_utils18.scanParentDirs)(workPath, true);
|
|
7786
|
+
spawnEnv = (0, import_build_utils18.getEnvForPackageManager)({
|
|
7528
7787
|
cliType,
|
|
7529
7788
|
lockfileVersion,
|
|
7530
7789
|
packageJsonPackageManager,
|
|
@@ -7549,13 +7808,13 @@ var build = async ({
|
|
|
7549
7808
|
let uvLockPath = null;
|
|
7550
7809
|
let uvProjectDir = null;
|
|
7551
7810
|
let projectName;
|
|
7552
|
-
await builderSpan.child(
|
|
7811
|
+
await builderSpan.child(import_build_utils18.BUILDER_INSTALLER_STEP, {
|
|
7553
7812
|
installCommand: projectInstallCommand || void 0,
|
|
7554
7813
|
runtime: "python",
|
|
7555
7814
|
"python.cache.restored": restoredCache
|
|
7556
7815
|
}).trace(async () => {
|
|
7557
7816
|
if (projectInstallCommand) {
|
|
7558
|
-
await
|
|
7817
|
+
await import_fs14.default.promises.rm(venvPath, { recursive: true, force: true });
|
|
7559
7818
|
await ensureVenv({
|
|
7560
7819
|
pythonVersion,
|
|
7561
7820
|
venvPath,
|
|
@@ -7566,7 +7825,7 @@ var build = async ({
|
|
|
7566
7825
|
console.log(
|
|
7567
7826
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
7568
7827
|
);
|
|
7569
|
-
await (0,
|
|
7828
|
+
await (0, import_build_utils18.execCommand)(projectInstallCommand, {
|
|
7570
7829
|
env: pythonEnv,
|
|
7571
7830
|
cwd: workPath
|
|
7572
7831
|
});
|
|
@@ -7587,7 +7846,7 @@ var build = async ({
|
|
|
7587
7846
|
}
|
|
7588
7847
|
if (!assumeDepsInstalled) {
|
|
7589
7848
|
const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
|
|
7590
|
-
const cachedLockPath = (0,
|
|
7849
|
+
const cachedLockPath = (0, import_path14.join)(uvCacheDir, lockCacheKey);
|
|
7591
7850
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
7592
7851
|
workPath,
|
|
7593
7852
|
rootDir,
|
|
@@ -7608,21 +7867,21 @@ var build = async ({
|
|
|
7608
7867
|
locked: !lockFileProvidedByUser,
|
|
7609
7868
|
pythonPlatform: target.uvPlatform
|
|
7610
7869
|
});
|
|
7611
|
-
if (lockPath &&
|
|
7612
|
-
await
|
|
7613
|
-
await
|
|
7870
|
+
if (lockPath && import_fs14.default.existsSync(lockPath)) {
|
|
7871
|
+
await import_fs14.default.promises.mkdir(uvCacheDir, { recursive: true });
|
|
7872
|
+
await import_fs14.default.promises.copyFile(lockPath, cachedLockPath);
|
|
7614
7873
|
}
|
|
7615
7874
|
}
|
|
7616
7875
|
});
|
|
7617
|
-
if ((0,
|
|
7876
|
+
if ((0, import_build_utils18.isPythonFramework)(framework)) {
|
|
7618
7877
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
7619
7878
|
config?.buildCommand;
|
|
7620
|
-
await builderSpan.child(
|
|
7879
|
+
await builderSpan.child(import_build_utils18.BUILDER_COMPILE_STEP, {
|
|
7621
7880
|
buildCommand: projectBuildCommand || void 0
|
|
7622
7881
|
}).trace(async () => {
|
|
7623
7882
|
if (projectBuildCommand) {
|
|
7624
7883
|
console.log(`Running "${projectBuildCommand}"`);
|
|
7625
|
-
await (0,
|
|
7884
|
+
await (0, import_build_utils18.execCommand)(projectBuildCommand, {
|
|
7626
7885
|
env: pythonEnv,
|
|
7627
7886
|
cwd: workPath
|
|
7628
7887
|
});
|
|
@@ -7637,7 +7896,7 @@ var build = async ({
|
|
|
7637
7896
|
}
|
|
7638
7897
|
const hookResult = await runFrameworkHook(framework, {
|
|
7639
7898
|
pythonEnv,
|
|
7640
|
-
projectDir: (0,
|
|
7899
|
+
projectDir: (0, import_path14.join)(workPath, entryDirectory),
|
|
7641
7900
|
workPath,
|
|
7642
7901
|
venvPath,
|
|
7643
7902
|
entrypoint,
|
|
@@ -7649,26 +7908,26 @@ var build = async ({
|
|
|
7649
7908
|
}
|
|
7650
7909
|
entrypoint = resolved?.entrypoint;
|
|
7651
7910
|
if (!entrypoint) {
|
|
7652
|
-
throw new
|
|
7911
|
+
throw new import_build_utils18.NowBuildError({
|
|
7653
7912
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
7654
7913
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
7655
7914
|
});
|
|
7656
7915
|
}
|
|
7657
7916
|
const djangoStatic = hookResult?.djangoStatic ?? null;
|
|
7658
7917
|
const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
|
|
7659
|
-
(0,
|
|
7918
|
+
(0, import_build_utils18.debug)(`Installing ${runtimeDep}`);
|
|
7660
7919
|
const pipPlatformArgs = target.uvPlatform ? ["--python-platform", target.uvPlatform] : [];
|
|
7661
7920
|
await uv.pip({
|
|
7662
7921
|
venvPath,
|
|
7663
|
-
projectDir: (0,
|
|
7922
|
+
projectDir: (0, import_path14.join)(workPath, entryDirectory),
|
|
7664
7923
|
args: ["install", "--link-mode", "copy", ...pipPlatformArgs, runtimeDep]
|
|
7665
7924
|
});
|
|
7666
7925
|
if (shouldInstallVercelWorkers) {
|
|
7667
7926
|
const workersDep = baseEnv.VERCEL_WORKERS_PYTHON || `vercel-workers==${VERCEL_WORKERS_VERSION}`;
|
|
7668
|
-
(0,
|
|
7927
|
+
(0, import_build_utils18.debug)(`Installing ${workersDep}`);
|
|
7669
7928
|
await uv.pip({
|
|
7670
7929
|
venvPath,
|
|
7671
|
-
projectDir: (0,
|
|
7930
|
+
projectDir: (0, import_path14.join)(workPath, entryDirectory),
|
|
7672
7931
|
args: ["install", "--link-mode", "copy", ...pipPlatformArgs, workersDep]
|
|
7673
7932
|
});
|
|
7674
7933
|
}
|
|
@@ -7681,25 +7940,25 @@ var build = async ({
|
|
|
7681
7940
|
const capturedEnv = { ...pythonEnv };
|
|
7682
7941
|
const capturedCwd = workPath;
|
|
7683
7942
|
registerPreDeploy(async () => {
|
|
7684
|
-
await builderSpan.child(
|
|
7943
|
+
await builderSpan.child(import_build_utils18.BUILDER_PRE_DEPLOY_STEP, {
|
|
7685
7944
|
preDeployCommand
|
|
7686
7945
|
}).trace(async () => {
|
|
7687
7946
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
7688
|
-
await (0,
|
|
7947
|
+
await (0, import_build_utils18.execCommand)(preDeployCommand, {
|
|
7689
7948
|
env: capturedEnv,
|
|
7690
7949
|
cwd: capturedCwd
|
|
7691
7950
|
});
|
|
7692
7951
|
});
|
|
7693
7952
|
});
|
|
7694
7953
|
}
|
|
7695
|
-
(0,
|
|
7954
|
+
(0, import_build_utils18.debug)("Entrypoint is", entrypoint);
|
|
7696
7955
|
const moduleName = entrypointToModule(entrypoint);
|
|
7697
7956
|
if (handlerFunction) {
|
|
7698
|
-
const entrypointPath = (0,
|
|
7699
|
-
const source = await
|
|
7957
|
+
const entrypointPath = (0, import_path14.join)(workPath, entrypoint);
|
|
7958
|
+
const source = await import_fs14.default.promises.readFile(entrypointPath, "utf-8");
|
|
7700
7959
|
const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
|
|
7701
7960
|
if (!found) {
|
|
7702
|
-
throw new
|
|
7961
|
+
throw new import_build_utils18.NowBuildError({
|
|
7703
7962
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
7704
7963
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
7705
7964
|
});
|
|
@@ -7708,7 +7967,7 @@ var build = async ({
|
|
|
7708
7967
|
const vendorDir = resolveVendorDir();
|
|
7709
7968
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
7710
7969
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
7711
|
-
(0,
|
|
7970
|
+
(0, import_build_utils18.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
7712
7971
|
const crons = await getServiceCrons({
|
|
7713
7972
|
service,
|
|
7714
7973
|
entrypoint,
|
|
@@ -7765,6 +8024,10 @@ if os.path.isdir(_vendor):
|
|
|
7765
8024
|
|
|
7766
8025
|
from vercel_runtime.vc_init import vc_handler
|
|
7767
8026
|
`;
|
|
8027
|
+
const automaticCompileAllEnabled = shouldUseCompileAll({
|
|
8028
|
+
isDev: meta.isDev,
|
|
8029
|
+
hasCustomCommand
|
|
8030
|
+
});
|
|
7768
8031
|
const predefinedExcludes = [
|
|
7769
8032
|
".git/**",
|
|
7770
8033
|
".gitignore",
|
|
@@ -7794,12 +8057,18 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7794
8057
|
cwd: workPath,
|
|
7795
8058
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
7796
8059
|
};
|
|
7797
|
-
const files = await (0,
|
|
8060
|
+
const files = await (0, import_build_utils18.glob)("**", globOptions);
|
|
7798
8061
|
if (djangoStatic?.manifestRelPath) {
|
|
7799
|
-
files[djangoStatic.manifestRelPath] = new
|
|
7800
|
-
fsPath: (0,
|
|
8062
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils18.FileFsRef({
|
|
8063
|
+
fsPath: (0, import_path14.join)(workPath, djangoStatic.manifestRelPath)
|
|
7801
8064
|
});
|
|
7802
8065
|
}
|
|
8066
|
+
const handlerPyFilename = "vc__handler__python";
|
|
8067
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils18.FileBlob({ data: runtimeTrampoline });
|
|
8068
|
+
if (config.framework === "fasthtml") {
|
|
8069
|
+
const { SESSKEY = "" } = process.env;
|
|
8070
|
+
files[".sesskey"] = new import_build_utils18.FileBlob({ data: `"${SESSKEY}"` });
|
|
8071
|
+
}
|
|
7803
8072
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
7804
8073
|
venvPath,
|
|
7805
8074
|
vendorDir,
|
|
@@ -7827,18 +8096,64 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7827
8096
|
if (depAnalysis.runtimeInstallEnabled) {
|
|
7828
8097
|
await depExternalizer.generateBundle(files);
|
|
7829
8098
|
} else {
|
|
7830
|
-
|
|
7831
|
-
|
|
8099
|
+
addFiles(files, depAnalysis.allVendorFiles);
|
|
8100
|
+
if (automaticCompileAllEnabled) {
|
|
8101
|
+
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
8102
|
+
const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs14.default.existsSync(d));
|
|
8103
|
+
const pythonBin = getVenvPythonBin(venvPath);
|
|
8104
|
+
console.log("Compiling Python application bytecode...");
|
|
8105
|
+
await runCompileAll({
|
|
8106
|
+
pythonBin,
|
|
8107
|
+
filesOrDirectories: [workPath],
|
|
8108
|
+
env: pythonEnv,
|
|
8109
|
+
excludeRegex: getCompileAllAppExcludeRegex(workPath)
|
|
8110
|
+
});
|
|
8111
|
+
console.log("Compiling Python dependency bytecode...");
|
|
8112
|
+
await runCompileAll({
|
|
8113
|
+
pythonBin,
|
|
8114
|
+
filesOrDirectories: sitePackageDirs,
|
|
8115
|
+
env: pythonEnv
|
|
8116
|
+
});
|
|
8117
|
+
compileSpan.setAttributes({
|
|
8118
|
+
"python.compileall.enabled": "true",
|
|
8119
|
+
"python.compileall.sitePackageDirectoryCount": String(
|
|
8120
|
+
sitePackageDirs.length
|
|
8121
|
+
)
|
|
8122
|
+
});
|
|
8123
|
+
});
|
|
8124
|
+
const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
|
|
8125
|
+
const activeThreshold = pythonOnHiveEnabled ? HIVE_LAMBDA_SIZE_BYTES : LAMBDA_SIZE_THRESHOLD_BYTES;
|
|
8126
|
+
const currentSize = await calculateBundleSize(files);
|
|
8127
|
+
let remainingCapacity = activeThreshold - currentSize;
|
|
8128
|
+
if (pythonVersion.major != null && pythonVersion.minor != null) {
|
|
8129
|
+
const appBytecodeInfo = await collectAppBytecodeFiles({
|
|
8130
|
+
workPath,
|
|
8131
|
+
files,
|
|
8132
|
+
pythonMajor: pythonVersion.major,
|
|
8133
|
+
pythonMinor: pythonVersion.minor
|
|
8134
|
+
});
|
|
8135
|
+
remainingCapacity = addBytecodeWithinCapacity(
|
|
8136
|
+
files,
|
|
8137
|
+
appBytecodeInfo,
|
|
8138
|
+
remainingCapacity
|
|
8139
|
+
);
|
|
8140
|
+
}
|
|
8141
|
+
const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles(
|
|
8142
|
+
{
|
|
8143
|
+
vendorDirName: vendorDir
|
|
8144
|
+
}
|
|
8145
|
+
);
|
|
8146
|
+
await addVendorBytecodeWithinCapacity({
|
|
8147
|
+
files,
|
|
8148
|
+
depExternalizer,
|
|
8149
|
+
vendorDir,
|
|
8150
|
+
bytecodeInfo: vendorBytecodeInfo,
|
|
8151
|
+
capacity: remainingCapacity
|
|
8152
|
+
});
|
|
7832
8153
|
}
|
|
7833
8154
|
}
|
|
7834
8155
|
});
|
|
7835
|
-
const
|
|
7836
|
-
files[`${handlerPyFilename}.py`] = new import_build_utils17.FileBlob({ data: runtimeTrampoline });
|
|
7837
|
-
if (config.framework === "fasthtml") {
|
|
7838
|
-
const { SESSKEY = "" } = process.env;
|
|
7839
|
-
files[".sesskey"] = new import_build_utils17.FileBlob({ data: `"${SESSKEY}"` });
|
|
7840
|
-
}
|
|
7841
|
-
const output = new import_build_utils17.Lambda({
|
|
8156
|
+
const output = new import_build_utils18.Lambda({
|
|
7842
8157
|
files,
|
|
7843
8158
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
7844
8159
|
runtime: pythonVersion.runtime,
|
|
@@ -7854,19 +8169,19 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
7854
8169
|
pythonVersion,
|
|
7855
8170
|
uvLockPath,
|
|
7856
8171
|
framework,
|
|
7857
|
-
serviceType: service ? (0,
|
|
8172
|
+
serviceType: service ? (0, import_build_utils18.getReportedServiceType)(service) : void 0
|
|
7858
8173
|
});
|
|
7859
8174
|
} catch (err) {
|
|
7860
|
-
(0,
|
|
8175
|
+
(0, import_build_utils18.debug)(
|
|
7861
8176
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
7862
8177
|
);
|
|
7863
8178
|
}
|
|
7864
8179
|
}
|
|
7865
|
-
if (!(0,
|
|
8180
|
+
if (!(0, import_build_utils18.isPythonFramework)(framework) && !service?.name) {
|
|
7866
8181
|
return { resultVersion: 3, result: { output } };
|
|
7867
8182
|
}
|
|
7868
8183
|
const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
|
|
7869
|
-
const staticFiles = djangoStatic?.cdnOutputDir ? await (0,
|
|
8184
|
+
const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils18.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
|
|
7870
8185
|
const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
|
|
7871
8186
|
return {
|
|
7872
8187
|
resultVersion: 2,
|
|
@@ -7895,14 +8210,14 @@ var prepareCache = async ({
|
|
|
7895
8210
|
}
|
|
7896
8211
|
} catch {
|
|
7897
8212
|
}
|
|
7898
|
-
return (0,
|
|
8213
|
+
return (0, import_build_utils18.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
7899
8214
|
cwd: root,
|
|
7900
8215
|
ignore
|
|
7901
8216
|
});
|
|
7902
8217
|
};
|
|
7903
8218
|
var shouldServe = (opts) => {
|
|
7904
8219
|
const framework = opts.config.framework;
|
|
7905
|
-
if ((0,
|
|
8220
|
+
if ((0, import_build_utils18.isPythonFramework)(framework)) {
|
|
7906
8221
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
7907
8222
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
7908
8223
|
return false;
|
|
@@ -7921,7 +8236,7 @@ var defaultShouldServe = ({
|
|
|
7921
8236
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
7922
8237
|
return true;
|
|
7923
8238
|
}
|
|
7924
|
-
const { dir, name } = (0,
|
|
8239
|
+
const { dir, name } = (0, import_path14.parse)(entrypoint);
|
|
7925
8240
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
7926
8241
|
return true;
|
|
7927
8242
|
}
|