@vercel/python 6.54.1 → 6.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +597 -395
- package/package.json +6 -6
- package/templates/vc_compileall.py +21 -3
package/dist/index.js
CHANGED
|
@@ -137,12 +137,12 @@ var require_isexe = __commonJS({
|
|
|
137
137
|
if (typeof Promise !== "function") {
|
|
138
138
|
throw new TypeError("callback not provided");
|
|
139
139
|
}
|
|
140
|
-
return new Promise(function(
|
|
140
|
+
return new Promise(function(resolve4, reject) {
|
|
141
141
|
isexe(path, options || {}, function(er, is) {
|
|
142
142
|
if (er) {
|
|
143
143
|
reject(er);
|
|
144
144
|
} else {
|
|
145
|
-
|
|
145
|
+
resolve4(is);
|
|
146
146
|
}
|
|
147
147
|
});
|
|
148
148
|
});
|
|
@@ -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 debug18;
|
|
427
427
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
428
|
-
|
|
428
|
+
debug18 = 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
|
+
debug18 = 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
|
+
debug18(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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("hyphen replace", range);
|
|
1054
1054
|
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
|
|
1055
|
-
|
|
1055
|
+
debug18("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
|
+
debug18("comp", comp, options);
|
|
1096
1096
|
comp = replaceCarets(comp, options);
|
|
1097
|
-
|
|
1097
|
+
debug18("caret", comp);
|
|
1098
1098
|
comp = replaceTildes(comp, options);
|
|
1099
|
-
|
|
1099
|
+
debug18("tildes", comp);
|
|
1100
1100
|
comp = replaceXRanges(comp, options);
|
|
1101
|
-
|
|
1101
|
+
debug18("xrange", comp);
|
|
1102
1102
|
comp = replaceStars(comp, options);
|
|
1103
|
-
|
|
1103
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("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
|
+
debug18("caret return", ret);
|
|
1180
1180
|
return ret;
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
function replaceXRanges(comp, options) {
|
|
1184
|
-
|
|
1184
|
+
debug18("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
|
+
debug18("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
|
+
debug18("xRange return", ret);
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
function replaceStars(comp, options) {
|
|
1241
|
-
|
|
1241
|
+
debug18("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
|
+
debug18(set[i2].semver);
|
|
1290
1290
|
if (set[i2].semver === ANY) {
|
|
1291
1291
|
continue;
|
|
1292
1292
|
}
|
|
@@ -2042,7 +2042,7 @@ var require_get_stream = __commonJS({
|
|
|
2042
2042
|
options = Object.assign({ maxBuffer: Infinity }, options);
|
|
2043
2043
|
const { maxBuffer } = options;
|
|
2044
2044
|
let stream;
|
|
2045
|
-
return new Promise((
|
|
2045
|
+
return new Promise((resolve4, reject) => {
|
|
2046
2046
|
const rejectPromise = (error) => {
|
|
2047
2047
|
if (error) {
|
|
2048
2048
|
error.bufferedData = stream.getBufferedValue();
|
|
@@ -2054,7 +2054,7 @@ var require_get_stream = __commonJS({
|
|
|
2054
2054
|
rejectPromise(error);
|
|
2055
2055
|
return;
|
|
2056
2056
|
}
|
|
2057
|
-
|
|
2057
|
+
resolve4();
|
|
2058
2058
|
});
|
|
2059
2059
|
stream.on("data", () => {
|
|
2060
2060
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
@@ -2078,11 +2078,11 @@ var require_p_finally = __commonJS({
|
|
|
2078
2078
|
onFinally = onFinally || (() => {
|
|
2079
2079
|
});
|
|
2080
2080
|
return promise.then(
|
|
2081
|
-
(val) => new Promise((
|
|
2082
|
-
|
|
2081
|
+
(val) => new Promise((resolve4) => {
|
|
2082
|
+
resolve4(onFinally());
|
|
2083
2083
|
}).then(() => val),
|
|
2084
|
-
(err) => new Promise((
|
|
2085
|
-
|
|
2084
|
+
(err) => new Promise((resolve4) => {
|
|
2085
|
+
resolve4(onFinally());
|
|
2086
2086
|
}).then(() => {
|
|
2087
2087
|
throw err;
|
|
2088
2088
|
})
|
|
@@ -2461,8 +2461,8 @@ var require_execa = __commonJS({
|
|
|
2461
2461
|
}
|
|
2462
2462
|
let ret;
|
|
2463
2463
|
if (!buffer) {
|
|
2464
|
-
ret = new Promise((
|
|
2465
|
-
process2[stream].once("end",
|
|
2464
|
+
ret = new Promise((resolve4, reject) => {
|
|
2465
|
+
process2[stream].once("end", resolve4).once("error", reject);
|
|
2466
2466
|
});
|
|
2467
2467
|
} else if (encoding) {
|
|
2468
2468
|
ret = _getStream(process2[stream], {
|
|
@@ -2551,19 +2551,19 @@ ${stderr}${stdout}`;
|
|
|
2551
2551
|
spawned.kill(parsed.opts.killSignal);
|
|
2552
2552
|
}, parsed.opts.timeout);
|
|
2553
2553
|
}
|
|
2554
|
-
const processDone = new Promise((
|
|
2554
|
+
const processDone = new Promise((resolve4) => {
|
|
2555
2555
|
spawned.on("exit", (code, signal) => {
|
|
2556
2556
|
cleanup();
|
|
2557
|
-
|
|
2557
|
+
resolve4({ code, signal });
|
|
2558
2558
|
});
|
|
2559
2559
|
spawned.on("error", (err) => {
|
|
2560
2560
|
cleanup();
|
|
2561
|
-
|
|
2561
|
+
resolve4({ error: err });
|
|
2562
2562
|
});
|
|
2563
2563
|
if (spawned.stdin) {
|
|
2564
2564
|
spawned.stdin.on("error", (err) => {
|
|
2565
2565
|
cleanup();
|
|
2566
|
-
|
|
2566
|
+
resolve4({ error: err });
|
|
2567
2567
|
});
|
|
2568
2568
|
}
|
|
2569
2569
|
});
|
|
@@ -3301,9 +3301,9 @@ var require_pep440 = __commonJS({
|
|
|
3301
3301
|
var require_lib = __commonJS({
|
|
3302
3302
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
3303
3303
|
var isexe = require_isexe();
|
|
3304
|
-
var { join:
|
|
3304
|
+
var { join: join21, delimiter: delimiter2, sep: sep4, posix } = require("path");
|
|
3305
3305
|
var isWindows = process.platform === "win32";
|
|
3306
|
-
var rSlash = new RegExp(`[${posix.sep}${
|
|
3306
|
+
var rSlash = new RegExp(`[${posix.sep}${sep4 === posix.sep ? "" : sep4}]`.replace(/(\\)/g, "\\$1"));
|
|
3307
3307
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
3308
3308
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
3309
3309
|
var getPathInfo = (cmd, {
|
|
@@ -3330,7 +3330,7 @@ var require_lib = __commonJS({
|
|
|
3330
3330
|
var getPathPart = (raw, cmd) => {
|
|
3331
3331
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
3332
3332
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
3333
|
-
return prefix +
|
|
3333
|
+
return prefix + join21(pathPart, cmd);
|
|
3334
3334
|
};
|
|
3335
3335
|
var which2 = async (cmd, opt = {}) => {
|
|
3336
3336
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -3389,15 +3389,15 @@ var require_lib = __commonJS({
|
|
|
3389
3389
|
var require_semver2 = __commonJS({
|
|
3390
3390
|
"../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
|
|
3391
3391
|
exports = module2.exports = SemVer;
|
|
3392
|
-
var
|
|
3392
|
+
var debug18;
|
|
3393
3393
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
3394
|
-
|
|
3394
|
+
debug18 = function() {
|
|
3395
3395
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
3396
3396
|
args.unshift("SEMVER");
|
|
3397
3397
|
console.log.apply(console, args);
|
|
3398
3398
|
};
|
|
3399
3399
|
} else {
|
|
3400
|
-
|
|
3400
|
+
debug18 = function() {
|
|
3401
3401
|
};
|
|
3402
3402
|
}
|
|
3403
3403
|
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
@@ -3515,7 +3515,7 @@ var require_semver2 = __commonJS({
|
|
|
3515
3515
|
tok("STAR");
|
|
3516
3516
|
src[t.STAR] = "(<|>)?=?\\s*\\*";
|
|
3517
3517
|
for (i = 0; i < R; i++) {
|
|
3518
|
-
|
|
3518
|
+
debug18(i, src[i]);
|
|
3519
3519
|
if (!re[i]) {
|
|
3520
3520
|
re[i] = new RegExp(src[i]);
|
|
3521
3521
|
safeRe[i] = new RegExp(makeSafeRe(src[i]));
|
|
@@ -3582,7 +3582,7 @@ var require_semver2 = __commonJS({
|
|
|
3582
3582
|
if (!(this instanceof SemVer)) {
|
|
3583
3583
|
return new SemVer(version2, options);
|
|
3584
3584
|
}
|
|
3585
|
-
|
|
3585
|
+
debug18("SemVer", version2, options);
|
|
3586
3586
|
this.options = options;
|
|
3587
3587
|
this.loose = !!options.loose;
|
|
3588
3588
|
var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
|
|
@@ -3629,7 +3629,7 @@ var require_semver2 = __commonJS({
|
|
|
3629
3629
|
return this.version;
|
|
3630
3630
|
};
|
|
3631
3631
|
SemVer.prototype.compare = function(other) {
|
|
3632
|
-
|
|
3632
|
+
debug18("SemVer.compare", this.version, this.options, other);
|
|
3633
3633
|
if (!(other instanceof SemVer)) {
|
|
3634
3634
|
other = new SemVer(other, this.options);
|
|
3635
3635
|
}
|
|
@@ -3656,7 +3656,7 @@ var require_semver2 = __commonJS({
|
|
|
3656
3656
|
do {
|
|
3657
3657
|
var a = this.prerelease[i2];
|
|
3658
3658
|
var b = other.prerelease[i2];
|
|
3659
|
-
|
|
3659
|
+
debug18("prerelease compare", i2, a, b);
|
|
3660
3660
|
if (a === void 0 && b === void 0) {
|
|
3661
3661
|
return 0;
|
|
3662
3662
|
} else if (b === void 0) {
|
|
@@ -3678,7 +3678,7 @@ var require_semver2 = __commonJS({
|
|
|
3678
3678
|
do {
|
|
3679
3679
|
var a = this.build[i2];
|
|
3680
3680
|
var b = other.build[i2];
|
|
3681
|
-
|
|
3681
|
+
debug18("prerelease compare", i2, a, b);
|
|
3682
3682
|
if (a === void 0 && b === void 0) {
|
|
3683
3683
|
return 0;
|
|
3684
3684
|
} else if (b === void 0) {
|
|
@@ -3938,7 +3938,7 @@ var require_semver2 = __commonJS({
|
|
|
3938
3938
|
return new Comparator(comp, options);
|
|
3939
3939
|
}
|
|
3940
3940
|
comp = comp.trim().split(/\s+/).join(" ");
|
|
3941
|
-
|
|
3941
|
+
debug18("comparator", comp, options);
|
|
3942
3942
|
this.options = options;
|
|
3943
3943
|
this.loose = !!options.loose;
|
|
3944
3944
|
this.parse(comp);
|
|
@@ -3947,7 +3947,7 @@ var require_semver2 = __commonJS({
|
|
|
3947
3947
|
} else {
|
|
3948
3948
|
this.value = this.operator + this.semver.version;
|
|
3949
3949
|
}
|
|
3950
|
-
|
|
3950
|
+
debug18("comp", this);
|
|
3951
3951
|
}
|
|
3952
3952
|
var ANY = {};
|
|
3953
3953
|
Comparator.prototype.parse = function(comp) {
|
|
@@ -3970,7 +3970,7 @@ var require_semver2 = __commonJS({
|
|
|
3970
3970
|
return this.value;
|
|
3971
3971
|
};
|
|
3972
3972
|
Comparator.prototype.test = function(version2) {
|
|
3973
|
-
|
|
3973
|
+
debug18("Comparator.test", version2, this.options.loose);
|
|
3974
3974
|
if (this.semver === ANY || version2 === ANY) {
|
|
3975
3975
|
return true;
|
|
3976
3976
|
}
|
|
@@ -4063,9 +4063,9 @@ var require_semver2 = __commonJS({
|
|
|
4063
4063
|
var loose = this.options.loose;
|
|
4064
4064
|
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
|
|
4065
4065
|
range = range.replace(hr, hyphenReplace);
|
|
4066
|
-
|
|
4066
|
+
debug18("hyphen replace", range);
|
|
4067
4067
|
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
4068
|
-
|
|
4068
|
+
debug18("comparator trim", range, safeRe[t.COMPARATORTRIM]);
|
|
4069
4069
|
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
|
|
4070
4070
|
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
|
|
4071
4071
|
range = range.split(/\s+/).join(" ");
|
|
@@ -4118,15 +4118,15 @@ var require_semver2 = __commonJS({
|
|
|
4118
4118
|
});
|
|
4119
4119
|
}
|
|
4120
4120
|
function parseComparator(comp, options) {
|
|
4121
|
-
|
|
4121
|
+
debug18("comp", comp, options);
|
|
4122
4122
|
comp = replaceCarets(comp, options);
|
|
4123
|
-
|
|
4123
|
+
debug18("caret", comp);
|
|
4124
4124
|
comp = replaceTildes(comp, options);
|
|
4125
|
-
|
|
4125
|
+
debug18("tildes", comp);
|
|
4126
4126
|
comp = replaceXRanges(comp, options);
|
|
4127
|
-
|
|
4127
|
+
debug18("xrange", comp);
|
|
4128
4128
|
comp = replaceStars(comp, options);
|
|
4129
|
-
|
|
4129
|
+
debug18("stars", comp);
|
|
4130
4130
|
return comp;
|
|
4131
4131
|
}
|
|
4132
4132
|
function isX(id) {
|
|
@@ -4140,7 +4140,7 @@ var require_semver2 = __commonJS({
|
|
|
4140
4140
|
function replaceTilde(comp, options) {
|
|
4141
4141
|
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
|
|
4142
4142
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
4143
|
-
|
|
4143
|
+
debug18("tilde", comp, _, M, m, p, pr);
|
|
4144
4144
|
var ret;
|
|
4145
4145
|
if (isX(M)) {
|
|
4146
4146
|
ret = "";
|
|
@@ -4149,12 +4149,12 @@ var require_semver2 = __commonJS({
|
|
|
4149
4149
|
} else if (isX(p)) {
|
|
4150
4150
|
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
4151
4151
|
} else if (pr) {
|
|
4152
|
-
|
|
4152
|
+
debug18("replaceTilde pr", pr);
|
|
4153
4153
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
|
|
4154
4154
|
} else {
|
|
4155
4155
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
4156
4156
|
}
|
|
4157
|
-
|
|
4157
|
+
debug18("tilde return", ret);
|
|
4158
4158
|
return ret;
|
|
4159
4159
|
});
|
|
4160
4160
|
}
|
|
@@ -4164,10 +4164,10 @@ var require_semver2 = __commonJS({
|
|
|
4164
4164
|
}).join(" ");
|
|
4165
4165
|
}
|
|
4166
4166
|
function replaceCaret(comp, options) {
|
|
4167
|
-
|
|
4167
|
+
debug18("caret", comp, options);
|
|
4168
4168
|
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
|
|
4169
4169
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
4170
|
-
|
|
4170
|
+
debug18("caret", comp, _, M, m, p, pr);
|
|
4171
4171
|
var ret;
|
|
4172
4172
|
if (isX(M)) {
|
|
4173
4173
|
ret = "";
|
|
@@ -4180,7 +4180,7 @@ var require_semver2 = __commonJS({
|
|
|
4180
4180
|
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
|
|
4181
4181
|
}
|
|
4182
4182
|
} else if (pr) {
|
|
4183
|
-
|
|
4183
|
+
debug18("replaceCaret pr", pr);
|
|
4184
4184
|
if (M === "0") {
|
|
4185
4185
|
if (m === "0") {
|
|
4186
4186
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -4191,7 +4191,7 @@ var require_semver2 = __commonJS({
|
|
|
4191
4191
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
|
|
4192
4192
|
}
|
|
4193
4193
|
} else {
|
|
4194
|
-
|
|
4194
|
+
debug18("no pr");
|
|
4195
4195
|
if (M === "0") {
|
|
4196
4196
|
if (m === "0") {
|
|
4197
4197
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -4202,12 +4202,12 @@ var require_semver2 = __commonJS({
|
|
|
4202
4202
|
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
|
|
4203
4203
|
}
|
|
4204
4204
|
}
|
|
4205
|
-
|
|
4205
|
+
debug18("caret return", ret);
|
|
4206
4206
|
return ret;
|
|
4207
4207
|
});
|
|
4208
4208
|
}
|
|
4209
4209
|
function replaceXRanges(comp, options) {
|
|
4210
|
-
|
|
4210
|
+
debug18("replaceXRanges", comp, options);
|
|
4211
4211
|
return comp.split(/\s+/).map(function(comp2) {
|
|
4212
4212
|
return replaceXRange(comp2, options);
|
|
4213
4213
|
}).join(" ");
|
|
@@ -4216,7 +4216,7 @@ var require_semver2 = __commonJS({
|
|
|
4216
4216
|
comp = comp.trim();
|
|
4217
4217
|
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
|
|
4218
4218
|
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
|
|
4219
|
-
|
|
4219
|
+
debug18("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
4220
4220
|
var xM = isX(M);
|
|
4221
4221
|
var xm = xM || isX(m);
|
|
4222
4222
|
var xp = xm || isX(p);
|
|
@@ -4260,12 +4260,12 @@ var require_semver2 = __commonJS({
|
|
|
4260
4260
|
} else if (xp) {
|
|
4261
4261
|
ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
|
|
4262
4262
|
}
|
|
4263
|
-
|
|
4263
|
+
debug18("xRange return", ret);
|
|
4264
4264
|
return ret;
|
|
4265
4265
|
});
|
|
4266
4266
|
}
|
|
4267
4267
|
function replaceStars(comp, options) {
|
|
4268
|
-
|
|
4268
|
+
debug18("replaceStars", comp, options);
|
|
4269
4269
|
return comp.trim().replace(safeRe[t.STAR], "");
|
|
4270
4270
|
}
|
|
4271
4271
|
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
@@ -4317,7 +4317,7 @@ var require_semver2 = __commonJS({
|
|
|
4317
4317
|
}
|
|
4318
4318
|
if (version2.prerelease.length && !options.includePrerelease) {
|
|
4319
4319
|
for (i2 = 0; i2 < set.length; i2++) {
|
|
4320
|
-
|
|
4320
|
+
debug18(set[i2].semver);
|
|
4321
4321
|
if (set[i2].semver === ANY) {
|
|
4322
4322
|
continue;
|
|
4323
4323
|
}
|
|
@@ -4574,14 +4574,14 @@ var require_filesystem = __commonJS({
|
|
|
4574
4574
|
});
|
|
4575
4575
|
return buffer.subarray(0, bytesRead);
|
|
4576
4576
|
};
|
|
4577
|
-
var readFile2 = (path) => new Promise((
|
|
4577
|
+
var readFile2 = (path) => new Promise((resolve4, reject) => {
|
|
4578
4578
|
fs19.open(path, "r", (err, fd) => {
|
|
4579
4579
|
if (err) {
|
|
4580
4580
|
reject(err);
|
|
4581
4581
|
} else {
|
|
4582
4582
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
4583
4583
|
fs19.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
4584
|
-
|
|
4584
|
+
resolve4(buffer.subarray(0, bytesRead));
|
|
4585
4585
|
fs19.close(fd, () => {
|
|
4586
4586
|
});
|
|
4587
4587
|
});
|
|
@@ -4649,10 +4649,10 @@ var require_detect_libc = __commonJS({
|
|
|
4649
4649
|
var commandOut = "";
|
|
4650
4650
|
var safeCommand = () => {
|
|
4651
4651
|
if (!commandOut) {
|
|
4652
|
-
return new Promise((
|
|
4652
|
+
return new Promise((resolve4) => {
|
|
4653
4653
|
childProcess.exec(command, (err, out) => {
|
|
4654
4654
|
commandOut = err ? " " : out;
|
|
4655
|
-
|
|
4655
|
+
resolve4(commandOut);
|
|
4656
4656
|
});
|
|
4657
4657
|
});
|
|
4658
4658
|
}
|
|
@@ -4905,14 +4905,14 @@ var require_get_port = __commonJS({
|
|
|
4905
4905
|
};
|
|
4906
4906
|
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
4907
4907
|
var interval;
|
|
4908
|
-
var getAvailablePort = (options) => new Promise((
|
|
4908
|
+
var getAvailablePort = (options) => new Promise((resolve4, reject) => {
|
|
4909
4909
|
const server = net.createServer();
|
|
4910
4910
|
server.unref();
|
|
4911
4911
|
server.on("error", reject);
|
|
4912
4912
|
server.listen(options, () => {
|
|
4913
4913
|
const { port } = server.address();
|
|
4914
4914
|
server.close(() => {
|
|
4915
|
-
|
|
4915
|
+
resolve4(port);
|
|
4916
4916
|
});
|
|
4917
4917
|
});
|
|
4918
4918
|
});
|
|
@@ -4984,7 +4984,7 @@ var require_is_port_reachable = __commonJS({
|
|
|
4984
4984
|
"use strict";
|
|
4985
4985
|
var net = require("net");
|
|
4986
4986
|
module2.exports = async (port, { timeout = 1e3, host } = {}) => {
|
|
4987
|
-
const promise = new Promise((
|
|
4987
|
+
const promise = new Promise((resolve4, reject) => {
|
|
4988
4988
|
const socket = new net.Socket();
|
|
4989
4989
|
const onError = () => {
|
|
4990
4990
|
socket.destroy();
|
|
@@ -4995,7 +4995,7 @@ var require_is_port_reachable = __commonJS({
|
|
|
4995
4995
|
socket.once("timeout", onError);
|
|
4996
4996
|
socket.connect(port, host, () => {
|
|
4997
4997
|
socket.end();
|
|
4998
|
-
|
|
4998
|
+
resolve4();
|
|
4999
4999
|
});
|
|
5000
5000
|
});
|
|
5001
5001
|
try {
|
|
@@ -5011,8 +5011,6 @@ var require_is_port_reachable = __commonJS({
|
|
|
5011
5011
|
// src/index.ts
|
|
5012
5012
|
var src_exports = {};
|
|
5013
5013
|
__export(src_exports, {
|
|
5014
|
-
addCollectedVendorBytecode: () => addCollectedVendorBytecode,
|
|
5015
|
-
addVendorBytecodeInTiers: () => addVendorBytecodeInTiers,
|
|
5016
5014
|
build: () => build,
|
|
5017
5015
|
defaultShouldServe: () => defaultShouldServe,
|
|
5018
5016
|
detectEntrypoint: () => detectEntrypoint,
|
|
@@ -5021,6 +5019,7 @@ __export(src_exports, {
|
|
|
5021
5019
|
getDevSidecars: () => getDevSidecars,
|
|
5022
5020
|
installRequirement: () => installRequirement,
|
|
5023
5021
|
installRequirementsFile: () => installRequirementsFile,
|
|
5022
|
+
moduleKeysForClosurePaths: () => moduleKeysForClosurePaths,
|
|
5024
5023
|
prepareCache: () => prepareCache,
|
|
5025
5024
|
runFrameworkHook: () => runFrameworkHook,
|
|
5026
5025
|
shouldServe: () => shouldServe,
|
|
@@ -5030,10 +5029,10 @@ __export(src_exports, {
|
|
|
5030
5029
|
module.exports = __toCommonJS(src_exports);
|
|
5031
5030
|
var import_assert = __toESM(require("assert"));
|
|
5032
5031
|
var import_fs20 = __toESM(require("fs"));
|
|
5033
|
-
var
|
|
5032
|
+
var import_path21 = require("path");
|
|
5034
5033
|
|
|
5035
5034
|
// src/package-versions.ts
|
|
5036
|
-
var VERCEL_RUNTIME_VERSION = "0.
|
|
5035
|
+
var VERCEL_RUNTIME_VERSION = "0.18.0";
|
|
5037
5036
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
5038
5037
|
|
|
5039
5038
|
// src/conditional-vendoring.ts
|
|
@@ -5084,12 +5083,6 @@ async function getQueueIntegrations({
|
|
|
5084
5083
|
}
|
|
5085
5084
|
return integrations;
|
|
5086
5085
|
}
|
|
5087
|
-
var INJECTED_PACKAGE_NAMES = /* @__PURE__ */ new Set([
|
|
5088
|
-
"vercel-celery",
|
|
5089
|
-
"vercel-celery-bundle",
|
|
5090
|
-
"vercel-dramatiq",
|
|
5091
|
-
"vercel-dramatiq-bundle"
|
|
5092
|
-
]);
|
|
5093
5086
|
async function getConditionalInjectedPackages({
|
|
5094
5087
|
pythonPackage,
|
|
5095
5088
|
env
|
|
@@ -5101,7 +5094,7 @@ async function getConditionalInjectedPackages({
|
|
|
5101
5094
|
for (const [upstream, adapter] of UPSTREAM_DEPENDENCY_ADAPTERS) {
|
|
5102
5095
|
if (!dependencies.has(upstream))
|
|
5103
5096
|
continue;
|
|
5104
|
-
if (
|
|
5097
|
+
if (dependencies.has(adapter.bundled) || dependencies.has(adapter.unbundled)) {
|
|
5105
5098
|
continue;
|
|
5106
5099
|
}
|
|
5107
5100
|
const name = adapter.preferUnbundledWhenPresent.some(
|
|
@@ -5127,13 +5120,6 @@ async function getDirectDependencyNames(pythonPackage) {
|
|
|
5127
5120
|
);
|
|
5128
5121
|
return dependencyNames;
|
|
5129
5122
|
}
|
|
5130
|
-
function hasDirectInjectedPackage(dependencies) {
|
|
5131
|
-
for (const packageName of INJECTED_PACKAGE_NAMES) {
|
|
5132
|
-
if (dependencies.has(packageName))
|
|
5133
|
-
return true;
|
|
5134
|
-
}
|
|
5135
|
-
return false;
|
|
5136
|
-
}
|
|
5137
5123
|
|
|
5138
5124
|
// src/sdk-detection.ts
|
|
5139
5125
|
var import_fs = __toESM(require("fs"));
|
|
@@ -5266,7 +5252,7 @@ async function queryPythonVercelSdkVersion({
|
|
|
5266
5252
|
}
|
|
5267
5253
|
|
|
5268
5254
|
// src/index.ts
|
|
5269
|
-
var
|
|
5255
|
+
var import_build_utils24 = require("@vercel/build-utils");
|
|
5270
5256
|
|
|
5271
5257
|
// src/install.ts
|
|
5272
5258
|
var import_execa4 = __toESM(require_execa());
|
|
@@ -8211,8 +8197,10 @@ function queueTopicPatternsOverlap(left, right) {
|
|
|
8211
8197
|
}
|
|
8212
8198
|
return left.startsWith(rightPrefix);
|
|
8213
8199
|
}
|
|
8214
|
-
function createIntegrationInstallLines(integrations, { serving }) {
|
|
8215
|
-
return integrations.
|
|
8200
|
+
function createIntegrationInstallLines(integrations, { serving, beforeImport }) {
|
|
8201
|
+
return integrations.filter(
|
|
8202
|
+
(integration) => Boolean(integration.installBeforeImport) === beforeImport
|
|
8203
|
+
).flatMap(({ module: module2, installer, servingActivator }) => [
|
|
8216
8204
|
`from ${module2} import ${installer}`,
|
|
8217
8205
|
`${installer}()`,
|
|
8218
8206
|
// Queue-serving processes must also activate consumption (register
|
|
@@ -8226,8 +8214,15 @@ function createQueueHandlerModule(declaration, integrations) {
|
|
|
8226
8214
|
"import importlib",
|
|
8227
8215
|
"import vercel.queue",
|
|
8228
8216
|
"",
|
|
8217
|
+
...createIntegrationInstallLines(integrations, {
|
|
8218
|
+
serving: true,
|
|
8219
|
+
beforeImport: true
|
|
8220
|
+
}),
|
|
8229
8221
|
`importlib.import_module(${JSON.stringify(declaration.moduleName)})`,
|
|
8230
|
-
...createIntegrationInstallLines(integrations, {
|
|
8222
|
+
...createIntegrationInstallLines(integrations, {
|
|
8223
|
+
serving: true,
|
|
8224
|
+
beforeImport: false
|
|
8225
|
+
}),
|
|
8231
8226
|
"app = vercel.queue.asgi_app()",
|
|
8232
8227
|
""
|
|
8233
8228
|
].join("\n");
|
|
@@ -8359,8 +8354,15 @@ function parseTopicPatterns(name, value) {
|
|
|
8359
8354
|
function createQueueIntrospectionScript(moduleName, integrations) {
|
|
8360
8355
|
return [
|
|
8361
8356
|
"import importlib, json, sys",
|
|
8357
|
+
...createIntegrationInstallLines(integrations, {
|
|
8358
|
+
serving: false,
|
|
8359
|
+
beforeImport: true
|
|
8360
|
+
}),
|
|
8362
8361
|
`importlib.import_module(${JSON.stringify(moduleName)})`,
|
|
8363
|
-
...createIntegrationInstallLines(integrations, {
|
|
8362
|
+
...createIntegrationInstallLines(integrations, {
|
|
8363
|
+
serving: false,
|
|
8364
|
+
beforeImport: false
|
|
8365
|
+
}),
|
|
8364
8366
|
"from vercel.queue import get_subscriptions",
|
|
8365
8367
|
"subs = [",
|
|
8366
8368
|
" {k: v for k, v in {",
|
|
@@ -8572,7 +8574,7 @@ function createLogListener(callback, stream) {
|
|
|
8572
8574
|
};
|
|
8573
8575
|
}
|
|
8574
8576
|
function sleep(ms) {
|
|
8575
|
-
return new Promise((
|
|
8577
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
8576
8578
|
}
|
|
8577
8579
|
async function checkForPort(port, timeout) {
|
|
8578
8580
|
const start = Date.now();
|
|
@@ -8719,7 +8721,7 @@ async function runSync({
|
|
|
8719
8721
|
(0, import_build_utils14.debug)(`Unknown manifest type: ${manifestType}`);
|
|
8720
8722
|
return;
|
|
8721
8723
|
}
|
|
8722
|
-
await new Promise((
|
|
8724
|
+
await new Promise((resolve4, reject) => {
|
|
8723
8725
|
(0, import_build_utils14.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
|
|
8724
8726
|
const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
|
|
8725
8727
|
cwd: projectDir,
|
|
@@ -8743,7 +8745,7 @@ async function runSync({
|
|
|
8743
8745
|
child.on("error", reject);
|
|
8744
8746
|
child.on("exit", (code, signal) => {
|
|
8745
8747
|
if (code === 0) {
|
|
8746
|
-
|
|
8748
|
+
resolve4();
|
|
8747
8749
|
} else {
|
|
8748
8750
|
reject(
|
|
8749
8751
|
new Error(
|
|
@@ -8809,7 +8811,7 @@ async function doInstallInjectedDevPackage(pkg, opts) {
|
|
|
8809
8811
|
...excludeOverride,
|
|
8810
8812
|
dep
|
|
8811
8813
|
];
|
|
8812
|
-
await new Promise((
|
|
8814
|
+
await new Promise((resolve4, reject) => {
|
|
8813
8815
|
const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
|
|
8814
8816
|
cwd: workPath,
|
|
8815
8817
|
env: getProtectedUvEnv(env),
|
|
@@ -8832,7 +8834,7 @@ async function doInstallInjectedDevPackage(pkg, opts) {
|
|
|
8832
8834
|
child.on("error", reject);
|
|
8833
8835
|
child.on("exit", (code, signal) => {
|
|
8834
8836
|
if (code === 0) {
|
|
8835
|
-
|
|
8837
|
+
resolve4();
|
|
8836
8838
|
} else {
|
|
8837
8839
|
reject(
|
|
8838
8840
|
new Error(
|
|
@@ -9040,8 +9042,8 @@ var startDevServer = async (opts) => {
|
|
|
9040
9042
|
let resolveChildReady;
|
|
9041
9043
|
let rejectChildReady;
|
|
9042
9044
|
const childReady = new Promise(
|
|
9043
|
-
(
|
|
9044
|
-
resolveChildReady =
|
|
9045
|
+
(resolve4, reject) => {
|
|
9046
|
+
resolveChildReady = resolve4;
|
|
9045
9047
|
rejectChildReady = reject;
|
|
9046
9048
|
}
|
|
9047
9049
|
);
|
|
@@ -9964,6 +9966,49 @@ async function runFastAPICollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
9964
9966
|
// src/index.ts
|
|
9965
9967
|
var import_python_analysis12 = require("@vercel/python-analysis");
|
|
9966
9968
|
|
|
9969
|
+
// src/bytecode-packing.ts
|
|
9970
|
+
function isBytecodeAnalysisDisabled() {
|
|
9971
|
+
const val = process.env.VERCEL_PYTHON_DISABLE_BYTECODE_ANALYSIS;
|
|
9972
|
+
if (val === void 0 || val === "")
|
|
9973
|
+
return false;
|
|
9974
|
+
const lower = val.toLowerCase();
|
|
9975
|
+
return lower === "1" || lower === "true";
|
|
9976
|
+
}
|
|
9977
|
+
function annotateBytecodeItems(items, importedModules, timings) {
|
|
9978
|
+
return items.map((item) => ({
|
|
9979
|
+
...item,
|
|
9980
|
+
imported: importedModules?.has(item.moduleKey) ?? false,
|
|
9981
|
+
compileSeconds: timings?.get(item.sourceAbsPath)
|
|
9982
|
+
}));
|
|
9983
|
+
}
|
|
9984
|
+
function rankBytecodeItems(items) {
|
|
9985
|
+
const densities = items.filter((i) => i.compileSeconds != null && i.size > 0).map((i) => i.compileSeconds / i.size).sort((a, b) => a - b);
|
|
9986
|
+
const medianDensity = densities.length > 0 ? densities[Math.floor(densities.length / 2)] : null;
|
|
9987
|
+
return [...items].sort((a, b) => {
|
|
9988
|
+
if (a.imported !== b.imported)
|
|
9989
|
+
return a.imported ? -1 : 1;
|
|
9990
|
+
if (medianDensity !== null) {
|
|
9991
|
+
const da = a.compileSeconds != null && a.size > 0 ? a.compileSeconds / a.size : medianDensity;
|
|
9992
|
+
const db = b.compileSeconds != null && b.size > 0 ? b.compileSeconds / b.size : medianDensity;
|
|
9993
|
+
if (da !== db)
|
|
9994
|
+
return db - da;
|
|
9995
|
+
}
|
|
9996
|
+
return b.size - a.size;
|
|
9997
|
+
});
|
|
9998
|
+
}
|
|
9999
|
+
function fillBytecodeWithinCapacity(files, rankedItems, capacity) {
|
|
10000
|
+
let remaining = capacity;
|
|
10001
|
+
for (const item of rankedItems) {
|
|
10002
|
+
if (remaining <= 0)
|
|
10003
|
+
break;
|
|
10004
|
+
if (item.size <= remaining) {
|
|
10005
|
+
files[item.bundlePath] = item.file;
|
|
10006
|
+
remaining -= item.size;
|
|
10007
|
+
}
|
|
10008
|
+
}
|
|
10009
|
+
return remaining;
|
|
10010
|
+
}
|
|
10011
|
+
|
|
9967
10012
|
// src/compileall.ts
|
|
9968
10013
|
var import_execa10 = __toESM(require_execa());
|
|
9969
10014
|
var import_build_utils20 = require("@vercel/build-utils");
|
|
@@ -10001,7 +10046,7 @@ async function runCompileAll({
|
|
|
10001
10046
|
}) {
|
|
10002
10047
|
const uniqueSourceFiles = [...new Set(sourceFiles)];
|
|
10003
10048
|
if (uniqueSourceFiles.length === 0) {
|
|
10004
|
-
return false;
|
|
10049
|
+
return { success: false };
|
|
10005
10050
|
}
|
|
10006
10051
|
let tempDir;
|
|
10007
10052
|
try {
|
|
@@ -10010,17 +10055,25 @@ async function runCompileAll({
|
|
|
10010
10055
|
);
|
|
10011
10056
|
const listPath = (0, import_path17.join)(tempDir, "pysources.json");
|
|
10012
10057
|
await import_fs17.default.promises.writeFile(listPath, JSON.stringify(uniqueSourceFiles));
|
|
10058
|
+
const timingsPath = (0, import_path17.join)(tempDir, "timings.json");
|
|
10013
10059
|
const scriptPath4 = (0, import_path17.join)(__dirname, "..", "templates", "vc_compileall.py");
|
|
10014
10060
|
const baseEnv = env || process.env;
|
|
10015
10061
|
const subprocessEnv = pycachePrefix ? { ...baseEnv, PYTHONPYCACHEPREFIX: pycachePrefix } : baseEnv;
|
|
10016
|
-
await (0, import_execa10.default)(pythonBin, [scriptPath4, listPath], {
|
|
10062
|
+
await (0, import_execa10.default)(pythonBin, [scriptPath4, listPath, timingsPath], {
|
|
10017
10063
|
env: subprocessEnv,
|
|
10018
10064
|
timeout: COMPILEALL_TIMEOUT_MS
|
|
10019
10065
|
});
|
|
10020
|
-
|
|
10066
|
+
let timings;
|
|
10067
|
+
try {
|
|
10068
|
+
const raw = await import_fs17.default.promises.readFile(timingsPath, "utf8");
|
|
10069
|
+
timings = new Map(Object.entries(JSON.parse(raw)));
|
|
10070
|
+
} catch (err) {
|
|
10071
|
+
(0, import_build_utils20.debug)(`compileall timings unavailable: ${String(err)}`);
|
|
10072
|
+
}
|
|
10073
|
+
return { success: true, timings };
|
|
10021
10074
|
} catch (err) {
|
|
10022
10075
|
(0, import_build_utils20.debug)(`compileall error details: ${JSON.stringify(err)}`);
|
|
10023
|
-
return false;
|
|
10076
|
+
return { success: false };
|
|
10024
10077
|
} finally {
|
|
10025
10078
|
if (tempDir) {
|
|
10026
10079
|
try {
|
|
@@ -10087,9 +10140,10 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
10087
10140
|
for (const bundlePath of Object.keys(appFiles)) {
|
|
10088
10141
|
if (!bundlePath.endsWith(".py"))
|
|
10089
10142
|
continue;
|
|
10143
|
+
const sourceAbsPath = (0, import_path17.join)(workPath, bundlePath.replaceAll("/", import_path17.sep));
|
|
10090
10144
|
const stagedFsPath = deriveStagedPycFsPath(
|
|
10091
10145
|
stagingDir,
|
|
10092
|
-
|
|
10146
|
+
sourceAbsPath,
|
|
10093
10147
|
pythonMajor,
|
|
10094
10148
|
pythonMinor
|
|
10095
10149
|
);
|
|
@@ -10100,13 +10154,24 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
10100
10154
|
);
|
|
10101
10155
|
if (!stagedFsPath || !pycBundlePath)
|
|
10102
10156
|
continue;
|
|
10103
|
-
pending.push({
|
|
10157
|
+
pending.push({
|
|
10158
|
+
bundlePath: pycBundlePath,
|
|
10159
|
+
srcFsPath: stagedFsPath,
|
|
10160
|
+
moduleKey: bundlePath,
|
|
10161
|
+
sourceAbsPath
|
|
10162
|
+
});
|
|
10104
10163
|
}
|
|
10105
10164
|
const results = await Promise.all(
|
|
10106
|
-
pending.map(async ({ bundlePath, srcFsPath }) => {
|
|
10165
|
+
pending.map(async ({ bundlePath, srcFsPath, moduleKey, sourceAbsPath }) => {
|
|
10107
10166
|
try {
|
|
10108
10167
|
const stats = await import_fs17.default.promises.stat(srcFsPath);
|
|
10109
|
-
return {
|
|
10168
|
+
return {
|
|
10169
|
+
bundlePath,
|
|
10170
|
+
srcFsPath,
|
|
10171
|
+
moduleKey,
|
|
10172
|
+
sourceAbsPath,
|
|
10173
|
+
size: stats.size
|
|
10174
|
+
};
|
|
10110
10175
|
} catch {
|
|
10111
10176
|
return null;
|
|
10112
10177
|
}
|
|
@@ -10114,18 +10179,27 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
10114
10179
|
);
|
|
10115
10180
|
const files = {};
|
|
10116
10181
|
const perItemSizes = /* @__PURE__ */ new Map();
|
|
10182
|
+
const items = [];
|
|
10117
10183
|
let totalSize = 0;
|
|
10118
10184
|
for (const result of results) {
|
|
10119
10185
|
if (!result)
|
|
10120
10186
|
continue;
|
|
10121
|
-
|
|
10187
|
+
const file = new import_build_utils20.FileFsRef({
|
|
10122
10188
|
fsPath: result.srcFsPath,
|
|
10123
10189
|
size: result.size
|
|
10124
10190
|
});
|
|
10191
|
+
files[result.bundlePath] = file;
|
|
10125
10192
|
perItemSizes.set(result.bundlePath, result.size);
|
|
10193
|
+
items.push({
|
|
10194
|
+
bundlePath: result.bundlePath,
|
|
10195
|
+
file,
|
|
10196
|
+
size: result.size,
|
|
10197
|
+
moduleKey: result.moduleKey,
|
|
10198
|
+
sourceAbsPath: result.sourceAbsPath
|
|
10199
|
+
});
|
|
10126
10200
|
totalSize += result.size;
|
|
10127
10201
|
}
|
|
10128
|
-
return { files, totalSize, perItemSizes };
|
|
10202
|
+
return { files, totalSize, perItemSizes, items };
|
|
10129
10203
|
}
|
|
10130
10204
|
async function collectAppBytecodeFiles({
|
|
10131
10205
|
workPath,
|
|
@@ -10140,14 +10214,22 @@ async function collectAppBytecodeFiles({
|
|
|
10140
10214
|
continue;
|
|
10141
10215
|
pending.push({
|
|
10142
10216
|
bundlePath: pycRel,
|
|
10143
|
-
srcFsPath: (0, import_path17.join)(workPath, pycRel.replaceAll("/", import_path17.sep))
|
|
10217
|
+
srcFsPath: (0, import_path17.join)(workPath, pycRel.replaceAll("/", import_path17.sep)),
|
|
10218
|
+
moduleKey: bundlePath,
|
|
10219
|
+
sourceAbsPath: (0, import_path17.join)(workPath, bundlePath.replaceAll("/", import_path17.sep))
|
|
10144
10220
|
});
|
|
10145
10221
|
}
|
|
10146
10222
|
const results = await Promise.all(
|
|
10147
|
-
pending.map(async ({ bundlePath, srcFsPath }) => {
|
|
10223
|
+
pending.map(async ({ bundlePath, srcFsPath, moduleKey, sourceAbsPath }) => {
|
|
10148
10224
|
try {
|
|
10149
10225
|
const stats = await import_fs17.default.promises.stat(srcFsPath);
|
|
10150
|
-
return {
|
|
10226
|
+
return {
|
|
10227
|
+
bundlePath,
|
|
10228
|
+
srcFsPath,
|
|
10229
|
+
moduleKey,
|
|
10230
|
+
sourceAbsPath,
|
|
10231
|
+
size: stats.size
|
|
10232
|
+
};
|
|
10151
10233
|
} catch {
|
|
10152
10234
|
return null;
|
|
10153
10235
|
}
|
|
@@ -10155,18 +10237,27 @@ async function collectAppBytecodeFiles({
|
|
|
10155
10237
|
);
|
|
10156
10238
|
const files = {};
|
|
10157
10239
|
const perItemSizes = /* @__PURE__ */ new Map();
|
|
10240
|
+
const items = [];
|
|
10158
10241
|
let totalSize = 0;
|
|
10159
10242
|
for (const result of results) {
|
|
10160
10243
|
if (!result)
|
|
10161
10244
|
continue;
|
|
10162
|
-
|
|
10245
|
+
const file = new import_build_utils20.FileFsRef({
|
|
10163
10246
|
fsPath: result.srcFsPath,
|
|
10164
10247
|
size: result.size
|
|
10165
10248
|
});
|
|
10249
|
+
files[result.bundlePath] = file;
|
|
10166
10250
|
perItemSizes.set(result.bundlePath, result.size);
|
|
10251
|
+
items.push({
|
|
10252
|
+
bundlePath: result.bundlePath,
|
|
10253
|
+
file,
|
|
10254
|
+
size: result.size,
|
|
10255
|
+
moduleKey: result.moduleKey,
|
|
10256
|
+
sourceAbsPath: result.sourceAbsPath
|
|
10257
|
+
});
|
|
10167
10258
|
totalSize += result.size;
|
|
10168
10259
|
}
|
|
10169
|
-
return { files, totalSize, perItemSizes };
|
|
10260
|
+
return { files, totalSize, perItemSizes, items };
|
|
10170
10261
|
}
|
|
10171
10262
|
|
|
10172
10263
|
// src/installed-distributions.ts
|
|
@@ -10256,6 +10347,13 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10256
10347
|
this.pythonMajor = options.pythonMajor;
|
|
10257
10348
|
this.pythonMinor = options.pythonMinor;
|
|
10258
10349
|
}
|
|
10350
|
+
/**
|
|
10351
|
+
* Site-packages roots of the build venv (resolved). Used as import-closure
|
|
10352
|
+
* search roots and to map traced module files to vendor module keys.
|
|
10353
|
+
*/
|
|
10354
|
+
getSitePackageDirs() {
|
|
10355
|
+
return this.sitePackageDirs;
|
|
10356
|
+
}
|
|
10259
10357
|
async mirrorPackagesIntoVendor({
|
|
10260
10358
|
vendorDirName,
|
|
10261
10359
|
includePackages
|
|
@@ -10354,7 +10452,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10354
10452
|
includePackages
|
|
10355
10453
|
}) {
|
|
10356
10454
|
if (this.pythonMajor == null || this.pythonMinor == null) {
|
|
10357
|
-
return { files: {}, totalSize: 0, perItemSizes: /* @__PURE__ */ new Map() };
|
|
10455
|
+
return { files: {}, totalSize: 0, perItemSizes: /* @__PURE__ */ new Map(), items: [] };
|
|
10358
10456
|
}
|
|
10359
10457
|
const pending = [];
|
|
10360
10458
|
const distributionGroups = getDistributionFileGroups({
|
|
@@ -10364,8 +10462,9 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10364
10462
|
});
|
|
10365
10463
|
for (const { packageName, sitePackagesDir, files } of distributionGroups) {
|
|
10366
10464
|
for (const { relativePath } of files) {
|
|
10465
|
+
const moduleKey = relativePath.replaceAll(import_path18.sep, "/");
|
|
10367
10466
|
const pycRelativePath = derivePycPath(
|
|
10368
|
-
|
|
10467
|
+
moduleKey,
|
|
10369
10468
|
this.pythonMajor,
|
|
10370
10469
|
this.pythonMinor
|
|
10371
10470
|
);
|
|
@@ -10375,7 +10474,9 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10375
10474
|
pending.push({
|
|
10376
10475
|
bundlePath: (0, import_path18.join)(vendorDirName, pycFilePath).replace(/\\/g, "/"),
|
|
10377
10476
|
srcFsPath: (0, import_path18.join)(sitePackagesDir, pycFilePath),
|
|
10378
|
-
packageName
|
|
10477
|
+
packageName,
|
|
10478
|
+
moduleKey,
|
|
10479
|
+
sourceAbsPath: (0, import_path18.join)(sitePackagesDir, relativePath)
|
|
10379
10480
|
});
|
|
10380
10481
|
}
|
|
10381
10482
|
}
|
|
@@ -10391,7 +10492,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10391
10492
|
includePackages
|
|
10392
10493
|
}) {
|
|
10393
10494
|
if (this.pythonMajor == null || this.pythonMinor == null) {
|
|
10394
|
-
return { files: {}, totalSize: 0, perItemSizes: /* @__PURE__ */ new Map() };
|
|
10495
|
+
return { files: {}, totalSize: 0, perItemSizes: /* @__PURE__ */ new Map(), items: [] };
|
|
10395
10496
|
}
|
|
10396
10497
|
const pending = [];
|
|
10397
10498
|
const distributionGroups = getDistributionFileGroups({
|
|
@@ -10417,7 +10518,13 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10417
10518
|
);
|
|
10418
10519
|
if (!srcFsPath || !bundlePath)
|
|
10419
10520
|
continue;
|
|
10420
|
-
pending.push({
|
|
10521
|
+
pending.push({
|
|
10522
|
+
bundlePath,
|
|
10523
|
+
srcFsPath,
|
|
10524
|
+
packageName,
|
|
10525
|
+
moduleKey: recordPath,
|
|
10526
|
+
sourceAbsPath: absolutePath
|
|
10527
|
+
});
|
|
10421
10528
|
}
|
|
10422
10529
|
}
|
|
10423
10530
|
const result = await this.collectExistingBytecode(pending);
|
|
@@ -10428,32 +10535,56 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
10428
10535
|
}
|
|
10429
10536
|
async collectExistingBytecode(pending) {
|
|
10430
10537
|
const results = await Promise.all(
|
|
10431
|
-
pending.map(
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10538
|
+
pending.map(
|
|
10539
|
+
async ({
|
|
10540
|
+
bundlePath,
|
|
10541
|
+
srcFsPath,
|
|
10542
|
+
packageName,
|
|
10543
|
+
moduleKey,
|
|
10544
|
+
sourceAbsPath
|
|
10545
|
+
}) => {
|
|
10546
|
+
try {
|
|
10547
|
+
const stats = await import_fs18.default.promises.stat(srcFsPath);
|
|
10548
|
+
return {
|
|
10549
|
+
bundlePath,
|
|
10550
|
+
srcFsPath,
|
|
10551
|
+
size: stats.size,
|
|
10552
|
+
packageName,
|
|
10553
|
+
moduleKey,
|
|
10554
|
+
sourceAbsPath
|
|
10555
|
+
};
|
|
10556
|
+
} catch {
|
|
10557
|
+
return null;
|
|
10558
|
+
}
|
|
10437
10559
|
}
|
|
10438
|
-
|
|
10560
|
+
)
|
|
10439
10561
|
);
|
|
10440
10562
|
const files = {};
|
|
10441
10563
|
let totalSize = 0;
|
|
10442
10564
|
const perItemSizes = /* @__PURE__ */ new Map();
|
|
10565
|
+
const items = [];
|
|
10443
10566
|
for (const result of results) {
|
|
10444
10567
|
if (!result)
|
|
10445
10568
|
continue;
|
|
10446
|
-
|
|
10569
|
+
const file = new import_build_utils21.FileFsRef({
|
|
10447
10570
|
fsPath: result.srcFsPath,
|
|
10448
10571
|
size: result.size
|
|
10449
10572
|
});
|
|
10573
|
+
files[result.bundlePath] = file;
|
|
10450
10574
|
totalSize += result.size;
|
|
10451
10575
|
perItemSizes.set(
|
|
10452
10576
|
result.packageName,
|
|
10453
10577
|
(perItemSizes.get(result.packageName) ?? 0) + result.size
|
|
10454
10578
|
);
|
|
10579
|
+
items.push({
|
|
10580
|
+
bundlePath: result.bundlePath,
|
|
10581
|
+
file,
|
|
10582
|
+
size: result.size,
|
|
10583
|
+
moduleKey: result.moduleKey,
|
|
10584
|
+
sourceAbsPath: result.sourceAbsPath
|
|
10585
|
+
});
|
|
10455
10586
|
}
|
|
10456
|
-
return { files, totalSize, perItemSizes };
|
|
10587
|
+
return { files, totalSize, perItemSizes, items };
|
|
10457
10588
|
}
|
|
10458
10589
|
};
|
|
10459
10590
|
|
|
@@ -10535,6 +10666,72 @@ function workflowError(message) {
|
|
|
10535
10666
|
});
|
|
10536
10667
|
}
|
|
10537
10668
|
|
|
10669
|
+
// src/import-closure.ts
|
|
10670
|
+
var import_path20 = require("path");
|
|
10671
|
+
var import_build_utils23 = require("@vercel/build-utils");
|
|
10672
|
+
var RUNTIME_BOOTSTRAP_MODULE = "vercel_runtime.vc_init";
|
|
10673
|
+
var IMPORT_CLOSURE_TIMEOUT_MS = 3e4;
|
|
10674
|
+
async function withTimeout(promise, ms, label) {
|
|
10675
|
+
let timer;
|
|
10676
|
+
const timeout = new Promise((resolvePromise) => {
|
|
10677
|
+
timer = setTimeout(() => {
|
|
10678
|
+
(0, import_build_utils23.debug)(`${label} timed out after ${ms}ms`);
|
|
10679
|
+
resolvePromise(void 0);
|
|
10680
|
+
}, ms);
|
|
10681
|
+
});
|
|
10682
|
+
try {
|
|
10683
|
+
return await Promise.race([promise, timeout]);
|
|
10684
|
+
} finally {
|
|
10685
|
+
clearTimeout(timer);
|
|
10686
|
+
}
|
|
10687
|
+
}
|
|
10688
|
+
function getImportClosureOptions({
|
|
10689
|
+
workPath,
|
|
10690
|
+
entrypoint,
|
|
10691
|
+
frameworkSeeds,
|
|
10692
|
+
extraPythonPath,
|
|
10693
|
+
subscriberDeclarations,
|
|
10694
|
+
subscribers,
|
|
10695
|
+
workflows,
|
|
10696
|
+
workflowMode,
|
|
10697
|
+
sitePackageDirs
|
|
10698
|
+
}) {
|
|
10699
|
+
const workerModules = [
|
|
10700
|
+
...subscriberDeclarations.map((declaration) => declaration.moduleName),
|
|
10701
|
+
...workflows.map((workflow) => workflow.moduleName)
|
|
10702
|
+
];
|
|
10703
|
+
const generatedWorkerModules = [
|
|
10704
|
+
...subscribers.map(
|
|
10705
|
+
(subscriber) => generatedPythonPathToModule(
|
|
10706
|
+
getGeneratedQueueHandlerPath(getSubscriberOutputPath(subscriber.name))
|
|
10707
|
+
)
|
|
10708
|
+
),
|
|
10709
|
+
...workflowMode === "queue" ? workflows.map(
|
|
10710
|
+
(workflow) => generatedPythonPathToModule(
|
|
10711
|
+
getGeneratedQueueHandlerPath(getWorkflowOutputPath(workflow.name))
|
|
10712
|
+
)
|
|
10713
|
+
) : []
|
|
10714
|
+
];
|
|
10715
|
+
return {
|
|
10716
|
+
seeds: [
|
|
10717
|
+
.../* @__PURE__ */ new Set([
|
|
10718
|
+
RUNTIME_BOOTSTRAP_MODULE,
|
|
10719
|
+
...entrypoint ? [(0, import_path20.join)(workPath, entrypoint)] : [],
|
|
10720
|
+
...frameworkSeeds,
|
|
10721
|
+
...workerModules,
|
|
10722
|
+
...generatedWorkerModules
|
|
10723
|
+
])
|
|
10724
|
+
],
|
|
10725
|
+
searchRoots: [
|
|
10726
|
+
.../* @__PURE__ */ new Set([
|
|
10727
|
+
...extraPythonPath ? [extraPythonPath] : [],
|
|
10728
|
+
workPath,
|
|
10729
|
+
...sitePackageDirs
|
|
10730
|
+
])
|
|
10731
|
+
]
|
|
10732
|
+
};
|
|
10733
|
+
}
|
|
10734
|
+
|
|
10538
10735
|
// src/index.ts
|
|
10539
10736
|
var writeFile = import_fs20.default.promises.writeFile;
|
|
10540
10737
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
@@ -10556,9 +10753,9 @@ async function getDevSidecars({
|
|
|
10556
10753
|
service
|
|
10557
10754
|
}) {
|
|
10558
10755
|
const framework = build2.config?.framework;
|
|
10559
|
-
const isPyprojectEntrypoint = (0,
|
|
10560
|
-
const isPyprojectService = service !== void 0 && (0,
|
|
10561
|
-
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0,
|
|
10756
|
+
const isPyprojectEntrypoint = (0, import_path21.basename)(build2.src ?? "") === "pyproject.toml";
|
|
10757
|
+
const isPyprojectService = service !== void 0 && (0, import_path21.basename)(service.entrypoint ?? "") === "pyproject.toml";
|
|
10758
|
+
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0, import_build_utils24.isPythonFramework)(framework))) {
|
|
10562
10759
|
return [];
|
|
10563
10760
|
}
|
|
10564
10761
|
const legacyWorkers = await isLegacyWorkersProject(workPath);
|
|
@@ -10612,96 +10809,19 @@ function addFiles(target, source) {
|
|
|
10612
10809
|
target[p] = f;
|
|
10613
10810
|
}
|
|
10614
10811
|
}
|
|
10615
|
-
function
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
const file = bytecodeInfo.files[p];
|
|
10627
|
-
if (!file)
|
|
10628
|
-
continue;
|
|
10629
|
-
files[p] = file;
|
|
10630
|
-
remainingCapacity -= bytecodeInfo.perItemSizes.get(p) ?? 0;
|
|
10631
|
-
}
|
|
10632
|
-
return remainingCapacity;
|
|
10633
|
-
}
|
|
10634
|
-
async function addVendorBytecodeWithinCapacity({
|
|
10635
|
-
files,
|
|
10636
|
-
installedDistributions,
|
|
10637
|
-
vendorDir,
|
|
10638
|
-
bytecodeInfo,
|
|
10639
|
-
capacity
|
|
10640
|
-
}) {
|
|
10641
|
-
if (!bytecodeInfo || bytecodeInfo.totalSize <= 0 || capacity <= 0) {
|
|
10642
|
-
return capacity;
|
|
10643
|
-
}
|
|
10644
|
-
if (bytecodeInfo.totalSize <= capacity) {
|
|
10645
|
-
addFiles(files, bytecodeInfo.files);
|
|
10646
|
-
return capacity - bytecodeInfo.totalSize;
|
|
10647
|
-
}
|
|
10648
|
-
const selectedPkgs = lambdaKnapsack(bytecodeInfo.perItemSizes, capacity);
|
|
10649
|
-
if (selectedPkgs.length === 0)
|
|
10650
|
-
return capacity;
|
|
10651
|
-
const selectedBytecode = await installedDistributions.collectBytecodeFiles({
|
|
10652
|
-
vendorDirName: vendorDir,
|
|
10653
|
-
includePackages: selectedPkgs
|
|
10654
|
-
});
|
|
10655
|
-
addFiles(files, selectedBytecode.files);
|
|
10656
|
-
return capacity - selectedBytecode.totalSize;
|
|
10657
|
-
}
|
|
10658
|
-
async function addVendorBytecodeInTiers({
|
|
10659
|
-
files,
|
|
10660
|
-
installedDistributions,
|
|
10661
|
-
vendorDir,
|
|
10662
|
-
capacity,
|
|
10663
|
-
vendorPackageTiers
|
|
10664
|
-
}) {
|
|
10665
|
-
let remainingCapacity = capacity;
|
|
10666
|
-
for (const tier of vendorPackageTiers) {
|
|
10667
|
-
if (remainingCapacity <= 0)
|
|
10668
|
-
break;
|
|
10669
|
-
if (tier && tier.length === 0)
|
|
10670
|
-
continue;
|
|
10671
|
-
const bytecodeInfo = await installedDistributions.collectBytecodeFiles({
|
|
10672
|
-
vendorDirName: vendorDir,
|
|
10673
|
-
includePackages: tier
|
|
10674
|
-
});
|
|
10675
|
-
remainingCapacity = await addVendorBytecodeWithinCapacity({
|
|
10676
|
-
files,
|
|
10677
|
-
installedDistributions,
|
|
10678
|
-
vendorDir,
|
|
10679
|
-
bytecodeInfo,
|
|
10680
|
-
capacity: remainingCapacity
|
|
10681
|
-
});
|
|
10812
|
+
function moduleKeysForClosurePaths(paths, workPath, sitePackageDirs) {
|
|
10813
|
+
const keys = /* @__PURE__ */ new Set();
|
|
10814
|
+
const roots = [...sitePackageDirs, workPath].map((r) => (0, import_path21.resolve)(r));
|
|
10815
|
+
for (const p of paths) {
|
|
10816
|
+
for (const root of roots) {
|
|
10817
|
+
const rel = (0, import_path21.relative)(root, p);
|
|
10818
|
+
if (rel && !rel.startsWith("..") && !(0, import_path21.isAbsolute)(rel)) {
|
|
10819
|
+
keys.add(rel.split(import_path21.sep).join("/"));
|
|
10820
|
+
break;
|
|
10821
|
+
}
|
|
10822
|
+
}
|
|
10682
10823
|
}
|
|
10683
|
-
return
|
|
10684
|
-
}
|
|
10685
|
-
async function addCollectedVendorBytecode({
|
|
10686
|
-
files,
|
|
10687
|
-
capacity,
|
|
10688
|
-
collect
|
|
10689
|
-
}) {
|
|
10690
|
-
if (capacity <= 0)
|
|
10691
|
-
return capacity;
|
|
10692
|
-
const info = await collect(void 0);
|
|
10693
|
-
if (!info || info.totalSize <= 0)
|
|
10694
|
-
return capacity;
|
|
10695
|
-
if (info.totalSize <= capacity) {
|
|
10696
|
-
addFiles(files, info.files);
|
|
10697
|
-
return capacity - info.totalSize;
|
|
10698
|
-
}
|
|
10699
|
-
const selected = lambdaKnapsack(info.perItemSizes, capacity);
|
|
10700
|
-
if (selected.length === 0)
|
|
10701
|
-
return capacity;
|
|
10702
|
-
const selectedInfo = await collect(selected);
|
|
10703
|
-
addFiles(files, selectedInfo.files);
|
|
10704
|
-
return capacity - selectedInfo.totalSize;
|
|
10824
|
+
return keys;
|
|
10705
10825
|
}
|
|
10706
10826
|
async function runFrameworkHook(framework, ctx) {
|
|
10707
10827
|
const hook = framework ? frameworkHooks[framework] : void 0;
|
|
@@ -10716,13 +10836,13 @@ var frameworkHooks = {
|
|
|
10716
10836
|
}) => {
|
|
10717
10837
|
let baseDir = detected?.baseDir;
|
|
10718
10838
|
if (baseDir === void 0) {
|
|
10719
|
-
if (!import_fs20.default.existsSync((0,
|
|
10720
|
-
(0,
|
|
10839
|
+
if (!import_fs20.default.existsSync((0, import_path21.join)(workPath, "manage.py"))) {
|
|
10840
|
+
(0, import_build_utils24.debug)("Django hook: no manage.py detected, skipping");
|
|
10721
10841
|
return;
|
|
10722
10842
|
}
|
|
10723
10843
|
baseDir = "";
|
|
10724
10844
|
}
|
|
10725
|
-
const djangoPath = (0,
|
|
10845
|
+
const djangoPath = (0, import_path21.join)(workPath, baseDir);
|
|
10726
10846
|
let settingsResult;
|
|
10727
10847
|
try {
|
|
10728
10848
|
settingsResult = await getDjangoSettings(djangoPath, pythonEnv);
|
|
@@ -10734,13 +10854,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
10734
10854
|
} else {
|
|
10735
10855
|
detail = err?.stderr || err?.message || String(err);
|
|
10736
10856
|
}
|
|
10737
|
-
throw new
|
|
10857
|
+
throw new import_build_utils24.NowBuildError({
|
|
10738
10858
|
code: "DJANGO_SETTINGS_FAILED",
|
|
10739
10859
|
message: `Failed to read Django application settings from ${djangoPath}/manage.py:
|
|
10740
10860
|
${detail}`
|
|
10741
10861
|
});
|
|
10742
10862
|
}
|
|
10743
|
-
(0,
|
|
10863
|
+
(0, import_build_utils24.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
10744
10864
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
10745
10865
|
if (djangoVersion) {
|
|
10746
10866
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -10752,7 +10872,7 @@ ${detail}`
|
|
|
10752
10872
|
const variableName = parts.at(-1);
|
|
10753
10873
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
10754
10874
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
10755
|
-
(0,
|
|
10875
|
+
(0, import_build_utils24.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
10756
10876
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
10757
10877
|
} else {
|
|
10758
10878
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -10761,7 +10881,7 @@ ${detail}`
|
|
|
10761
10881
|
const variableName = parts.at(-1);
|
|
10762
10882
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
10763
10883
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
10764
|
-
(0,
|
|
10884
|
+
(0, import_build_utils24.debug)(
|
|
10765
10885
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
10766
10886
|
);
|
|
10767
10887
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -10769,7 +10889,7 @@ ${detail}`
|
|
|
10769
10889
|
}
|
|
10770
10890
|
let djangoStatic = null;
|
|
10771
10891
|
if (workPath && venvPath) {
|
|
10772
|
-
const outputStaticDir = (0,
|
|
10892
|
+
const outputStaticDir = (0, import_path21.join)(workPath, ".vercel", "output", "static");
|
|
10773
10893
|
djangoStatic = await runDjangoCollectStatic(
|
|
10774
10894
|
venvPath,
|
|
10775
10895
|
workPath,
|
|
@@ -10781,10 +10901,17 @@ ${detail}`
|
|
|
10781
10901
|
djangoVersion
|
|
10782
10902
|
);
|
|
10783
10903
|
}
|
|
10904
|
+
const importSeeds = [
|
|
10905
|
+
settingsModule,
|
|
10906
|
+
djangoSettings["ROOT_URLCONF"],
|
|
10907
|
+
...djangoSettings["INSTALLED_APPS"] ?? [],
|
|
10908
|
+
...djangoSettings["MIDDLEWARE"] ?? []
|
|
10909
|
+
].filter((s) => typeof s === "string");
|
|
10784
10910
|
return {
|
|
10785
10911
|
entrypoint: resolvedEntrypoint,
|
|
10786
10912
|
djangoStatic,
|
|
10787
|
-
|
|
10913
|
+
importSeeds,
|
|
10914
|
+
extraPythonPath: baseDir ? (0, import_path21.join)(workPath, baseDir) : void 0
|
|
10788
10915
|
};
|
|
10789
10916
|
},
|
|
10790
10917
|
fastapi: async ({
|
|
@@ -10795,27 +10922,27 @@ ${detail}`
|
|
|
10795
10922
|
pyprojectData
|
|
10796
10923
|
}) => {
|
|
10797
10924
|
if (!detected?.entrypoint || !workPath || !venvPath) {
|
|
10798
|
-
(0,
|
|
10925
|
+
(0, import_build_utils24.debug)(
|
|
10799
10926
|
`FastAPI hook: skipping \u2014 detected.entrypoint=${JSON.stringify(detected?.entrypoint)}, workPath=${workPath}, venvPath=${venvPath}`
|
|
10800
10927
|
);
|
|
10801
10928
|
return;
|
|
10802
10929
|
}
|
|
10803
10930
|
const { entrypoint: entrypointRel, variableName } = detected.entrypoint;
|
|
10804
|
-
(0,
|
|
10931
|
+
(0, import_build_utils24.debug)(
|
|
10805
10932
|
`FastAPI hook: entrypoint=${entrypointRel}, variableName=${variableName}`
|
|
10806
10933
|
);
|
|
10807
|
-
const entrypointAbs = (0,
|
|
10808
|
-
const outputStaticDir = (0,
|
|
10934
|
+
const entrypointAbs = (0, import_path21.join)(workPath, entrypointRel);
|
|
10935
|
+
const outputStaticDir = (0, import_path21.join)(workPath, ".vercel", "output", "static");
|
|
10809
10936
|
const cdnEnv = process.env.VERCEL_FASTAPI_STATIC_CDN?.toLowerCase();
|
|
10810
10937
|
if (cdnEnv !== "1" && cdnEnv !== "true") {
|
|
10811
|
-
(0,
|
|
10938
|
+
(0, import_build_utils24.debug)(
|
|
10812
10939
|
"FastAPI: VERCEL_FASTAPI_STATIC_CDN not set, skipping static CDN collection"
|
|
10813
10940
|
);
|
|
10814
10941
|
return;
|
|
10815
10942
|
}
|
|
10816
10943
|
const staticCdn = pyprojectData?.tool?.vercel?.fastapi?.static?.cdn;
|
|
10817
10944
|
if (staticCdn === false) {
|
|
10818
|
-
(0,
|
|
10945
|
+
(0, import_build_utils24.debug)(
|
|
10819
10946
|
"FastAPI: static.cdn = false in pyproject.toml, skipping CDN collection"
|
|
10820
10947
|
);
|
|
10821
10948
|
return;
|
|
@@ -10888,23 +11015,23 @@ async function downloadFilesInWorkPath({
|
|
|
10888
11015
|
files,
|
|
10889
11016
|
meta = {}
|
|
10890
11017
|
}) {
|
|
10891
|
-
(0,
|
|
10892
|
-
let downloadedFiles = await (0,
|
|
11018
|
+
(0, import_build_utils24.debug)("Downloading user files...");
|
|
11019
|
+
let downloadedFiles = await (0, import_build_utils24.download)(files, workPath, meta);
|
|
10893
11020
|
if (meta.isDev && entrypoint) {
|
|
10894
11021
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
10895
11022
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
10896
|
-
throw new
|
|
11023
|
+
throw new import_build_utils24.NowBuildError({
|
|
10897
11024
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
10898
11025
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
10899
11026
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
10900
11027
|
action: "Learn More"
|
|
10901
11028
|
});
|
|
10902
11029
|
}
|
|
10903
|
-
const { devCacheDir = (0,
|
|
10904
|
-
const cacheKey = (0,
|
|
10905
|
-
const destCache = (0,
|
|
10906
|
-
await (0,
|
|
10907
|
-
downloadedFiles = await (0,
|
|
11030
|
+
const { devCacheDir = (0, import_path21.join)(workPath, ".now", "cache") } = meta;
|
|
11031
|
+
const cacheKey = (0, import_path21.basename)(entrypoint).replace(/\./g, "_");
|
|
11032
|
+
const destCache = (0, import_path21.join)(devCacheDir, cacheKey);
|
|
11033
|
+
await (0, import_build_utils24.download)(downloadedFiles, destCache);
|
|
11034
|
+
downloadedFiles = await (0, import_build_utils24.glob)("**", destCache);
|
|
10908
11035
|
workPath = destCache;
|
|
10909
11036
|
}
|
|
10910
11037
|
return workPath;
|
|
@@ -10940,7 +11067,7 @@ async function getPythonLambdaOptions({
|
|
|
10940
11067
|
sources.add(entrypoint.slice(0, -".py".length));
|
|
10941
11068
|
}
|
|
10942
11069
|
for (const sourceFile of sources) {
|
|
10943
|
-
const lambdaOptions = await (0,
|
|
11070
|
+
const lambdaOptions = await (0, import_build_utils24.getLambdaOptionsFromFunction)({
|
|
10944
11071
|
sourceFile,
|
|
10945
11072
|
config
|
|
10946
11073
|
});
|
|
@@ -10961,11 +11088,11 @@ async function installInjectedPackage({
|
|
|
10961
11088
|
projectDir,
|
|
10962
11089
|
pipPlatformArgs
|
|
10963
11090
|
}) {
|
|
10964
|
-
const localDir = (0,
|
|
10965
|
-
const isLocalDev = allowLocalSource && import_fs20.default.existsSync((0,
|
|
11091
|
+
const localDir = (0, import_path21.join)(__dirname, "..", "..", "..", "python", name);
|
|
11092
|
+
const isLocalDev = allowLocalSource && import_fs20.default.existsSync((0, import_path21.join)(localDir, "pyproject.toml"));
|
|
10966
11093
|
const dep = envOverride || (isLocalDev ? localDir : requirement);
|
|
10967
11094
|
const noExclude = ["--exclude-newer-package", `${name}=false`];
|
|
10968
|
-
(0,
|
|
11095
|
+
(0, import_build_utils24.debug)(`Installing ${dep}`);
|
|
10969
11096
|
await uv.pip({
|
|
10970
11097
|
venvPath,
|
|
10971
11098
|
projectDir,
|
|
@@ -10991,14 +11118,14 @@ var build = async ({
|
|
|
10991
11118
|
registerPreDeploy
|
|
10992
11119
|
}) => {
|
|
10993
11120
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
10994
|
-
const isPyprojectEntrypoint = entrypoint !== void 0 && (0,
|
|
11121
|
+
const isPyprojectEntrypoint = entrypoint !== void 0 && (0, import_path21.basename)(entrypoint) === "pyproject.toml";
|
|
10995
11122
|
if (isPyprojectEntrypoint && entrypoint !== "pyproject.toml") {
|
|
10996
|
-
throw new
|
|
11123
|
+
throw new import_build_utils24.NowBuildError({
|
|
10997
11124
|
code: "PYTHON_INVALID_PYPROJECT_ENTRYPOINT",
|
|
10998
|
-
message: `A "pyproject.toml" entrypoint must sit at the service root. Set the service "root" to "${(0,
|
|
11125
|
+
message: `A "pyproject.toml" entrypoint must sit at the service root. Set the service "root" to "${(0, import_path21.dirname)(entrypoint)}" and use entrypoint "pyproject.toml".`
|
|
10999
11126
|
});
|
|
11000
11127
|
}
|
|
11001
|
-
const builderSpan = parentSpan ?? new
|
|
11128
|
+
const builderSpan = parentSpan ?? new import_build_utils24.Span({ name: "vc.builder" });
|
|
11002
11129
|
const framework = config?.framework;
|
|
11003
11130
|
let subscriberDeclarations = [];
|
|
11004
11131
|
let subscribers = [];
|
|
@@ -11009,7 +11136,7 @@ var build = async ({
|
|
|
11009
11136
|
let projectInstallCommand;
|
|
11010
11137
|
let hasCustomCommand = false;
|
|
11011
11138
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
11012
|
-
(0,
|
|
11139
|
+
(0, import_build_utils24.debug)(`workPath: ${workPath}`);
|
|
11013
11140
|
workPath = await downloadFilesInWorkPath({
|
|
11014
11141
|
workPath,
|
|
11015
11142
|
files: originalFiles,
|
|
@@ -11017,7 +11144,7 @@ var build = async ({
|
|
|
11017
11144
|
meta
|
|
11018
11145
|
});
|
|
11019
11146
|
legacyWorkersProject = await isLegacyWorkersProject(workPath);
|
|
11020
|
-
if (isPyprojectEntrypoint || !service && (0,
|
|
11147
|
+
if (isPyprojectEntrypoint || !service && (0, import_build_utils24.isPythonFramework)(framework)) {
|
|
11021
11148
|
subscriberDeclarations = await getPyprojectSubscribers(workPath, {
|
|
11022
11149
|
legacySchema: legacyWorkersProject
|
|
11023
11150
|
});
|
|
@@ -11025,7 +11152,7 @@ var build = async ({
|
|
|
11025
11152
|
}
|
|
11026
11153
|
try {
|
|
11027
11154
|
if (meta.isDev) {
|
|
11028
|
-
const setupCfg = (0,
|
|
11155
|
+
const setupCfg = (0, import_path21.join)(workPath, "setup.cfg");
|
|
11029
11156
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
11030
11157
|
}
|
|
11031
11158
|
} catch (err) {
|
|
@@ -11039,7 +11166,7 @@ var build = async ({
|
|
|
11039
11166
|
if (declared) {
|
|
11040
11167
|
detected = { entrypoint: declared };
|
|
11041
11168
|
} else if (subscriberDeclarations.length === 0 && workflows.length === 0) {
|
|
11042
|
-
throw new
|
|
11169
|
+
throw new import_build_utils24.NowBuildError({
|
|
11043
11170
|
code: "PYTHON_PYPROJECT_NOTHING_TO_BUILD",
|
|
11044
11171
|
message: 'Entrypoint "pyproject.toml" declares nothing to build. Set "tool.vercel.entrypoint" for a web app and/or declare "[[tool.vercel.subscribers]]" or "[[tool.vercel.workflows]]" entries in pyproject.toml.'
|
|
11045
11172
|
});
|
|
@@ -11053,7 +11180,7 @@ var build = async ({
|
|
|
11053
11180
|
filePath: entrypoint,
|
|
11054
11181
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
11055
11182
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
11056
|
-
varName: service && (0,
|
|
11183
|
+
varName: service && (0, import_build_utils24.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
11057
11184
|
} : void 0,
|
|
11058
11185
|
service,
|
|
11059
11186
|
repoRootPath
|
|
@@ -11062,8 +11189,8 @@ var build = async ({
|
|
|
11062
11189
|
if (detected?.error && detected?.baseDir === void 0) {
|
|
11063
11190
|
throw detected?.error;
|
|
11064
11191
|
}
|
|
11065
|
-
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0,
|
|
11066
|
-
const entrypointAbsDir = (0,
|
|
11192
|
+
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path21.dirname)(entrypoint) : ".");
|
|
11193
|
+
const entrypointAbsDir = (0, import_path21.join)(workPath, entryDirectory);
|
|
11067
11194
|
const rootDir = repoRootPath ?? workPath;
|
|
11068
11195
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
11069
11196
|
() => discoverPackage({
|
|
@@ -11104,12 +11231,12 @@ var build = async ({
|
|
|
11104
11231
|
}
|
|
11105
11232
|
const uvVersion = checkUvBinaryVersion(uv.getPath());
|
|
11106
11233
|
console.log(`Using ${uvVersion}`);
|
|
11107
|
-
const venvPath = service?.name ? (0,
|
|
11108
|
-
const hasCachedVenv = import_fs20.default.existsSync((0,
|
|
11234
|
+
const venvPath = service?.name ? (0, import_path21.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path21.join)(workPath, ".vercel", "python", ".venv");
|
|
11235
|
+
const hasCachedVenv = import_fs20.default.existsSync((0, import_path21.join)(venvPath, "pyvenv.cfg"));
|
|
11109
11236
|
const hasCachedUv = import_fs20.default.existsSync(uvCacheDir);
|
|
11110
11237
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
11111
11238
|
if (hasCachedVenv || hasCachedUv) {
|
|
11112
|
-
(0,
|
|
11239
|
+
(0, import_build_utils24.debug)(
|
|
11113
11240
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
11114
11241
|
);
|
|
11115
11242
|
}
|
|
@@ -11121,14 +11248,14 @@ var build = async ({
|
|
|
11121
11248
|
uvCacheDir
|
|
11122
11249
|
});
|
|
11123
11250
|
});
|
|
11124
|
-
if ((0,
|
|
11251
|
+
if ((0, import_build_utils24.isPythonFramework)(framework)) {
|
|
11125
11252
|
const {
|
|
11126
11253
|
cliType,
|
|
11127
11254
|
lockfileVersion,
|
|
11128
11255
|
packageJsonPackageManager,
|
|
11129
11256
|
turboSupportsCorepackHome
|
|
11130
|
-
} = await (0,
|
|
11131
|
-
spawnEnv = (0,
|
|
11257
|
+
} = await (0, import_build_utils24.scanParentDirs)(workPath, true);
|
|
11258
|
+
spawnEnv = (0, import_build_utils24.getEnvForPackageManager)({
|
|
11132
11259
|
cliType,
|
|
11133
11260
|
lockfileVersion,
|
|
11134
11261
|
packageJsonPackageManager,
|
|
@@ -11154,7 +11281,7 @@ var build = async ({
|
|
|
11154
11281
|
let uvProjectDir = null;
|
|
11155
11282
|
let projectName;
|
|
11156
11283
|
let usedUvManagedInstall = false;
|
|
11157
|
-
await builderSpan.child(
|
|
11284
|
+
await builderSpan.child(import_build_utils24.BUILDER_INSTALLER_STEP, {
|
|
11158
11285
|
installCommand: projectInstallCommand || void 0,
|
|
11159
11286
|
runtime: "python",
|
|
11160
11287
|
"python.cache.restored": restoredCache
|
|
@@ -11171,7 +11298,7 @@ var build = async ({
|
|
|
11171
11298
|
console.log(
|
|
11172
11299
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
11173
11300
|
);
|
|
11174
|
-
await (0,
|
|
11301
|
+
await (0, import_build_utils24.execCommand)(projectInstallCommand, {
|
|
11175
11302
|
env: pythonEnv,
|
|
11176
11303
|
cwd: workPath
|
|
11177
11304
|
});
|
|
@@ -11192,7 +11319,7 @@ var build = async ({
|
|
|
11192
11319
|
}
|
|
11193
11320
|
if (!assumeDepsInstalled) {
|
|
11194
11321
|
const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
|
|
11195
|
-
const cachedLockPath = (0,
|
|
11322
|
+
const cachedLockPath = (0, import_path21.join)(uvCacheDir, lockCacheKey);
|
|
11196
11323
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
11197
11324
|
workPath,
|
|
11198
11325
|
rootDir,
|
|
@@ -11220,15 +11347,15 @@ var build = async ({
|
|
|
11220
11347
|
}
|
|
11221
11348
|
}
|
|
11222
11349
|
});
|
|
11223
|
-
if ((0,
|
|
11350
|
+
if ((0, import_build_utils24.isPythonFramework)(framework)) {
|
|
11224
11351
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
11225
11352
|
config?.buildCommand;
|
|
11226
|
-
await builderSpan.child(
|
|
11353
|
+
await builderSpan.child(import_build_utils24.BUILDER_COMPILE_STEP, {
|
|
11227
11354
|
buildCommand: projectBuildCommand || void 0
|
|
11228
11355
|
}).trace(async () => {
|
|
11229
11356
|
if (projectBuildCommand) {
|
|
11230
11357
|
console.log(`Running "${projectBuildCommand}"`);
|
|
11231
|
-
await (0,
|
|
11358
|
+
await (0, import_build_utils24.execCommand)(projectBuildCommand, {
|
|
11232
11359
|
env: pythonEnv,
|
|
11233
11360
|
cwd: workPath
|
|
11234
11361
|
});
|
|
@@ -11256,13 +11383,14 @@ var build = async ({
|
|
|
11256
11383
|
entrypoint = resolved?.entrypoint;
|
|
11257
11384
|
const isWorkersOnly = !entrypoint && isPyprojectEntrypoint && (subscriberDeclarations.length > 0 || workflows.length > 0);
|
|
11258
11385
|
if (!entrypoint && !isWorkersOnly) {
|
|
11259
|
-
throw new
|
|
11386
|
+
throw new import_build_utils24.NowBuildError({
|
|
11260
11387
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
11261
11388
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
11262
11389
|
});
|
|
11263
11390
|
}
|
|
11264
11391
|
const djangoStatic = hookResult?.djangoStatic ?? null;
|
|
11265
11392
|
const fastapiStatic = hookResult?.fastapiStatic ?? null;
|
|
11393
|
+
const importSeeds = hookResult?.importSeeds ?? [];
|
|
11266
11394
|
const cdnOutputDir = djangoStatic?.cdnOutputDir ?? fastapiStatic?.cdnOutputDir ?? null;
|
|
11267
11395
|
const pipPlatformArgs = target.uvPlatform ? ["--python-platform", target.uvPlatform] : [];
|
|
11268
11396
|
await installInjectedPackage({
|
|
@@ -11272,7 +11400,7 @@ var build = async ({
|
|
|
11272
11400
|
allowLocalSource: true,
|
|
11273
11401
|
uv,
|
|
11274
11402
|
venvPath,
|
|
11275
|
-
projectDir: (0,
|
|
11403
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11276
11404
|
pipPlatformArgs
|
|
11277
11405
|
});
|
|
11278
11406
|
const conditionalInjectedPackages = usedUvManagedInstall && !legacyWorkersProject ? await getConditionalInjectedPackages({
|
|
@@ -11284,7 +11412,7 @@ var build = async ({
|
|
|
11284
11412
|
...injectedPackage,
|
|
11285
11413
|
uv,
|
|
11286
11414
|
venvPath,
|
|
11287
|
-
projectDir: (0,
|
|
11415
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11288
11416
|
pipPlatformArgs
|
|
11289
11417
|
});
|
|
11290
11418
|
}
|
|
@@ -11293,7 +11421,7 @@ var build = async ({
|
|
|
11293
11421
|
pythonPackage,
|
|
11294
11422
|
uv,
|
|
11295
11423
|
venvPath,
|
|
11296
|
-
projectDir: (0,
|
|
11424
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11297
11425
|
uvLockPath
|
|
11298
11426
|
});
|
|
11299
11427
|
}
|
|
@@ -11306,7 +11434,7 @@ var build = async ({
|
|
|
11306
11434
|
allowLocalSource: true,
|
|
11307
11435
|
uv,
|
|
11308
11436
|
venvPath,
|
|
11309
|
-
projectDir: (0,
|
|
11437
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11310
11438
|
pipPlatformArgs
|
|
11311
11439
|
});
|
|
11312
11440
|
}
|
|
@@ -11317,11 +11445,11 @@ var build = async ({
|
|
|
11317
11445
|
const queueIntegrations = legacyWorkersProject ? [] : await getQueueIntegrations({ pythonPackage });
|
|
11318
11446
|
const writeGeneratedQueueHandler = async (outputPath, declaration) => {
|
|
11319
11447
|
const generatedPath = getGeneratedQueueHandlerPath(outputPath);
|
|
11320
|
-
await import_fs20.default.promises.mkdir((0,
|
|
11448
|
+
await import_fs20.default.promises.mkdir((0, import_path21.dirname)((0, import_path21.join)(workPath, generatedPath)), {
|
|
11321
11449
|
recursive: true
|
|
11322
11450
|
});
|
|
11323
11451
|
await import_fs20.default.promises.writeFile(
|
|
11324
|
-
(0,
|
|
11452
|
+
(0, import_path21.join)(workPath, generatedPath),
|
|
11325
11453
|
createQueueHandlerModule(declaration, queueIntegrations)
|
|
11326
11454
|
);
|
|
11327
11455
|
};
|
|
@@ -11330,7 +11458,7 @@ var build = async ({
|
|
|
11330
11458
|
declarations: subscriberDeclarations,
|
|
11331
11459
|
uv,
|
|
11332
11460
|
venvPath,
|
|
11333
|
-
projectDir: (0,
|
|
11461
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11334
11462
|
integrations: queueIntegrations
|
|
11335
11463
|
});
|
|
11336
11464
|
if (workflowMode === "queue") {
|
|
@@ -11361,7 +11489,7 @@ var build = async ({
|
|
|
11361
11489
|
})),
|
|
11362
11490
|
uv,
|
|
11363
11491
|
venvPath,
|
|
11364
|
-
projectDir: (0,
|
|
11492
|
+
projectDir: (0, import_path21.join)(workPath, entryDirectory),
|
|
11365
11493
|
kind: "workflow",
|
|
11366
11494
|
integrations: queueIntegrations
|
|
11367
11495
|
});
|
|
@@ -11378,11 +11506,11 @@ var build = async ({
|
|
|
11378
11506
|
const capturedEnv = { ...pythonEnv };
|
|
11379
11507
|
const capturedCwd = workPath;
|
|
11380
11508
|
registerPreDeploy(async () => {
|
|
11381
|
-
await builderSpan.child(
|
|
11509
|
+
await builderSpan.child(import_build_utils24.BUILDER_PRE_DEPLOY_STEP, {
|
|
11382
11510
|
preDeployCommand
|
|
11383
11511
|
}).trace(async () => {
|
|
11384
11512
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
11385
|
-
await (0,
|
|
11513
|
+
await (0, import_build_utils24.execCommand)(preDeployCommand, {
|
|
11386
11514
|
env: capturedEnv,
|
|
11387
11515
|
cwd: capturedCwd
|
|
11388
11516
|
});
|
|
@@ -11393,14 +11521,14 @@ var build = async ({
|
|
|
11393
11521
|
let crons;
|
|
11394
11522
|
let runtimeTrampoline;
|
|
11395
11523
|
if (entrypoint) {
|
|
11396
|
-
(0,
|
|
11524
|
+
(0, import_build_utils24.debug)("Entrypoint is", entrypoint);
|
|
11397
11525
|
const moduleName = entrypointToModule(entrypoint);
|
|
11398
11526
|
if (handlerFunction) {
|
|
11399
|
-
const entrypointPath = (0,
|
|
11527
|
+
const entrypointPath = (0, import_path21.join)(workPath, entrypoint);
|
|
11400
11528
|
const source = await import_fs20.default.promises.readFile(entrypointPath, "utf-8");
|
|
11401
11529
|
const found = await (0, import_python_analysis12.containsTopLevelCallable)(source, handlerFunction);
|
|
11402
11530
|
if (!found) {
|
|
11403
|
-
throw new
|
|
11531
|
+
throw new import_build_utils24.NowBuildError({
|
|
11404
11532
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
11405
11533
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
11406
11534
|
});
|
|
@@ -11408,7 +11536,7 @@ var build = async ({
|
|
|
11408
11536
|
}
|
|
11409
11537
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
11410
11538
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
11411
|
-
(0,
|
|
11539
|
+
(0, import_build_utils24.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
11412
11540
|
crons = await getServiceCrons({
|
|
11413
11541
|
service,
|
|
11414
11542
|
entrypoint,
|
|
@@ -11474,17 +11602,17 @@ var build = async ({
|
|
|
11474
11602
|
cwd: workPath,
|
|
11475
11603
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
11476
11604
|
};
|
|
11477
|
-
const files = await (0,
|
|
11478
|
-
const appPythonSourceFiles = Object.keys(files).filter((file) => file.endsWith(".py")).map((file) => (0,
|
|
11605
|
+
const files = await (0, import_build_utils24.glob)("**", globOptions);
|
|
11606
|
+
const appPythonSourceFiles = Object.keys(files).filter((file) => file.endsWith(".py")).map((file) => (0, import_path21.join)(workPath, file)).sort();
|
|
11479
11607
|
if (djangoStatic?.manifestRelPath) {
|
|
11480
|
-
files[djangoStatic.manifestRelPath] = new
|
|
11481
|
-
fsPath: (0,
|
|
11608
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils24.FileFsRef({
|
|
11609
|
+
fsPath: (0, import_path21.join)(workPath, djangoStatic.manifestRelPath)
|
|
11482
11610
|
});
|
|
11483
11611
|
}
|
|
11484
11612
|
const handlerPyFilename = "vc__handler__python";
|
|
11485
11613
|
if (config.framework === "fasthtml") {
|
|
11486
11614
|
const { SESSKEY = "" } = process.env;
|
|
11487
|
-
files[".sesskey"] = new
|
|
11615
|
+
files[".sesskey"] = new import_build_utils24.FileBlob({ data: `"${SESSKEY}"` });
|
|
11488
11616
|
}
|
|
11489
11617
|
await builderSpan.child("vc.builder.python.bundle").trace(async (bundleSpan) => {
|
|
11490
11618
|
const installedDistributions = await InstalledPythonDistributions.load({
|
|
@@ -11525,15 +11653,17 @@ var build = async ({
|
|
|
11525
11653
|
pycachePrefix
|
|
11526
11654
|
}) => {
|
|
11527
11655
|
if (!compileAllOptions)
|
|
11528
|
-
return;
|
|
11656
|
+
return void 0;
|
|
11529
11657
|
const vendorSourceFiles = installedDistributions.getPythonSourceFiles(includePackages);
|
|
11658
|
+
let timings;
|
|
11530
11659
|
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
11531
11660
|
console.log("Compiling Python bytecode...");
|
|
11532
|
-
await runCompileAll({
|
|
11661
|
+
const result = await runCompileAll({
|
|
11533
11662
|
...compileAllOptions,
|
|
11534
11663
|
sourceFiles: [...appPythonSourceFiles, ...vendorSourceFiles],
|
|
11535
11664
|
pycachePrefix
|
|
11536
11665
|
});
|
|
11666
|
+
timings = result.timings;
|
|
11537
11667
|
compileSpan.setAttributes({
|
|
11538
11668
|
"python.compileall.enabled": "true",
|
|
11539
11669
|
"python.compileall.appSourceFileCount": String(
|
|
@@ -11544,39 +11674,119 @@ var build = async ({
|
|
|
11544
11674
|
)
|
|
11545
11675
|
});
|
|
11546
11676
|
});
|
|
11677
|
+
return timings;
|
|
11547
11678
|
};
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11679
|
+
let importClosurePromise;
|
|
11680
|
+
const getImportClosureKeys = () => {
|
|
11681
|
+
importClosurePromise ??= (async () => {
|
|
11682
|
+
try {
|
|
11683
|
+
const sitePackageDirs = installedDistributions.getSitePackageDirs();
|
|
11684
|
+
const closure = await withTimeout(
|
|
11685
|
+
(0, import_python_analysis12.collectImportClosure)(
|
|
11686
|
+
getImportClosureOptions({
|
|
11687
|
+
workPath,
|
|
11688
|
+
entrypoint,
|
|
11689
|
+
frameworkSeeds: importSeeds,
|
|
11690
|
+
extraPythonPath: hookResult?.extraPythonPath,
|
|
11691
|
+
subscriberDeclarations,
|
|
11692
|
+
subscribers,
|
|
11693
|
+
workflows,
|
|
11694
|
+
workflowMode,
|
|
11695
|
+
sitePackageDirs
|
|
11696
|
+
})
|
|
11697
|
+
),
|
|
11698
|
+
IMPORT_CLOSURE_TIMEOUT_MS,
|
|
11699
|
+
"import closure"
|
|
11700
|
+
);
|
|
11701
|
+
if (!closure)
|
|
11702
|
+
return void 0;
|
|
11703
|
+
const keys = moduleKeysForClosurePaths(
|
|
11704
|
+
closure.files,
|
|
11557
11705
|
workPath,
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11706
|
+
sitePackageDirs
|
|
11707
|
+
);
|
|
11708
|
+
(0, import_build_utils24.debug)(
|
|
11709
|
+
`import closure: ${closure.files.size} files, ${keys.size} bundled modules` + (closure.truncated ? " (truncated)" : "")
|
|
11710
|
+
);
|
|
11711
|
+
return keys;
|
|
11712
|
+
} catch (err) {
|
|
11713
|
+
(0, import_build_utils24.debug)(
|
|
11714
|
+
`import closure unavailable, ranking by compile density only: ${err}`
|
|
11715
|
+
);
|
|
11716
|
+
return void 0;
|
|
11717
|
+
}
|
|
11718
|
+
})();
|
|
11719
|
+
return importClosurePromise;
|
|
11720
|
+
};
|
|
11721
|
+
const fillBytecodeWithValueRanking = async ({
|
|
11722
|
+
items,
|
|
11723
|
+
totalSize,
|
|
11724
|
+
capacity,
|
|
11725
|
+
timings
|
|
11726
|
+
}) => {
|
|
11727
|
+
if (totalSize <= 0 || capacity <= 0)
|
|
11728
|
+
return 0;
|
|
11729
|
+
if (totalSize <= capacity) {
|
|
11730
|
+
for (const item of items) {
|
|
11731
|
+
files[item.bundlePath] = item.file;
|
|
11732
|
+
}
|
|
11733
|
+
return totalSize;
|
|
11734
|
+
}
|
|
11735
|
+
return bundleSpan.child("vc.builder.python.bundle.optimize").trace(async (optimizeSpan) => {
|
|
11736
|
+
console.log("Optimizing Python bundle...");
|
|
11737
|
+
const analysisDisabled = isBytecodeAnalysisDisabled();
|
|
11738
|
+
if (analysisDisabled) {
|
|
11739
|
+
(0, import_build_utils24.debug)(
|
|
11740
|
+
"bytecode analysis disabled via VERCEL_PYTHON_DISABLE_BYTECODE_ANALYSIS; ranking by size"
|
|
11566
11741
|
);
|
|
11567
11742
|
}
|
|
11568
|
-
await
|
|
11743
|
+
const importedModules = analysisDisabled ? void 0 : await getImportClosureKeys();
|
|
11744
|
+
const ranked = rankBytecodeItems(
|
|
11745
|
+
annotateBytecodeItems(
|
|
11746
|
+
items,
|
|
11747
|
+
importedModules,
|
|
11748
|
+
analysisDisabled ? void 0 : timings
|
|
11749
|
+
)
|
|
11750
|
+
);
|
|
11751
|
+
const selectedSize = capacity - fillBytecodeWithinCapacity(files, ranked, capacity);
|
|
11752
|
+
optimizeSpan.setAttributes({
|
|
11753
|
+
"python.bundle.optimize.bytecodeCoveragePercent": (selectedSize / totalSize * 100).toFixed(2)
|
|
11754
|
+
});
|
|
11755
|
+
return selectedSize;
|
|
11756
|
+
});
|
|
11757
|
+
};
|
|
11758
|
+
const runAdjacentCompileAndFill = async (capacityBytes, includePackages) => {
|
|
11759
|
+
try {
|
|
11760
|
+
const pyMajor = pythonVersion.major;
|
|
11761
|
+
const pyMinor = pythonVersion.minor;
|
|
11762
|
+
if (pyMajor == null || pyMinor == null)
|
|
11763
|
+
return;
|
|
11764
|
+
const timings = await compileSources({ includePackages });
|
|
11765
|
+
const currentSize = await calculateBundleSize(files);
|
|
11766
|
+
const remaining = capacityBytes - currentSize;
|
|
11767
|
+
if (remaining <= 0)
|
|
11768
|
+
return;
|
|
11769
|
+
const appInfo = await collectAppBytecodeFiles({
|
|
11770
|
+
workPath,
|
|
11569
11771
|
files,
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11772
|
+
pythonMajor: pyMajor,
|
|
11773
|
+
pythonMinor: pyMinor
|
|
11774
|
+
});
|
|
11775
|
+
const vendorInfo = await installedDistributions.collectBytecodeFiles({
|
|
11776
|
+
vendorDirName: vendorDir,
|
|
11777
|
+
includePackages
|
|
11778
|
+
});
|
|
11779
|
+
await fillBytecodeWithValueRanking({
|
|
11780
|
+
items: [...appInfo.items, ...vendorInfo.items],
|
|
11781
|
+
totalSize: appInfo.totalSize + vendorInfo.totalSize,
|
|
11782
|
+
capacity: remaining,
|
|
11783
|
+
timings
|
|
11574
11784
|
});
|
|
11575
11785
|
} catch (err) {
|
|
11576
11786
|
console.log(
|
|
11577
11787
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
11578
11788
|
);
|
|
11579
|
-
(0,
|
|
11789
|
+
(0, import_build_utils24.debug)(`bytecode precompilation error details: ${err}`);
|
|
11580
11790
|
}
|
|
11581
11791
|
};
|
|
11582
11792
|
const runPrefixCompileAndFill = async (bundleResult) => {
|
|
@@ -11586,25 +11796,27 @@ var build = async ({
|
|
|
11586
11796
|
return;
|
|
11587
11797
|
try {
|
|
11588
11798
|
const currentSize = await calculateBundleSize(files);
|
|
11589
|
-
|
|
11799
|
+
const remainingCapacity = BYTECODE_FILL_CEILING_BYTES - currentSize;
|
|
11590
11800
|
if (remainingCapacity <= 0) {
|
|
11591
|
-
(0,
|
|
11801
|
+
(0, import_build_utils24.debug)(
|
|
11592
11802
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
11593
11803
|
);
|
|
11594
11804
|
return;
|
|
11595
11805
|
}
|
|
11596
|
-
const stagingDir = (0,
|
|
11806
|
+
const stagingDir = (0, import_path21.join)(workPath, ".vercel", "python", "pycache");
|
|
11597
11807
|
await import_fs20.default.promises.rm(stagingDir, { recursive: true, force: true });
|
|
11598
11808
|
await import_fs20.default.promises.mkdir(stagingDir, { recursive: true });
|
|
11599
|
-
|
|
11809
|
+
const alwaysBundled = bundleResult.alwaysBundledPackages ?? [];
|
|
11810
|
+
const bundledPublic = bundleResult.bundledPublicPackages ?? [];
|
|
11811
|
+
const externalized = bundleResult.externalizedPublicPackages ?? [];
|
|
11812
|
+
const timings = await compileSources({
|
|
11600
11813
|
includePackages: [
|
|
11601
|
-
...
|
|
11602
|
-
...
|
|
11603
|
-
...
|
|
11814
|
+
...alwaysBundled,
|
|
11815
|
+
...bundledPublic,
|
|
11816
|
+
...externalized
|
|
11604
11817
|
],
|
|
11605
11818
|
pycachePrefix: stagingDir
|
|
11606
11819
|
});
|
|
11607
|
-
const beforeCount = Object.keys(files).length;
|
|
11608
11820
|
const appInfo = await collectAppPrefixBytecodeFiles({
|
|
11609
11821
|
stagingDir,
|
|
11610
11822
|
workPath,
|
|
@@ -11613,39 +11825,34 @@ var build = async ({
|
|
|
11613
11825
|
pythonMajor: pyMajor,
|
|
11614
11826
|
pythonMinor: pyMinor
|
|
11615
11827
|
});
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
);
|
|
11621
|
-
const alwaysBundled = bundleResult.alwaysBundledPackages ?? [];
|
|
11622
|
-
remainingCapacity = await addCollectedVendorBytecode({
|
|
11623
|
-
files,
|
|
11624
|
-
capacity: remainingCapacity,
|
|
11625
|
-
collect: (include) => installedDistributions.collectPrefixBytecodeFiles({
|
|
11626
|
-
stagingDir,
|
|
11627
|
-
runtimeRoot: `/var/task/${vendorDir}`,
|
|
11628
|
-
includePackages: include ?? alwaysBundled
|
|
11629
|
-
})
|
|
11828
|
+
const bundledVendorInfo = await installedDistributions.collectPrefixBytecodeFiles({
|
|
11829
|
+
stagingDir,
|
|
11830
|
+
runtimeRoot: `/var/task/${vendorDir}`,
|
|
11831
|
+
includePackages: [...alwaysBundled, ...bundledPublic]
|
|
11630
11832
|
});
|
|
11631
|
-
const
|
|
11632
|
-
|
|
11633
|
-
|
|
11833
|
+
const externalizedInfo = await installedDistributions.collectPrefixBytecodeFiles({
|
|
11834
|
+
stagingDir,
|
|
11835
|
+
runtimeRoot: `${RUNTIME_DEPS_DIR}/lib/python${pyMajor}.${pyMinor}/site-packages`,
|
|
11836
|
+
includePackages: externalized
|
|
11837
|
+
});
|
|
11838
|
+
const bytesAdded = await fillBytecodeWithValueRanking({
|
|
11839
|
+
items: [
|
|
11840
|
+
...appInfo.items,
|
|
11841
|
+
...bundledVendorInfo.items,
|
|
11842
|
+
...externalizedInfo.items
|
|
11843
|
+
],
|
|
11844
|
+
totalSize: appInfo.totalSize + bundledVendorInfo.totalSize + externalizedInfo.totalSize,
|
|
11634
11845
|
capacity: remainingCapacity,
|
|
11635
|
-
|
|
11636
|
-
stagingDir,
|
|
11637
|
-
runtimeRoot: `${RUNTIME_DEPS_DIR}/lib/python${pyMajor}.${pyMinor}/site-packages`,
|
|
11638
|
-
includePackages: include ?? externalized
|
|
11639
|
-
})
|
|
11846
|
+
timings
|
|
11640
11847
|
});
|
|
11641
|
-
if (
|
|
11848
|
+
if (bytesAdded > 0) {
|
|
11642
11849
|
lambdaEnv.PYTHONPYCACHEPREFIX = RUNTIME_PYCACHE_PREFIX;
|
|
11643
11850
|
}
|
|
11644
11851
|
} catch (err) {
|
|
11645
11852
|
console.log(
|
|
11646
11853
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
11647
11854
|
);
|
|
11648
|
-
(0,
|
|
11855
|
+
(0, import_build_utils24.debug)(`bytecode precompilation error details: ${err}`);
|
|
11649
11856
|
}
|
|
11650
11857
|
};
|
|
11651
11858
|
const announceLargeFunction = () => console.log(
|
|
@@ -11662,9 +11869,7 @@ var build = async ({
|
|
|
11662
11869
|
packingMode = "hive";
|
|
11663
11870
|
announceLargeFunction();
|
|
11664
11871
|
if (compileAllEnabled) {
|
|
11665
|
-
await
|
|
11666
|
-
LARGE_FUNCTION_FILL_CEILING_BYTES
|
|
11667
|
-
);
|
|
11872
|
+
await runAdjacentCompileAndFill(LARGE_FUNCTION_FILL_CEILING_BYTES);
|
|
11668
11873
|
}
|
|
11669
11874
|
} else if (bundleResult.packingMode === "bytecode-first") {
|
|
11670
11875
|
await runPrefixCompileAndFill(bundleResult);
|
|
@@ -11672,12 +11877,12 @@ var build = async ({
|
|
|
11672
11877
|
const currentSize = await calculateBundleSize(files);
|
|
11673
11878
|
const capacity = BYTECODE_FILL_CEILING_BYTES - currentSize;
|
|
11674
11879
|
if (capacity > 0) {
|
|
11675
|
-
await
|
|
11676
|
-
bundleResult.alwaysBundledPackages ?? [],
|
|
11677
|
-
bundleResult.bundledPublicPackages ?? []
|
|
11880
|
+
await runAdjacentCompileAndFill(BYTECODE_FILL_CEILING_BYTES, [
|
|
11881
|
+
...bundleResult.alwaysBundledPackages ?? [],
|
|
11882
|
+
...bundleResult.bundledPublicPackages ?? []
|
|
11678
11883
|
]);
|
|
11679
11884
|
} else {
|
|
11680
|
-
(0,
|
|
11885
|
+
(0, import_build_utils24.debug)(
|
|
11681
11886
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
11682
11887
|
);
|
|
11683
11888
|
}
|
|
@@ -11690,18 +11895,16 @@ var build = async ({
|
|
|
11690
11895
|
announceLargeFunction();
|
|
11691
11896
|
}
|
|
11692
11897
|
if (compileAllEnabled) {
|
|
11693
|
-
await
|
|
11694
|
-
LARGE_FUNCTION_FILL_CEILING_BYTES
|
|
11695
|
-
);
|
|
11898
|
+
await runAdjacentCompileAndFill(LARGE_FUNCTION_FILL_CEILING_BYTES);
|
|
11696
11899
|
}
|
|
11697
11900
|
} else {
|
|
11698
11901
|
packingMode = "standard";
|
|
11699
11902
|
if (compileAllEnabled) {
|
|
11700
11903
|
const capacity = BYTECODE_FILL_CEILING_BYTES - depAnalysis.totalBundleSize;
|
|
11701
11904
|
if (capacity > 0) {
|
|
11702
|
-
await
|
|
11905
|
+
await runAdjacentCompileAndFill(BYTECODE_FILL_CEILING_BYTES);
|
|
11703
11906
|
} else {
|
|
11704
|
-
(0,
|
|
11907
|
+
(0, import_build_utils24.debug)(
|
|
11705
11908
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(depAnalysis.totalBundleSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
11706
11909
|
);
|
|
11707
11910
|
}
|
|
@@ -11719,13 +11922,13 @@ var build = async ({
|
|
|
11719
11922
|
if (entrypoint && runtimeTrampoline) {
|
|
11720
11923
|
const webFiles = {
|
|
11721
11924
|
...files,
|
|
11722
|
-
[`${handlerPyFilename}.py`]: new
|
|
11925
|
+
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({ data: runtimeTrampoline })
|
|
11723
11926
|
};
|
|
11724
11927
|
const lambdaOptions = await getPythonLambdaOptions({
|
|
11725
11928
|
config,
|
|
11726
11929
|
entrypoint
|
|
11727
11930
|
});
|
|
11728
|
-
output = new
|
|
11931
|
+
output = new import_build_utils24.Lambda({
|
|
11729
11932
|
files: webFiles,
|
|
11730
11933
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
11731
11934
|
runtime: pythonVersion.runtime,
|
|
@@ -11754,10 +11957,10 @@ var build = async ({
|
|
|
11754
11957
|
...subscription.triggerDefaults
|
|
11755
11958
|
})
|
|
11756
11959
|
);
|
|
11757
|
-
subscriberLambdas[outputPath] = new
|
|
11960
|
+
subscriberLambdas[outputPath] = new import_build_utils24.Lambda({
|
|
11758
11961
|
files: {
|
|
11759
11962
|
...files,
|
|
11760
|
-
[`${handlerPyFilename}.py`]: new
|
|
11963
|
+
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({
|
|
11761
11964
|
data: createRuntimeTrampoline({
|
|
11762
11965
|
moduleName: generatedPythonPathToModule(generatedHandlerPath),
|
|
11763
11966
|
entrypoint: generatedHandlerPath,
|
|
@@ -11787,10 +11990,10 @@ var build = async ({
|
|
|
11787
11990
|
consumer,
|
|
11788
11991
|
...legacy.triggerDefaults
|
|
11789
11992
|
}));
|
|
11790
|
-
subscriberLambdas[outputPath] = new
|
|
11993
|
+
subscriberLambdas[outputPath] = new import_build_utils24.Lambda({
|
|
11791
11994
|
files: {
|
|
11792
11995
|
...files,
|
|
11793
|
-
[`${handlerPyFilename}.py`]: new
|
|
11996
|
+
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({
|
|
11794
11997
|
data: createRuntimeTrampoline({
|
|
11795
11998
|
moduleName: declaration.moduleName,
|
|
11796
11999
|
entrypoint: declaration.entrypoint,
|
|
@@ -11823,10 +12026,10 @@ var build = async ({
|
|
|
11823
12026
|
...subscription.triggerDefaults
|
|
11824
12027
|
})
|
|
11825
12028
|
);
|
|
11826
|
-
workflowLambdas[outputPath] = new
|
|
12029
|
+
workflowLambdas[outputPath] = new import_build_utils24.Lambda({
|
|
11827
12030
|
files: {
|
|
11828
12031
|
...files,
|
|
11829
|
-
[`${handlerPyFilename}.py`]: new
|
|
12032
|
+
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({
|
|
11830
12033
|
data: createRuntimeTrampoline({
|
|
11831
12034
|
moduleName: generatedPythonPathToModule(generatedHandlerPath),
|
|
11832
12035
|
entrypoint: generatedHandlerPath,
|
|
@@ -11852,10 +12055,10 @@ var build = async ({
|
|
|
11852
12055
|
consumer: getWorkflowConsumerName(workflow.name)
|
|
11853
12056
|
}
|
|
11854
12057
|
];
|
|
11855
|
-
workflowLambdas[outputPath] = new
|
|
12058
|
+
workflowLambdas[outputPath] = new import_build_utils24.Lambda({
|
|
11856
12059
|
files: {
|
|
11857
12060
|
...files,
|
|
11858
|
-
[`${handlerPyFilename}.py`]: new
|
|
12061
|
+
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({
|
|
11859
12062
|
data: createRuntimeTrampoline({
|
|
11860
12063
|
moduleName: workflow.moduleName,
|
|
11861
12064
|
entrypoint: workflow.entrypoint,
|
|
@@ -11880,21 +12083,21 @@ var build = async ({
|
|
|
11880
12083
|
pythonVersion,
|
|
11881
12084
|
uvLockPath,
|
|
11882
12085
|
framework,
|
|
11883
|
-
serviceType: service ? (0,
|
|
12086
|
+
serviceType: service ? (0, import_build_utils24.getReportedServiceType)(service) : void 0
|
|
11884
12087
|
});
|
|
11885
12088
|
} catch (err) {
|
|
11886
|
-
(0,
|
|
12089
|
+
(0, import_build_utils24.debug)(
|
|
11887
12090
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
11888
12091
|
);
|
|
11889
12092
|
}
|
|
11890
12093
|
}
|
|
11891
|
-
if (!(0,
|
|
12094
|
+
if (!(0, import_build_utils24.isPythonFramework)(framework) && !service?.name && !isPyprojectEntrypoint) {
|
|
11892
12095
|
(0, import_assert.default)(output, "web Lambda must exist for non-service builds");
|
|
11893
12096
|
return { resultVersion: 3, result: { output } };
|
|
11894
12097
|
}
|
|
11895
12098
|
const frameworkLambdaName = framework ?? "python";
|
|
11896
12099
|
const lambdaPath = service?.name && service.type ? `_svc/${service.name}/index` : frameworkLambdaName;
|
|
11897
|
-
const staticFiles = cdnOutputDir ? await (0,
|
|
12100
|
+
const staticFiles = cdnOutputDir ? await (0, import_build_utils24.glob)("**", { cwd: cdnOutputDir }) : {};
|
|
11898
12101
|
const isNonWebService = service?.name && service.type && service.type !== "web";
|
|
11899
12102
|
const queueRoutes = queueRoutePaths.map((outputPath) => ({
|
|
11900
12103
|
src: `/${outputPath}`,
|
|
@@ -11947,14 +12150,14 @@ var prepareCache = async ({
|
|
|
11947
12150
|
}
|
|
11948
12151
|
} catch {
|
|
11949
12152
|
}
|
|
11950
|
-
return (0,
|
|
12153
|
+
return (0, import_build_utils24.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
11951
12154
|
cwd: root,
|
|
11952
12155
|
ignore
|
|
11953
12156
|
});
|
|
11954
12157
|
};
|
|
11955
12158
|
var shouldServe = (opts) => {
|
|
11956
12159
|
const framework = opts.config.framework;
|
|
11957
|
-
if ((0,
|
|
12160
|
+
if ((0, import_build_utils24.isPythonFramework)(framework)) {
|
|
11958
12161
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
11959
12162
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
11960
12163
|
return false;
|
|
@@ -11973,7 +12176,7 @@ var defaultShouldServe = ({
|
|
|
11973
12176
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
11974
12177
|
return true;
|
|
11975
12178
|
}
|
|
11976
|
-
const { dir, name } = (0,
|
|
12179
|
+
const { dir, name } = (0, import_path21.parse)(entrypoint);
|
|
11977
12180
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
11978
12181
|
return true;
|
|
11979
12182
|
}
|
|
@@ -11984,8 +12187,6 @@ function hasProp(obj, key) {
|
|
|
11984
12187
|
}
|
|
11985
12188
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11986
12189
|
0 && (module.exports = {
|
|
11987
|
-
addCollectedVendorBytecode,
|
|
11988
|
-
addVendorBytecodeInTiers,
|
|
11989
12190
|
build,
|
|
11990
12191
|
defaultShouldServe,
|
|
11991
12192
|
detectEntrypoint,
|
|
@@ -11994,6 +12195,7 @@ function hasProp(obj, key) {
|
|
|
11994
12195
|
getDevSidecars,
|
|
11995
12196
|
installRequirement,
|
|
11996
12197
|
installRequirementsFile,
|
|
12198
|
+
moduleKeysForClosurePaths,
|
|
11997
12199
|
prepareCache,
|
|
11998
12200
|
runFrameworkHook,
|
|
11999
12201
|
shouldServe,
|