@vercel/python 6.51.1 → 6.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +454 -320
- package/package.json +6 -7
- package/templates/vc_compileall.py +47 -0
- package/templates/vc_fastapi_static.py +116 -0
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ var require_windows = __commonJS({
|
|
|
48
48
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
|
|
49
49
|
module2.exports = isexe;
|
|
50
50
|
isexe.sync = sync;
|
|
51
|
-
var
|
|
51
|
+
var fs18 = require("fs");
|
|
52
52
|
function checkPathExt(path, options) {
|
|
53
53
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
54
54
|
if (!pathext) {
|
|
@@ -73,12 +73,12 @@ var require_windows = __commonJS({
|
|
|
73
73
|
return checkPathExt(path, options);
|
|
74
74
|
}
|
|
75
75
|
function isexe(path, options, cb) {
|
|
76
|
-
|
|
76
|
+
fs18.stat(path, function(er, stat) {
|
|
77
77
|
cb(er, er ? false : checkStat(stat, path, options));
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function sync(path, options) {
|
|
81
|
-
return checkStat(
|
|
81
|
+
return checkStat(fs18.statSync(path), path, options);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
});
|
|
@@ -88,14 +88,14 @@ var require_mode = __commonJS({
|
|
|
88
88
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
|
|
89
89
|
module2.exports = isexe;
|
|
90
90
|
isexe.sync = sync;
|
|
91
|
-
var
|
|
91
|
+
var fs18 = require("fs");
|
|
92
92
|
function isexe(path, options, cb) {
|
|
93
|
-
|
|
93
|
+
fs18.stat(path, function(er, stat) {
|
|
94
94
|
cb(er, er ? false : checkStat(stat, options));
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
function sync(path, options) {
|
|
98
|
-
return checkStat(
|
|
98
|
+
return checkStat(fs18.statSync(path), options);
|
|
99
99
|
}
|
|
100
100
|
function checkStat(stat, options) {
|
|
101
101
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
|
|
|
119
119
|
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
120
120
|
var require_isexe = __commonJS({
|
|
121
121
|
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
|
|
122
|
-
var
|
|
122
|
+
var fs18 = require("fs");
|
|
123
123
|
var core;
|
|
124
124
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
125
125
|
core = require_windows();
|
|
@@ -395,7 +395,7 @@ var require_shebang_command = __commonJS({
|
|
|
395
395
|
var require_readShebang = __commonJS({
|
|
396
396
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
|
|
397
397
|
"use strict";
|
|
398
|
-
var
|
|
398
|
+
var fs18 = require("fs");
|
|
399
399
|
var shebangCommand = require_shebang_command();
|
|
400
400
|
function readShebang(command) {
|
|
401
401
|
const size = 150;
|
|
@@ -408,9 +408,9 @@ var require_readShebang = __commonJS({
|
|
|
408
408
|
}
|
|
409
409
|
let fd;
|
|
410
410
|
try {
|
|
411
|
-
fd =
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
fd = fs18.openSync(command, "r");
|
|
412
|
+
fs18.readSync(fd, buffer, 0, size, 0);
|
|
413
|
+
fs18.closeSync(fd);
|
|
414
414
|
} catch (e) {
|
|
415
415
|
}
|
|
416
416
|
return shebangCommand(buffer.toString());
|
|
@@ -423,15 +423,15 @@ var require_readShebang = __commonJS({
|
|
|
423
423
|
var require_semver = __commonJS({
|
|
424
424
|
"../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js"(exports, module2) {
|
|
425
425
|
exports = module2.exports = SemVer;
|
|
426
|
-
var
|
|
426
|
+
var debug15;
|
|
427
427
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
428
|
-
|
|
428
|
+
debug15 = 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
|
+
debug15 = 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
|
+
debug15(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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("hyphen replace", range);
|
|
1054
1054
|
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
|
|
1055
|
-
|
|
1055
|
+
debug15("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
|
+
debug15("comp", comp, options);
|
|
1096
1096
|
comp = replaceCarets(comp, options);
|
|
1097
|
-
|
|
1097
|
+
debug15("caret", comp);
|
|
1098
1098
|
comp = replaceTildes(comp, options);
|
|
1099
|
-
|
|
1099
|
+
debug15("tildes", comp);
|
|
1100
1100
|
comp = replaceXRanges(comp, options);
|
|
1101
|
-
|
|
1101
|
+
debug15("xrange", comp);
|
|
1102
1102
|
comp = replaceStars(comp, options);
|
|
1103
|
-
|
|
1103
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("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
|
+
debug15("caret return", ret);
|
|
1180
1180
|
return ret;
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
function replaceXRanges(comp, options) {
|
|
1184
|
-
|
|
1184
|
+
debug15("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
|
+
debug15("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
|
+
debug15("xRange return", ret);
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
function replaceStars(comp, options) {
|
|
1241
|
-
|
|
1241
|
+
debug15("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
|
+
debug15(set[i2].semver);
|
|
1290
1290
|
if (set[i2].semver === ANY) {
|
|
1291
1291
|
continue;
|
|
1292
1292
|
}
|
|
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
|
|
|
1895
1895
|
"../../node_modules/.pnpm/pump@3.0.4/node_modules/pump/index.js"(exports, module2) {
|
|
1896
1896
|
var once = require_once();
|
|
1897
1897
|
var eos = require_end_of_stream();
|
|
1898
|
-
var
|
|
1898
|
+
var fs18;
|
|
1899
1899
|
try {
|
|
1900
|
-
|
|
1900
|
+
fs18 = require("fs");
|
|
1901
1901
|
} catch (e) {
|
|
1902
1902
|
}
|
|
1903
1903
|
var noop = function() {
|
|
@@ -1909,9 +1909,9 @@ var require_pump = __commonJS({
|
|
|
1909
1909
|
var isFS = function(stream) {
|
|
1910
1910
|
if (!ancient)
|
|
1911
1911
|
return false;
|
|
1912
|
-
if (!
|
|
1912
|
+
if (!fs18)
|
|
1913
1913
|
return false;
|
|
1914
|
-
return (stream instanceof (
|
|
1914
|
+
return (stream instanceof (fs18.ReadStream || noop) || stream instanceof (fs18.WriteStream || noop)) && isFn(stream.close);
|
|
1915
1915
|
};
|
|
1916
1916
|
var isRequest = function(stream) {
|
|
1917
1917
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -2651,7 +2651,7 @@ ${stderr}${stdout}`;
|
|
|
2651
2651
|
var require_lib = __commonJS({
|
|
2652
2652
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
2653
2653
|
var isexe = require_isexe();
|
|
2654
|
-
var { join:
|
|
2654
|
+
var { join: join19, delimiter: delimiter2, sep: sep3, posix } = require("path");
|
|
2655
2655
|
var isWindows = process.platform === "win32";
|
|
2656
2656
|
var rSlash = new RegExp(`[${posix.sep}${sep3 === posix.sep ? "" : sep3}]`.replace(/(\\)/g, "\\$1"));
|
|
2657
2657
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -2680,7 +2680,7 @@ var require_lib = __commonJS({
|
|
|
2680
2680
|
var getPathPart = (raw, cmd) => {
|
|
2681
2681
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2682
2682
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2683
|
-
return prefix +
|
|
2683
|
+
return prefix + join19(pathPart, cmd);
|
|
2684
2684
|
};
|
|
2685
2685
|
var which2 = async (cmd, opt = {}) => {
|
|
2686
2686
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -2739,15 +2739,15 @@ var require_lib = __commonJS({
|
|
|
2739
2739
|
var require_semver2 = __commonJS({
|
|
2740
2740
|
"../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
|
|
2741
2741
|
exports = module2.exports = SemVer;
|
|
2742
|
-
var
|
|
2742
|
+
var debug15;
|
|
2743
2743
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
2744
|
-
|
|
2744
|
+
debug15 = function() {
|
|
2745
2745
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
2746
2746
|
args.unshift("SEMVER");
|
|
2747
2747
|
console.log.apply(console, args);
|
|
2748
2748
|
};
|
|
2749
2749
|
} else {
|
|
2750
|
-
|
|
2750
|
+
debug15 = function() {
|
|
2751
2751
|
};
|
|
2752
2752
|
}
|
|
2753
2753
|
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
@@ -2865,7 +2865,7 @@ var require_semver2 = __commonJS({
|
|
|
2865
2865
|
tok("STAR");
|
|
2866
2866
|
src[t.STAR] = "(<|>)?=?\\s*\\*";
|
|
2867
2867
|
for (i = 0; i < R; i++) {
|
|
2868
|
-
|
|
2868
|
+
debug15(i, src[i]);
|
|
2869
2869
|
if (!re[i]) {
|
|
2870
2870
|
re[i] = new RegExp(src[i]);
|
|
2871
2871
|
safeRe[i] = new RegExp(makeSafeRe(src[i]));
|
|
@@ -2932,7 +2932,7 @@ var require_semver2 = __commonJS({
|
|
|
2932
2932
|
if (!(this instanceof SemVer)) {
|
|
2933
2933
|
return new SemVer(version2, options);
|
|
2934
2934
|
}
|
|
2935
|
-
|
|
2935
|
+
debug15("SemVer", version2, options);
|
|
2936
2936
|
this.options = options;
|
|
2937
2937
|
this.loose = !!options.loose;
|
|
2938
2938
|
var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
|
|
@@ -2979,7 +2979,7 @@ var require_semver2 = __commonJS({
|
|
|
2979
2979
|
return this.version;
|
|
2980
2980
|
};
|
|
2981
2981
|
SemVer.prototype.compare = function(other) {
|
|
2982
|
-
|
|
2982
|
+
debug15("SemVer.compare", this.version, this.options, other);
|
|
2983
2983
|
if (!(other instanceof SemVer)) {
|
|
2984
2984
|
other = new SemVer(other, this.options);
|
|
2985
2985
|
}
|
|
@@ -3006,7 +3006,7 @@ var require_semver2 = __commonJS({
|
|
|
3006
3006
|
do {
|
|
3007
3007
|
var a = this.prerelease[i2];
|
|
3008
3008
|
var b = other.prerelease[i2];
|
|
3009
|
-
|
|
3009
|
+
debug15("prerelease compare", i2, a, b);
|
|
3010
3010
|
if (a === void 0 && b === void 0) {
|
|
3011
3011
|
return 0;
|
|
3012
3012
|
} else if (b === void 0) {
|
|
@@ -3028,7 +3028,7 @@ var require_semver2 = __commonJS({
|
|
|
3028
3028
|
do {
|
|
3029
3029
|
var a = this.build[i2];
|
|
3030
3030
|
var b = other.build[i2];
|
|
3031
|
-
|
|
3031
|
+
debug15("prerelease compare", i2, a, b);
|
|
3032
3032
|
if (a === void 0 && b === void 0) {
|
|
3033
3033
|
return 0;
|
|
3034
3034
|
} else if (b === void 0) {
|
|
@@ -3288,7 +3288,7 @@ var require_semver2 = __commonJS({
|
|
|
3288
3288
|
return new Comparator(comp, options);
|
|
3289
3289
|
}
|
|
3290
3290
|
comp = comp.trim().split(/\s+/).join(" ");
|
|
3291
|
-
|
|
3291
|
+
debug15("comparator", comp, options);
|
|
3292
3292
|
this.options = options;
|
|
3293
3293
|
this.loose = !!options.loose;
|
|
3294
3294
|
this.parse(comp);
|
|
@@ -3297,7 +3297,7 @@ var require_semver2 = __commonJS({
|
|
|
3297
3297
|
} else {
|
|
3298
3298
|
this.value = this.operator + this.semver.version;
|
|
3299
3299
|
}
|
|
3300
|
-
|
|
3300
|
+
debug15("comp", this);
|
|
3301
3301
|
}
|
|
3302
3302
|
var ANY = {};
|
|
3303
3303
|
Comparator.prototype.parse = function(comp) {
|
|
@@ -3320,7 +3320,7 @@ var require_semver2 = __commonJS({
|
|
|
3320
3320
|
return this.value;
|
|
3321
3321
|
};
|
|
3322
3322
|
Comparator.prototype.test = function(version2) {
|
|
3323
|
-
|
|
3323
|
+
debug15("Comparator.test", version2, this.options.loose);
|
|
3324
3324
|
if (this.semver === ANY || version2 === ANY) {
|
|
3325
3325
|
return true;
|
|
3326
3326
|
}
|
|
@@ -3413,9 +3413,9 @@ var require_semver2 = __commonJS({
|
|
|
3413
3413
|
var loose = this.options.loose;
|
|
3414
3414
|
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
|
|
3415
3415
|
range = range.replace(hr, hyphenReplace);
|
|
3416
|
-
|
|
3416
|
+
debug15("hyphen replace", range);
|
|
3417
3417
|
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
3418
|
-
|
|
3418
|
+
debug15("comparator trim", range, safeRe[t.COMPARATORTRIM]);
|
|
3419
3419
|
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
|
|
3420
3420
|
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
|
|
3421
3421
|
range = range.split(/\s+/).join(" ");
|
|
@@ -3468,15 +3468,15 @@ var require_semver2 = __commonJS({
|
|
|
3468
3468
|
});
|
|
3469
3469
|
}
|
|
3470
3470
|
function parseComparator(comp, options) {
|
|
3471
|
-
|
|
3471
|
+
debug15("comp", comp, options);
|
|
3472
3472
|
comp = replaceCarets(comp, options);
|
|
3473
|
-
|
|
3473
|
+
debug15("caret", comp);
|
|
3474
3474
|
comp = replaceTildes(comp, options);
|
|
3475
|
-
|
|
3475
|
+
debug15("tildes", comp);
|
|
3476
3476
|
comp = replaceXRanges(comp, options);
|
|
3477
|
-
|
|
3477
|
+
debug15("xrange", comp);
|
|
3478
3478
|
comp = replaceStars(comp, options);
|
|
3479
|
-
|
|
3479
|
+
debug15("stars", comp);
|
|
3480
3480
|
return comp;
|
|
3481
3481
|
}
|
|
3482
3482
|
function isX(id) {
|
|
@@ -3490,7 +3490,7 @@ var require_semver2 = __commonJS({
|
|
|
3490
3490
|
function replaceTilde(comp, options) {
|
|
3491
3491
|
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
|
|
3492
3492
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
3493
|
-
|
|
3493
|
+
debug15("tilde", comp, _, M, m, p, pr);
|
|
3494
3494
|
var ret;
|
|
3495
3495
|
if (isX(M)) {
|
|
3496
3496
|
ret = "";
|
|
@@ -3499,12 +3499,12 @@ var require_semver2 = __commonJS({
|
|
|
3499
3499
|
} else if (isX(p)) {
|
|
3500
3500
|
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
|
|
3501
3501
|
} else if (pr) {
|
|
3502
|
-
|
|
3502
|
+
debug15("replaceTilde pr", pr);
|
|
3503
3503
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
|
|
3504
3504
|
} else {
|
|
3505
3505
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
|
|
3506
3506
|
}
|
|
3507
|
-
|
|
3507
|
+
debug15("tilde return", ret);
|
|
3508
3508
|
return ret;
|
|
3509
3509
|
});
|
|
3510
3510
|
}
|
|
@@ -3514,10 +3514,10 @@ var require_semver2 = __commonJS({
|
|
|
3514
3514
|
}).join(" ");
|
|
3515
3515
|
}
|
|
3516
3516
|
function replaceCaret(comp, options) {
|
|
3517
|
-
|
|
3517
|
+
debug15("caret", comp, options);
|
|
3518
3518
|
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
|
|
3519
3519
|
return comp.replace(r, function(_, M, m, p, pr) {
|
|
3520
|
-
|
|
3520
|
+
debug15("caret", comp, _, M, m, p, pr);
|
|
3521
3521
|
var ret;
|
|
3522
3522
|
if (isX(M)) {
|
|
3523
3523
|
ret = "";
|
|
@@ -3530,7 +3530,7 @@ var require_semver2 = __commonJS({
|
|
|
3530
3530
|
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
|
|
3531
3531
|
}
|
|
3532
3532
|
} else if (pr) {
|
|
3533
|
-
|
|
3533
|
+
debug15("replaceCaret pr", pr);
|
|
3534
3534
|
if (M === "0") {
|
|
3535
3535
|
if (m === "0") {
|
|
3536
3536
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -3541,7 +3541,7 @@ var require_semver2 = __commonJS({
|
|
|
3541
3541
|
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
|
|
3542
3542
|
}
|
|
3543
3543
|
} else {
|
|
3544
|
-
|
|
3544
|
+
debug15("no pr");
|
|
3545
3545
|
if (M === "0") {
|
|
3546
3546
|
if (m === "0") {
|
|
3547
3547
|
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
|
|
@@ -3552,12 +3552,12 @@ var require_semver2 = __commonJS({
|
|
|
3552
3552
|
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
|
|
3553
3553
|
}
|
|
3554
3554
|
}
|
|
3555
|
-
|
|
3555
|
+
debug15("caret return", ret);
|
|
3556
3556
|
return ret;
|
|
3557
3557
|
});
|
|
3558
3558
|
}
|
|
3559
3559
|
function replaceXRanges(comp, options) {
|
|
3560
|
-
|
|
3560
|
+
debug15("replaceXRanges", comp, options);
|
|
3561
3561
|
return comp.split(/\s+/).map(function(comp2) {
|
|
3562
3562
|
return replaceXRange(comp2, options);
|
|
3563
3563
|
}).join(" ");
|
|
@@ -3566,7 +3566,7 @@ var require_semver2 = __commonJS({
|
|
|
3566
3566
|
comp = comp.trim();
|
|
3567
3567
|
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
|
|
3568
3568
|
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
|
|
3569
|
-
|
|
3569
|
+
debug15("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
3570
3570
|
var xM = isX(M);
|
|
3571
3571
|
var xm = xM || isX(m);
|
|
3572
3572
|
var xp = xm || isX(p);
|
|
@@ -3610,12 +3610,12 @@ var require_semver2 = __commonJS({
|
|
|
3610
3610
|
} else if (xp) {
|
|
3611
3611
|
ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
|
|
3612
3612
|
}
|
|
3613
|
-
|
|
3613
|
+
debug15("xRange return", ret);
|
|
3614
3614
|
return ret;
|
|
3615
3615
|
});
|
|
3616
3616
|
}
|
|
3617
3617
|
function replaceStars(comp, options) {
|
|
3618
|
-
|
|
3618
|
+
debug15("replaceStars", comp, options);
|
|
3619
3619
|
return comp.trim().replace(safeRe[t.STAR], "");
|
|
3620
3620
|
}
|
|
3621
3621
|
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
|
|
@@ -3667,7 +3667,7 @@ var require_semver2 = __commonJS({
|
|
|
3667
3667
|
}
|
|
3668
3668
|
if (version2.prerelease.length && !options.includePrerelease) {
|
|
3669
3669
|
for (i2 = 0; i2 < set.length; i2++) {
|
|
3670
|
-
|
|
3670
|
+
debug15(set[i2].semver);
|
|
3671
3671
|
if (set[i2].semver === ANY) {
|
|
3672
3672
|
continue;
|
|
3673
3673
|
}
|
|
@@ -3912,27 +3912,27 @@ var require_process = __commonJS({
|
|
|
3912
3912
|
var require_filesystem = __commonJS({
|
|
3913
3913
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
|
|
3914
3914
|
"use strict";
|
|
3915
|
-
var
|
|
3915
|
+
var fs18 = require("fs");
|
|
3916
3916
|
var LDD_PATH = "/usr/bin/ldd";
|
|
3917
3917
|
var SELF_PATH = "/proc/self/exe";
|
|
3918
3918
|
var MAX_LENGTH = 2048;
|
|
3919
3919
|
var readFileSync2 = (path) => {
|
|
3920
|
-
const fd =
|
|
3920
|
+
const fd = fs18.openSync(path, "r");
|
|
3921
3921
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3922
|
-
const bytesRead =
|
|
3923
|
-
|
|
3922
|
+
const bytesRead = fs18.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
3923
|
+
fs18.close(fd, () => {
|
|
3924
3924
|
});
|
|
3925
3925
|
return buffer.subarray(0, bytesRead);
|
|
3926
3926
|
};
|
|
3927
3927
|
var readFile2 = (path) => new Promise((resolve3, reject) => {
|
|
3928
|
-
|
|
3928
|
+
fs18.open(path, "r", (err, fd) => {
|
|
3929
3929
|
if (err) {
|
|
3930
3930
|
reject(err);
|
|
3931
3931
|
} else {
|
|
3932
3932
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
3933
|
-
|
|
3933
|
+
fs18.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
3934
3934
|
resolve3(buffer.subarray(0, bytesRead));
|
|
3935
|
-
|
|
3935
|
+
fs18.close(fd, () => {
|
|
3936
3936
|
});
|
|
3937
3937
|
});
|
|
3938
3938
|
}
|
|
@@ -4379,15 +4379,15 @@ __export(src_exports, {
|
|
|
4379
4379
|
});
|
|
4380
4380
|
module.exports = __toCommonJS(src_exports);
|
|
4381
4381
|
var import_assert = __toESM(require("assert"));
|
|
4382
|
-
var
|
|
4383
|
-
var
|
|
4382
|
+
var import_fs19 = __toESM(require("fs"));
|
|
4383
|
+
var import_path19 = require("path");
|
|
4384
4384
|
|
|
4385
4385
|
// src/package-versions.ts
|
|
4386
4386
|
var VERCEL_RUNTIME_VERSION = "0.16.0";
|
|
4387
4387
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
4388
4388
|
|
|
4389
4389
|
// src/index.ts
|
|
4390
|
-
var
|
|
4390
|
+
var import_build_utils22 = require("@vercel/build-utils");
|
|
4391
4391
|
|
|
4392
4392
|
// src/install.ts
|
|
4393
4393
|
var import_execa3 = __toESM(require_execa());
|
|
@@ -8354,14 +8354,91 @@ async function runDjangoCollectStatic(venvPath, workPath, djangoPath, env, outpu
|
|
|
8354
8354
|
};
|
|
8355
8355
|
}
|
|
8356
8356
|
|
|
8357
|
+
// src/fastapi.ts
|
|
8358
|
+
var import_fs13 = __toESM(require("fs"));
|
|
8359
|
+
var import_path13 = require("path");
|
|
8360
|
+
var import_execa7 = __toESM(require_execa());
|
|
8361
|
+
var import_build_utils17 = require("@vercel/build-utils");
|
|
8362
|
+
var scriptPath3 = (0, import_path13.join)(__dirname, "..", "templates", "vc_fastapi_static.py");
|
|
8363
|
+
var _STATIC_FILE_COLLECTION_ERROR_MESSAGE = "Warning: FastAPI static file collection failed. Static files will not be served from the CDN.";
|
|
8364
|
+
async function getFastAPIStaticMounts(venvPath, entrypointAbs, variableName, env, workPath) {
|
|
8365
|
+
const pythonPath = getVenvPythonBin(venvPath);
|
|
8366
|
+
const outputPath = (0, import_path13.join)(
|
|
8367
|
+
workPath,
|
|
8368
|
+
".vercel",
|
|
8369
|
+
"python",
|
|
8370
|
+
"vc_fastapi_static_output.json"
|
|
8371
|
+
);
|
|
8372
|
+
await import_fs13.default.promises.mkdir((0, import_path13.join)(workPath, ".vercel", "python"), {
|
|
8373
|
+
recursive: true
|
|
8374
|
+
});
|
|
8375
|
+
try {
|
|
8376
|
+
const { stderr } = await (0, import_execa7.default)(
|
|
8377
|
+
pythonPath,
|
|
8378
|
+
[scriptPath3, entrypointAbs, variableName, outputPath],
|
|
8379
|
+
{ env, cwd: workPath }
|
|
8380
|
+
);
|
|
8381
|
+
if (stderr) {
|
|
8382
|
+
(0, import_build_utils17.debug)(`FastAPI shim stderr:
|
|
8383
|
+
${stderr}`);
|
|
8384
|
+
}
|
|
8385
|
+
} catch (err) {
|
|
8386
|
+
console.error(_STATIC_FILE_COLLECTION_ERROR_MESSAGE);
|
|
8387
|
+
(0, import_build_utils17.debug)(
|
|
8388
|
+
`FastAPI: could not discover static mounts: ${err?.stderr ?? err?.message ?? err}`
|
|
8389
|
+
);
|
|
8390
|
+
return [];
|
|
8391
|
+
}
|
|
8392
|
+
try {
|
|
8393
|
+
const raw = await import_fs13.default.promises.readFile(outputPath, "utf8");
|
|
8394
|
+
const parsed = JSON.parse(raw);
|
|
8395
|
+
(0, import_build_utils17.debug)(`FastAPI: discovered mounts: ${JSON.stringify(parsed)}`);
|
|
8396
|
+
return parsed;
|
|
8397
|
+
} catch {
|
|
8398
|
+
console.error(_STATIC_FILE_COLLECTION_ERROR_MESSAGE);
|
|
8399
|
+
(0, import_build_utils17.debug)(`FastAPI: could not read shim output file: ${outputPath}`);
|
|
8400
|
+
return [];
|
|
8401
|
+
} finally {
|
|
8402
|
+
await import_fs13.default.promises.rm(outputPath, { force: true });
|
|
8403
|
+
}
|
|
8404
|
+
}
|
|
8405
|
+
async function runFastAPICollectStatic(venvPath, workPath, env, outputStaticDir, entrypointAbs, variableName) {
|
|
8406
|
+
const mounts = await getFastAPIStaticMounts(
|
|
8407
|
+
venvPath,
|
|
8408
|
+
entrypointAbs,
|
|
8409
|
+
variableName,
|
|
8410
|
+
env,
|
|
8411
|
+
workPath
|
|
8412
|
+
);
|
|
8413
|
+
if (mounts.length === 0) {
|
|
8414
|
+
(0, import_build_utils17.debug)("FastAPI: no StaticFiles mounts found, skipping");
|
|
8415
|
+
return null;
|
|
8416
|
+
}
|
|
8417
|
+
(0, import_build_utils17.debug)(
|
|
8418
|
+
`Found ${mounts.length} FastAPI static mount(s): ${mounts.map((m) => m.urlPath).join(", ")}`
|
|
8419
|
+
);
|
|
8420
|
+
for (const mount of mounts) {
|
|
8421
|
+
const urlSubPath = mount.urlPath.replace(/^\/|\/$/g, "");
|
|
8422
|
+
const dest = (0, import_path13.join)(outputStaticDir, urlSubPath);
|
|
8423
|
+
await import_fs13.default.promises.mkdir(dest, { recursive: true });
|
|
8424
|
+
await import_fs13.default.promises.cp(mount.directory, dest, { recursive: true });
|
|
8425
|
+
(0, import_build_utils17.debug)(`copied ${mount.directory} -> ${dest}`);
|
|
8426
|
+
}
|
|
8427
|
+
return {
|
|
8428
|
+
collectedMounts: mounts.map((m) => m.urlPath),
|
|
8429
|
+
cdnOutputDir: outputStaticDir
|
|
8430
|
+
};
|
|
8431
|
+
}
|
|
8432
|
+
|
|
8357
8433
|
// src/index.ts
|
|
8358
8434
|
var import_python_analysis10 = require("@vercel/python-analysis");
|
|
8359
8435
|
|
|
8360
8436
|
// src/compileall.ts
|
|
8361
|
-
var
|
|
8362
|
-
var
|
|
8363
|
-
var
|
|
8364
|
-
var
|
|
8437
|
+
var import_execa8 = __toESM(require_execa());
|
|
8438
|
+
var import_build_utils18 = require("@vercel/build-utils");
|
|
8439
|
+
var import_fs14 = __toESM(require("fs"));
|
|
8440
|
+
var import_os3 = require("os");
|
|
8441
|
+
var import_path14 = require("path");
|
|
8365
8442
|
var COMPILEALL_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
8366
8443
|
var PYCACHE_PREFIX_DIR = "_vc_pycache";
|
|
8367
8444
|
var RUNTIME_PYCACHE_PREFIX = `/var/task/${PYCACHE_PREFIX_DIR}`;
|
|
@@ -8387,34 +8464,40 @@ function shouldCompileAll({
|
|
|
8387
8464
|
}
|
|
8388
8465
|
async function runCompileAll({
|
|
8389
8466
|
pythonBin,
|
|
8390
|
-
|
|
8467
|
+
sourceFiles,
|
|
8391
8468
|
env,
|
|
8392
|
-
excludeRegex,
|
|
8393
8469
|
pycachePrefix
|
|
8394
8470
|
}) {
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
"-q",
|
|
8401
|
-
"-j",
|
|
8402
|
-
"0",
|
|
8403
|
-
"-f",
|
|
8404
|
-
"--invalidation-mode",
|
|
8405
|
-
"unchecked-hash",
|
|
8406
|
-
...excludeRegex ? ["-x", excludeRegex] : [],
|
|
8407
|
-
...filesOrDirectories
|
|
8408
|
-
];
|
|
8409
|
-
const baseEnv = env || process.env;
|
|
8410
|
-
const subprocessEnv = pycachePrefix ? { ...baseEnv, PYTHONPYCACHEPREFIX: pycachePrefix } : baseEnv;
|
|
8471
|
+
const uniqueSourceFiles = [...new Set(sourceFiles)];
|
|
8472
|
+
if (uniqueSourceFiles.length === 0) {
|
|
8473
|
+
return false;
|
|
8474
|
+
}
|
|
8475
|
+
let tempDir;
|
|
8411
8476
|
try {
|
|
8412
|
-
await
|
|
8477
|
+
tempDir = await import_fs14.default.promises.mkdtemp(
|
|
8478
|
+
(0, import_path14.join)((0, import_os3.tmpdir)(), "vercel-python-compileall-")
|
|
8479
|
+
);
|
|
8480
|
+
const listPath = (0, import_path14.join)(tempDir, "pysources.json");
|
|
8481
|
+
await import_fs14.default.promises.writeFile(listPath, JSON.stringify(uniqueSourceFiles));
|
|
8482
|
+
const scriptPath4 = (0, import_path14.join)(__dirname, "..", "templates", "vc_compileall.py");
|
|
8483
|
+
const baseEnv = env || process.env;
|
|
8484
|
+
const subprocessEnv = pycachePrefix ? { ...baseEnv, PYTHONPYCACHEPREFIX: pycachePrefix } : baseEnv;
|
|
8485
|
+
await (0, import_execa8.default)(pythonBin, [scriptPath4, listPath], {
|
|
8413
8486
|
env: subprocessEnv,
|
|
8414
8487
|
timeout: COMPILEALL_TIMEOUT_MS
|
|
8415
8488
|
});
|
|
8489
|
+
return true;
|
|
8416
8490
|
} catch (err) {
|
|
8417
|
-
(0,
|
|
8491
|
+
(0, import_build_utils18.debug)(`compileall error details: ${JSON.stringify(err)}`);
|
|
8492
|
+
return false;
|
|
8493
|
+
} finally {
|
|
8494
|
+
if (tempDir) {
|
|
8495
|
+
try {
|
|
8496
|
+
await import_fs14.default.promises.rm(tempDir, { recursive: true, force: true });
|
|
8497
|
+
} catch (err) {
|
|
8498
|
+
(0, import_build_utils18.debug)(`compileall temporary file cleanup error: ${String(err)}`);
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8418
8501
|
}
|
|
8419
8502
|
}
|
|
8420
8503
|
function derivePycPath(pyRelPath, pythonMajor, pythonMinor) {
|
|
@@ -8449,7 +8532,7 @@ function deriveStagedPycFsPath(stagingDir, srcAbsPath, pythonMajor, pythonMinor)
|
|
|
8449
8532
|
);
|
|
8450
8533
|
if (!rel)
|
|
8451
8534
|
return null;
|
|
8452
|
-
return (0,
|
|
8535
|
+
return (0, import_path14.join)(stagingDir, rel.replaceAll("/", import_path14.sep));
|
|
8453
8536
|
}
|
|
8454
8537
|
function derivePrefixPycBundlePath(runtimeAbsPath, pythonMajor, pythonMinor) {
|
|
8455
8538
|
const rel = derivePrefixPycRelPath(
|
|
@@ -8461,27 +8544,6 @@ function derivePrefixPycBundlePath(runtimeAbsPath, pythonMajor, pythonMinor) {
|
|
|
8461
8544
|
return null;
|
|
8462
8545
|
return `${PYCACHE_PREFIX_DIR}/${rel}`;
|
|
8463
8546
|
}
|
|
8464
|
-
var COMPILEALL_APP_EXCLUDED_DIRS = [
|
|
8465
|
-
".git",
|
|
8466
|
-
".vercel",
|
|
8467
|
-
".pnpm-store",
|
|
8468
|
-
"node_modules",
|
|
8469
|
-
".next",
|
|
8470
|
-
".nuxt",
|
|
8471
|
-
".venv",
|
|
8472
|
-
"venv",
|
|
8473
|
-
"__pycache__",
|
|
8474
|
-
".mypy_cache",
|
|
8475
|
-
".ruff_cache",
|
|
8476
|
-
"public"
|
|
8477
|
-
];
|
|
8478
|
-
function escapePythonRegex(value) {
|
|
8479
|
-
return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
8480
|
-
}
|
|
8481
|
-
function getCompileAllAppExcludeRegex(workPath) {
|
|
8482
|
-
const excludedDirs = COMPILEALL_APP_EXCLUDED_DIRS.map(escapePythonRegex).join("|");
|
|
8483
|
-
return `${escapePythonRegex(workPath)}[/\\\\](?:${excludedDirs})(?:[/\\\\]|$)`;
|
|
8484
|
-
}
|
|
8485
8547
|
async function collectAppPrefixBytecodeFiles({
|
|
8486
8548
|
stagingDir,
|
|
8487
8549
|
workPath,
|
|
@@ -8496,7 +8558,7 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
8496
8558
|
continue;
|
|
8497
8559
|
const stagedFsPath = deriveStagedPycFsPath(
|
|
8498
8560
|
stagingDir,
|
|
8499
|
-
(0,
|
|
8561
|
+
(0, import_path14.join)(workPath, bundlePath.replaceAll("/", import_path14.sep)),
|
|
8500
8562
|
pythonMajor,
|
|
8501
8563
|
pythonMinor
|
|
8502
8564
|
);
|
|
@@ -8512,7 +8574,7 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
8512
8574
|
const results = await Promise.all(
|
|
8513
8575
|
pending.map(async ({ bundlePath, srcFsPath }) => {
|
|
8514
8576
|
try {
|
|
8515
|
-
const stats = await
|
|
8577
|
+
const stats = await import_fs14.default.promises.stat(srcFsPath);
|
|
8516
8578
|
return { bundlePath, srcFsPath, size: stats.size };
|
|
8517
8579
|
} catch {
|
|
8518
8580
|
return null;
|
|
@@ -8525,7 +8587,7 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
8525
8587
|
for (const result of results) {
|
|
8526
8588
|
if (!result)
|
|
8527
8589
|
continue;
|
|
8528
|
-
files[result.bundlePath] = new
|
|
8590
|
+
files[result.bundlePath] = new import_build_utils18.FileFsRef({
|
|
8529
8591
|
fsPath: result.srcFsPath,
|
|
8530
8592
|
size: result.size
|
|
8531
8593
|
});
|
|
@@ -8547,13 +8609,13 @@ async function collectAppBytecodeFiles({
|
|
|
8547
8609
|
continue;
|
|
8548
8610
|
pending.push({
|
|
8549
8611
|
bundlePath: pycRel,
|
|
8550
|
-
srcFsPath: (0,
|
|
8612
|
+
srcFsPath: (0, import_path14.join)(workPath, pycRel.replaceAll("/", import_path14.sep))
|
|
8551
8613
|
});
|
|
8552
8614
|
}
|
|
8553
8615
|
const results = await Promise.all(
|
|
8554
8616
|
pending.map(async ({ bundlePath, srcFsPath }) => {
|
|
8555
8617
|
try {
|
|
8556
|
-
const stats = await
|
|
8618
|
+
const stats = await import_fs14.default.promises.stat(srcFsPath);
|
|
8557
8619
|
return { bundlePath, srcFsPath, size: stats.size };
|
|
8558
8620
|
} catch {
|
|
8559
8621
|
return null;
|
|
@@ -8566,7 +8628,7 @@ async function collectAppBytecodeFiles({
|
|
|
8566
8628
|
for (const result of results) {
|
|
8567
8629
|
if (!result)
|
|
8568
8630
|
continue;
|
|
8569
|
-
files[result.bundlePath] = new
|
|
8631
|
+
files[result.bundlePath] = new import_build_utils18.FileFsRef({
|
|
8570
8632
|
fsPath: result.srcFsPath,
|
|
8571
8633
|
size: result.size
|
|
8572
8634
|
});
|
|
@@ -8577,9 +8639,9 @@ async function collectAppBytecodeFiles({
|
|
|
8577
8639
|
}
|
|
8578
8640
|
|
|
8579
8641
|
// src/installed-distributions.ts
|
|
8580
|
-
var
|
|
8581
|
-
var
|
|
8582
|
-
var
|
|
8642
|
+
var import_fs15 = __toESM(require("fs"));
|
|
8643
|
+
var import_path15 = require("path");
|
|
8644
|
+
var import_build_utils19 = require("@vercel/build-utils");
|
|
8583
8645
|
var import_python_analysis9 = require("@vercel/python-analysis");
|
|
8584
8646
|
var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
8585
8647
|
"py.typed",
|
|
@@ -8588,7 +8650,7 @@ var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
|
8588
8650
|
"direct_url.json"
|
|
8589
8651
|
]);
|
|
8590
8652
|
function shouldStripVendorFile(filePath) {
|
|
8591
|
-
const segments = filePath.split(
|
|
8653
|
+
const segments = filePath.split(import_path15.sep);
|
|
8592
8654
|
if (segments.includes("__pycache__"))
|
|
8593
8655
|
return true;
|
|
8594
8656
|
const name = segments[segments.length - 1] ?? "";
|
|
@@ -8612,19 +8674,19 @@ function getDistributionFileGroups({
|
|
|
8612
8674
|
const dirDistributions = distributions.get(dir);
|
|
8613
8675
|
if (!dirDistributions)
|
|
8614
8676
|
continue;
|
|
8615
|
-
const sitePackagesDir = (0,
|
|
8677
|
+
const sitePackagesDir = (0, import_path15.resolve)(dir);
|
|
8616
8678
|
for (const [name, distribution] of dirDistributions) {
|
|
8617
8679
|
const packageName = (0, import_python_analysis9.normalizePackageName)(name);
|
|
8618
8680
|
if (includeSet && !includeSet.has(packageName))
|
|
8619
8681
|
continue;
|
|
8620
8682
|
const files = [];
|
|
8621
8683
|
for (const record of distribution.files) {
|
|
8622
|
-
const absolutePath = (0,
|
|
8684
|
+
const absolutePath = (0, import_path15.resolve)(
|
|
8623
8685
|
sitePackagesDir,
|
|
8624
|
-
record.path.replaceAll("/",
|
|
8686
|
+
record.path.replaceAll("/", import_path15.sep)
|
|
8625
8687
|
);
|
|
8626
|
-
const relativePath = (0,
|
|
8627
|
-
if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${
|
|
8688
|
+
const relativePath = (0, import_path15.relative)(sitePackagesDir, absolutePath);
|
|
8689
|
+
if (relativePath === "" || relativePath === ".." || relativePath.startsWith(`..${import_path15.sep}`) || (0, import_path15.isAbsolute)(relativePath)) {
|
|
8628
8690
|
continue;
|
|
8629
8691
|
}
|
|
8630
8692
|
files.push({ absolutePath, relativePath, record });
|
|
@@ -8644,7 +8706,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8644
8706
|
const distributions = /* @__PURE__ */ new Map();
|
|
8645
8707
|
for (const dir of sitePackageDirs) {
|
|
8646
8708
|
try {
|
|
8647
|
-
await
|
|
8709
|
+
await import_fs15.default.promises.access(dir);
|
|
8648
8710
|
} catch {
|
|
8649
8711
|
continue;
|
|
8650
8712
|
}
|
|
@@ -8678,7 +8740,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8678
8740
|
if (shouldStripVendorFile(relativePath))
|
|
8679
8741
|
continue;
|
|
8680
8742
|
pending.push({
|
|
8681
|
-
bundlePath: (0,
|
|
8743
|
+
bundlePath: (0, import_path15.join)(vendorDirName, relativePath).replace(/\\/g, "/"),
|
|
8682
8744
|
srcFsPath: absolutePath,
|
|
8683
8745
|
recordSize: record.size != null ? Number(record.size) : void 0
|
|
8684
8746
|
});
|
|
@@ -8688,10 +8750,10 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8688
8750
|
pending.map(async ({ bundlePath, srcFsPath, recordSize }) => {
|
|
8689
8751
|
try {
|
|
8690
8752
|
if (recordSize === void 0) {
|
|
8691
|
-
const stats = await
|
|
8753
|
+
const stats = await import_fs15.default.promises.stat(srcFsPath);
|
|
8692
8754
|
return { bundlePath, srcFsPath, size: stats.size };
|
|
8693
8755
|
}
|
|
8694
|
-
await
|
|
8756
|
+
await import_fs15.default.promises.access(srcFsPath);
|
|
8695
8757
|
return { bundlePath, srcFsPath, size: recordSize };
|
|
8696
8758
|
} catch {
|
|
8697
8759
|
return null;
|
|
@@ -8702,12 +8764,12 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8702
8764
|
for (const result of results) {
|
|
8703
8765
|
if (!result)
|
|
8704
8766
|
continue;
|
|
8705
|
-
vendorFiles[result.bundlePath] = new
|
|
8767
|
+
vendorFiles[result.bundlePath] = new import_build_utils19.FileFsRef({
|
|
8706
8768
|
fsPath: result.srcFsPath,
|
|
8707
8769
|
size: result.size
|
|
8708
8770
|
});
|
|
8709
8771
|
}
|
|
8710
|
-
(0,
|
|
8772
|
+
(0, import_build_utils19.debug)(
|
|
8711
8773
|
`Mirrored ${Object.keys(vendorFiles).length} files` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
8712
8774
|
);
|
|
8713
8775
|
return vendorFiles;
|
|
@@ -8728,7 +8790,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8728
8790
|
knownSize += Number(record.size);
|
|
8729
8791
|
} else {
|
|
8730
8792
|
statPromises.push(
|
|
8731
|
-
|
|
8793
|
+
import_fs15.default.promises.stat(absolutePath).then((stats) => stats.size).catch(() => 0)
|
|
8732
8794
|
);
|
|
8733
8795
|
}
|
|
8734
8796
|
}
|
|
@@ -8740,6 +8802,22 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8740
8802
|
}
|
|
8741
8803
|
return sizes;
|
|
8742
8804
|
}
|
|
8805
|
+
getPythonSourceFiles(includePackages) {
|
|
8806
|
+
const sourceFiles = /* @__PURE__ */ new Set();
|
|
8807
|
+
const distributionGroups = getDistributionFileGroups({
|
|
8808
|
+
sitePackageDirs: this.sitePackageDirs,
|
|
8809
|
+
distributions: this.distributions,
|
|
8810
|
+
includePackages
|
|
8811
|
+
});
|
|
8812
|
+
for (const { files } of distributionGroups) {
|
|
8813
|
+
for (const { absolutePath, relativePath } of files) {
|
|
8814
|
+
if (relativePath.endsWith(".py")) {
|
|
8815
|
+
sourceFiles.add(absolutePath);
|
|
8816
|
+
}
|
|
8817
|
+
}
|
|
8818
|
+
}
|
|
8819
|
+
return [...sourceFiles].sort();
|
|
8820
|
+
}
|
|
8743
8821
|
async collectBytecodeFiles({
|
|
8744
8822
|
vendorDirName,
|
|
8745
8823
|
includePackages
|
|
@@ -8756,22 +8834,22 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8756
8834
|
for (const { packageName, sitePackagesDir, files } of distributionGroups) {
|
|
8757
8835
|
for (const { relativePath } of files) {
|
|
8758
8836
|
const pycRelativePath = derivePycPath(
|
|
8759
|
-
relativePath.replaceAll(
|
|
8837
|
+
relativePath.replaceAll(import_path15.sep, "/"),
|
|
8760
8838
|
this.pythonMajor,
|
|
8761
8839
|
this.pythonMinor
|
|
8762
8840
|
);
|
|
8763
8841
|
if (!pycRelativePath)
|
|
8764
8842
|
continue;
|
|
8765
|
-
const pycFilePath = pycRelativePath.replaceAll("/",
|
|
8843
|
+
const pycFilePath = pycRelativePath.replaceAll("/", import_path15.sep);
|
|
8766
8844
|
pending.push({
|
|
8767
|
-
bundlePath: (0,
|
|
8768
|
-
srcFsPath: (0,
|
|
8845
|
+
bundlePath: (0, import_path15.join)(vendorDirName, pycFilePath).replace(/\\/g, "/"),
|
|
8846
|
+
srcFsPath: (0, import_path15.join)(sitePackagesDir, pycFilePath),
|
|
8769
8847
|
packageName
|
|
8770
8848
|
});
|
|
8771
8849
|
}
|
|
8772
8850
|
}
|
|
8773
8851
|
const result = await this.collectExistingBytecode(pending);
|
|
8774
|
-
(0,
|
|
8852
|
+
(0, import_build_utils19.debug)(
|
|
8775
8853
|
`Collected ${Object.keys(result.files).length} bytecode files (${(result.totalSize / (1024 * 1024)).toFixed(2)} MB)` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
8776
8854
|
);
|
|
8777
8855
|
return result;
|
|
@@ -8794,7 +8872,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8794
8872
|
for (const { absolutePath, relativePath } of files) {
|
|
8795
8873
|
if (!relativePath.endsWith(".py"))
|
|
8796
8874
|
continue;
|
|
8797
|
-
const recordPath = relativePath.replaceAll(
|
|
8875
|
+
const recordPath = relativePath.replaceAll(import_path15.sep, "/");
|
|
8798
8876
|
const srcFsPath = deriveStagedPycFsPath(
|
|
8799
8877
|
stagingDir,
|
|
8800
8878
|
absolutePath,
|
|
@@ -8812,7 +8890,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8812
8890
|
}
|
|
8813
8891
|
}
|
|
8814
8892
|
const result = await this.collectExistingBytecode(pending);
|
|
8815
|
-
(0,
|
|
8893
|
+
(0, import_build_utils19.debug)(
|
|
8816
8894
|
`Collected ${Object.keys(result.files).length} prefix bytecode files (${(result.totalSize / (1024 * 1024)).toFixed(2)} MB) for runtime root ${runtimeRoot}` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
8817
8895
|
);
|
|
8818
8896
|
return result;
|
|
@@ -8821,7 +8899,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8821
8899
|
const results = await Promise.all(
|
|
8822
8900
|
pending.map(async ({ bundlePath, srcFsPath, packageName }) => {
|
|
8823
8901
|
try {
|
|
8824
|
-
const stats = await
|
|
8902
|
+
const stats = await import_fs15.default.promises.stat(srcFsPath);
|
|
8825
8903
|
return { bundlePath, srcFsPath, size: stats.size, packageName };
|
|
8826
8904
|
} catch {
|
|
8827
8905
|
return null;
|
|
@@ -8834,7 +8912,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8834
8912
|
for (const result of results) {
|
|
8835
8913
|
if (!result)
|
|
8836
8914
|
continue;
|
|
8837
|
-
files[result.bundlePath] = new
|
|
8915
|
+
files[result.bundlePath] = new import_build_utils19.FileFsRef({
|
|
8838
8916
|
fsPath: result.srcFsPath,
|
|
8839
8917
|
size: result.size
|
|
8840
8918
|
});
|
|
@@ -8849,13 +8927,13 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
8849
8927
|
};
|
|
8850
8928
|
|
|
8851
8929
|
// src/subscribers.ts
|
|
8852
|
-
var
|
|
8853
|
-
var
|
|
8854
|
-
var
|
|
8930
|
+
var import_path17 = require("path");
|
|
8931
|
+
var import_fs17 = __toESM(require("fs"));
|
|
8932
|
+
var import_build_utils20 = require("@vercel/build-utils");
|
|
8855
8933
|
|
|
8856
8934
|
// src/module-entrypoint.ts
|
|
8857
|
-
var
|
|
8858
|
-
var
|
|
8935
|
+
var import_path16 = require("path");
|
|
8936
|
+
var import_fs16 = __toESM(require("fs"));
|
|
8859
8937
|
var MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
|
|
8860
8938
|
function parseModuleEntrypoint(value) {
|
|
8861
8939
|
const match = MODULE_ATTR_RE.exec(value);
|
|
@@ -8886,7 +8964,7 @@ async function resolveExistingEntrypoint(workPath, filePath) {
|
|
|
8886
8964
|
const candidates = [filePath, filePath.replace(/\.py$/i, "/__init__.py")];
|
|
8887
8965
|
for (const candidate of candidates) {
|
|
8888
8966
|
try {
|
|
8889
|
-
const stat = await
|
|
8967
|
+
const stat = await import_fs16.default.promises.stat((0, import_path16.join)(workPath, candidate));
|
|
8890
8968
|
if (stat.isFile()) {
|
|
8891
8969
|
return candidate;
|
|
8892
8970
|
}
|
|
@@ -8933,14 +9011,14 @@ function getSubscriberOutputPath(subscriberName) {
|
|
|
8933
9011
|
return `${SUBSCRIBER_OUTPUT_DIR}/${safePathSegment(subscriberName)}`;
|
|
8934
9012
|
}
|
|
8935
9013
|
function getSubscriberConsumerName(subscriberName) {
|
|
8936
|
-
return (0,
|
|
9014
|
+
return (0, import_build_utils20.sanitizeConsumerName)(getSubscriberOutputPath(subscriberName));
|
|
8937
9015
|
}
|
|
8938
9016
|
async function getPyprojectSubscribers(workPath) {
|
|
8939
|
-
const pyprojectPath = (0,
|
|
8940
|
-
if (!
|
|
9017
|
+
const pyprojectPath = (0, import_path17.join)(workPath, "pyproject.toml");
|
|
9018
|
+
if (!import_fs17.default.existsSync(pyprojectPath)) {
|
|
8941
9019
|
return [];
|
|
8942
9020
|
}
|
|
8943
|
-
const pyproject = await (0,
|
|
9021
|
+
const pyproject = await (0, import_build_utils20.readConfigFile)(pyprojectPath);
|
|
8944
9022
|
const subscribers = pyproject?.tool?.vercel?.subscribers;
|
|
8945
9023
|
if (!subscribers) {
|
|
8946
9024
|
return [];
|
|
@@ -9032,16 +9110,16 @@ function parseTriggerDefaults(subscriber, config) {
|
|
|
9032
9110
|
return defaults;
|
|
9033
9111
|
}
|
|
9034
9112
|
function subscriberError(message) {
|
|
9035
|
-
return new
|
|
9113
|
+
return new import_build_utils20.NowBuildError({
|
|
9036
9114
|
code: "PYTHON_INVALID_SUBSCRIBER_CONFIG",
|
|
9037
9115
|
message
|
|
9038
9116
|
});
|
|
9039
9117
|
}
|
|
9040
9118
|
|
|
9041
9119
|
// src/workflows.ts
|
|
9042
|
-
var
|
|
9043
|
-
var
|
|
9044
|
-
var
|
|
9120
|
+
var import_path18 = require("path");
|
|
9121
|
+
var import_fs18 = __toESM(require("fs"));
|
|
9122
|
+
var import_build_utils21 = require("@vercel/build-utils");
|
|
9045
9123
|
var WORKFLOW_OUTPUT_DIR = "_py_workflows";
|
|
9046
9124
|
var WORKFLOW_TOPIC_PATTERN = "__wkf_*";
|
|
9047
9125
|
var WORKFLOW_FIELD_NAMES = /* @__PURE__ */ new Set(["entrypoint"]);
|
|
@@ -9049,14 +9127,14 @@ function getWorkflowOutputPath(workflowName) {
|
|
|
9049
9127
|
return `${WORKFLOW_OUTPUT_DIR}/${safePathSegment(workflowName)}`;
|
|
9050
9128
|
}
|
|
9051
9129
|
function getWorkflowConsumerName(workflowName) {
|
|
9052
|
-
return (0,
|
|
9130
|
+
return (0, import_build_utils21.sanitizeConsumerName)(getWorkflowOutputPath(workflowName));
|
|
9053
9131
|
}
|
|
9054
9132
|
async function getPyprojectWorkflows(workPath) {
|
|
9055
|
-
const pyprojectPath = (0,
|
|
9056
|
-
if (!
|
|
9133
|
+
const pyprojectPath = (0, import_path18.join)(workPath, "pyproject.toml");
|
|
9134
|
+
if (!import_fs18.default.existsSync(pyprojectPath)) {
|
|
9057
9135
|
return [];
|
|
9058
9136
|
}
|
|
9059
|
-
const pyproject = await (0,
|
|
9137
|
+
const pyproject = await (0, import_build_utils21.readConfigFile)(pyprojectPath);
|
|
9060
9138
|
const workflows = pyproject?.tool?.vercel?.workflows;
|
|
9061
9139
|
if (!workflows) {
|
|
9062
9140
|
return [];
|
|
@@ -9110,14 +9188,14 @@ async function parseWorkflow(workPath, index, config) {
|
|
|
9110
9188
|
};
|
|
9111
9189
|
}
|
|
9112
9190
|
function workflowError(message) {
|
|
9113
|
-
return new
|
|
9191
|
+
return new import_build_utils21.NowBuildError({
|
|
9114
9192
|
code: "PYTHON_INVALID_WORKFLOW_CONFIG",
|
|
9115
9193
|
message
|
|
9116
9194
|
});
|
|
9117
9195
|
}
|
|
9118
9196
|
|
|
9119
9197
|
// src/index.ts
|
|
9120
|
-
var writeFile =
|
|
9198
|
+
var writeFile = import_fs19.default.promises.writeFile;
|
|
9121
9199
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
9122
9200
|
var version = -1;
|
|
9123
9201
|
function getDevSubscriberTopics(subscriber) {
|
|
@@ -9134,9 +9212,9 @@ async function getDevSidecars({
|
|
|
9134
9212
|
service
|
|
9135
9213
|
}) {
|
|
9136
9214
|
const framework = build2.config?.framework;
|
|
9137
|
-
const isPyprojectEntrypoint = (0,
|
|
9138
|
-
const isPyprojectService = service !== void 0 && (0,
|
|
9139
|
-
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0,
|
|
9215
|
+
const isPyprojectEntrypoint = (0, import_path19.basename)(build2.src ?? "") === "pyproject.toml";
|
|
9216
|
+
const isPyprojectService = service !== void 0 && (0, import_path19.basename)(service.entrypoint ?? "") === "pyproject.toml";
|
|
9217
|
+
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0, import_build_utils22.isPythonFramework)(framework))) {
|
|
9140
9218
|
return [];
|
|
9141
9219
|
}
|
|
9142
9220
|
const subscribers = await getPyprojectSubscribers(workPath);
|
|
@@ -9289,13 +9367,13 @@ var frameworkHooks = {
|
|
|
9289
9367
|
}) => {
|
|
9290
9368
|
let baseDir = detected?.baseDir;
|
|
9291
9369
|
if (baseDir === void 0) {
|
|
9292
|
-
if (!
|
|
9293
|
-
(0,
|
|
9370
|
+
if (!import_fs19.default.existsSync((0, import_path19.join)(workPath, "manage.py"))) {
|
|
9371
|
+
(0, import_build_utils22.debug)("Django hook: no manage.py detected, skipping");
|
|
9294
9372
|
return;
|
|
9295
9373
|
}
|
|
9296
9374
|
baseDir = "";
|
|
9297
9375
|
}
|
|
9298
|
-
const djangoPath = (0,
|
|
9376
|
+
const djangoPath = (0, import_path19.join)(workPath, baseDir);
|
|
9299
9377
|
let settingsResult;
|
|
9300
9378
|
try {
|
|
9301
9379
|
settingsResult = await getDjangoSettings(djangoPath, pythonEnv);
|
|
@@ -9307,13 +9385,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
9307
9385
|
} else {
|
|
9308
9386
|
detail = err?.stderr || err?.message || String(err);
|
|
9309
9387
|
}
|
|
9310
|
-
throw new
|
|
9388
|
+
throw new import_build_utils22.NowBuildError({
|
|
9311
9389
|
code: "DJANGO_SETTINGS_FAILED",
|
|
9312
9390
|
message: `Failed to read Django application settings from ${djangoPath}/manage.py:
|
|
9313
9391
|
${detail}`
|
|
9314
9392
|
});
|
|
9315
9393
|
}
|
|
9316
|
-
(0,
|
|
9394
|
+
(0, import_build_utils22.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
9317
9395
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
9318
9396
|
if (djangoVersion) {
|
|
9319
9397
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -9325,7 +9403,7 @@ ${detail}`
|
|
|
9325
9403
|
const variableName = parts.at(-1);
|
|
9326
9404
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
9327
9405
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
9328
|
-
(0,
|
|
9406
|
+
(0, import_build_utils22.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
9329
9407
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
9330
9408
|
} else {
|
|
9331
9409
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -9334,7 +9412,7 @@ ${detail}`
|
|
|
9334
9412
|
const variableName = parts.at(-1);
|
|
9335
9413
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
9336
9414
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
9337
|
-
(0,
|
|
9415
|
+
(0, import_build_utils22.debug)(
|
|
9338
9416
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
9339
9417
|
);
|
|
9340
9418
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -9342,7 +9420,7 @@ ${detail}`
|
|
|
9342
9420
|
}
|
|
9343
9421
|
let djangoStatic = null;
|
|
9344
9422
|
if (workPath && venvPath) {
|
|
9345
|
-
const outputStaticDir = (0,
|
|
9423
|
+
const outputStaticDir = (0, import_path19.join)(workPath, ".vercel", "output", "static");
|
|
9346
9424
|
djangoStatic = await runDjangoCollectStatic(
|
|
9347
9425
|
venvPath,
|
|
9348
9426
|
workPath,
|
|
@@ -9357,8 +9435,53 @@ ${detail}`
|
|
|
9357
9435
|
return {
|
|
9358
9436
|
entrypoint: resolvedEntrypoint,
|
|
9359
9437
|
djangoStatic,
|
|
9360
|
-
extraPythonPath: baseDir ? (0,
|
|
9438
|
+
extraPythonPath: baseDir ? (0, import_path19.join)(workPath, baseDir) : void 0
|
|
9361
9439
|
};
|
|
9440
|
+
},
|
|
9441
|
+
fastapi: async ({
|
|
9442
|
+
pythonEnv,
|
|
9443
|
+
detected,
|
|
9444
|
+
workPath,
|
|
9445
|
+
venvPath,
|
|
9446
|
+
pyprojectData
|
|
9447
|
+
}) => {
|
|
9448
|
+
if (!detected?.entrypoint || !workPath || !venvPath) {
|
|
9449
|
+
(0, import_build_utils22.debug)(
|
|
9450
|
+
`FastAPI hook: skipping \u2014 detected.entrypoint=${JSON.stringify(detected?.entrypoint)}, workPath=${workPath}, venvPath=${venvPath}`
|
|
9451
|
+
);
|
|
9452
|
+
return;
|
|
9453
|
+
}
|
|
9454
|
+
const { entrypoint: entrypointRel, variableName } = detected.entrypoint;
|
|
9455
|
+
(0, import_build_utils22.debug)(
|
|
9456
|
+
`FastAPI hook: entrypoint=${entrypointRel}, variableName=${variableName}`
|
|
9457
|
+
);
|
|
9458
|
+
const entrypointAbs = (0, import_path19.join)(workPath, entrypointRel);
|
|
9459
|
+
const outputStaticDir = (0, import_path19.join)(workPath, ".vercel", "output", "static");
|
|
9460
|
+
const cdnEnv = process.env.VERCEL_FASTAPI_STATIC_CDN?.toLowerCase();
|
|
9461
|
+
if (cdnEnv !== "1" && cdnEnv !== "true") {
|
|
9462
|
+
(0, import_build_utils22.debug)(
|
|
9463
|
+
"FastAPI: VERCEL_FASTAPI_STATIC_CDN not set, skipping static CDN collection"
|
|
9464
|
+
);
|
|
9465
|
+
return;
|
|
9466
|
+
}
|
|
9467
|
+
const staticCdn = pyprojectData?.tool?.vercel?.fastapi?.static?.cdn;
|
|
9468
|
+
if (staticCdn === false) {
|
|
9469
|
+
(0, import_build_utils22.debug)(
|
|
9470
|
+
"FastAPI: static.cdn = false in pyproject.toml, skipping CDN collection"
|
|
9471
|
+
);
|
|
9472
|
+
return;
|
|
9473
|
+
}
|
|
9474
|
+
const fastapiStatic = await runFastAPICollectStatic(
|
|
9475
|
+
venvPath,
|
|
9476
|
+
workPath,
|
|
9477
|
+
pythonEnv,
|
|
9478
|
+
outputStaticDir,
|
|
9479
|
+
entrypointAbs,
|
|
9480
|
+
variableName
|
|
9481
|
+
);
|
|
9482
|
+
if (!fastapiStatic)
|
|
9483
|
+
return;
|
|
9484
|
+
return { fastapiStatic };
|
|
9362
9485
|
}
|
|
9363
9486
|
};
|
|
9364
9487
|
function createRuntimeTrampoline({
|
|
@@ -9416,23 +9539,23 @@ async function downloadFilesInWorkPath({
|
|
|
9416
9539
|
files,
|
|
9417
9540
|
meta = {}
|
|
9418
9541
|
}) {
|
|
9419
|
-
(0,
|
|
9420
|
-
let downloadedFiles = await (0,
|
|
9542
|
+
(0, import_build_utils22.debug)("Downloading user files...");
|
|
9543
|
+
let downloadedFiles = await (0, import_build_utils22.download)(files, workPath, meta);
|
|
9421
9544
|
if (meta.isDev && entrypoint) {
|
|
9422
9545
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
9423
9546
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
9424
|
-
throw new
|
|
9547
|
+
throw new import_build_utils22.NowBuildError({
|
|
9425
9548
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
9426
9549
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
9427
9550
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
9428
9551
|
action: "Learn More"
|
|
9429
9552
|
});
|
|
9430
9553
|
}
|
|
9431
|
-
const { devCacheDir = (0,
|
|
9432
|
-
const cacheKey = (0,
|
|
9433
|
-
const destCache = (0,
|
|
9434
|
-
await (0,
|
|
9435
|
-
downloadedFiles = await (0,
|
|
9554
|
+
const { devCacheDir = (0, import_path19.join)(workPath, ".now", "cache") } = meta;
|
|
9555
|
+
const cacheKey = (0, import_path19.basename)(entrypoint).replace(/\./g, "_");
|
|
9556
|
+
const destCache = (0, import_path19.join)(devCacheDir, cacheKey);
|
|
9557
|
+
await (0, import_build_utils22.download)(downloadedFiles, destCache);
|
|
9558
|
+
downloadedFiles = await (0, import_build_utils22.glob)("**", destCache);
|
|
9436
9559
|
workPath = destCache;
|
|
9437
9560
|
}
|
|
9438
9561
|
return workPath;
|
|
@@ -9468,7 +9591,7 @@ async function getPythonLambdaOptions({
|
|
|
9468
9591
|
sources.add(entrypoint.slice(0, -".py".length));
|
|
9469
9592
|
}
|
|
9470
9593
|
for (const sourceFile of sources) {
|
|
9471
|
-
const lambdaOptions = await (0,
|
|
9594
|
+
const lambdaOptions = await (0, import_build_utils22.getLambdaOptionsFromFunction)({
|
|
9472
9595
|
sourceFile,
|
|
9473
9596
|
config
|
|
9474
9597
|
});
|
|
@@ -9488,11 +9611,11 @@ async function installInjectedPackage({
|
|
|
9488
9611
|
projectDir,
|
|
9489
9612
|
pipPlatformArgs
|
|
9490
9613
|
}) {
|
|
9491
|
-
const localDir = (0,
|
|
9492
|
-
const isLocalDev =
|
|
9614
|
+
const localDir = (0, import_path19.join)(__dirname, "..", "..", "..", "python", name);
|
|
9615
|
+
const isLocalDev = import_fs19.default.existsSync((0, import_path19.join)(localDir, "pyproject.toml"));
|
|
9493
9616
|
const dep = envOverride || (isLocalDev ? localDir : pinned);
|
|
9494
9617
|
const noExclude = ["--exclude-newer-package", `${name}=false`];
|
|
9495
|
-
(0,
|
|
9618
|
+
(0, import_build_utils22.debug)(`Installing ${dep}`);
|
|
9496
9619
|
await uv.pip({
|
|
9497
9620
|
venvPath,
|
|
9498
9621
|
projectDir,
|
|
@@ -9518,14 +9641,14 @@ var build = async ({
|
|
|
9518
9641
|
registerPreDeploy
|
|
9519
9642
|
}) => {
|
|
9520
9643
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
9521
|
-
const isPyprojectEntrypoint = entrypoint !== void 0 && (0,
|
|
9644
|
+
const isPyprojectEntrypoint = entrypoint !== void 0 && (0, import_path19.basename)(entrypoint) === "pyproject.toml";
|
|
9522
9645
|
if (isPyprojectEntrypoint && entrypoint !== "pyproject.toml") {
|
|
9523
|
-
throw new
|
|
9646
|
+
throw new import_build_utils22.NowBuildError({
|
|
9524
9647
|
code: "PYTHON_INVALID_PYPROJECT_ENTRYPOINT",
|
|
9525
|
-
message: `A "pyproject.toml" entrypoint must sit at the service root. Set the service "root" to "${(0,
|
|
9648
|
+
message: `A "pyproject.toml" entrypoint must sit at the service root. Set the service "root" to "${(0, import_path19.dirname)(entrypoint)}" and use entrypoint "pyproject.toml".`
|
|
9526
9649
|
});
|
|
9527
9650
|
}
|
|
9528
|
-
const builderSpan = parentSpan ?? new
|
|
9651
|
+
const builderSpan = parentSpan ?? new import_build_utils22.Span({ name: "vc.builder" });
|
|
9529
9652
|
const framework = config?.framework;
|
|
9530
9653
|
let shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
9531
9654
|
let subscribers = [];
|
|
@@ -9534,21 +9657,21 @@ var build = async ({
|
|
|
9534
9657
|
let projectInstallCommand;
|
|
9535
9658
|
let hasCustomCommand = false;
|
|
9536
9659
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
9537
|
-
(0,
|
|
9660
|
+
(0, import_build_utils22.debug)(`workPath: ${workPath}`);
|
|
9538
9661
|
workPath = await downloadFilesInWorkPath({
|
|
9539
9662
|
workPath,
|
|
9540
9663
|
files: originalFiles,
|
|
9541
9664
|
entrypoint,
|
|
9542
9665
|
meta
|
|
9543
9666
|
});
|
|
9544
|
-
if (isPyprojectEntrypoint || !service && (0,
|
|
9667
|
+
if (isPyprojectEntrypoint || !service && (0, import_build_utils22.isPythonFramework)(framework)) {
|
|
9545
9668
|
subscribers = await getPyprojectSubscribers(workPath);
|
|
9546
9669
|
workflows = await getPyprojectWorkflows(workPath);
|
|
9547
9670
|
shouldInstallVercelWorkers ||= subscribers.length > 0 || workflows.length > 0;
|
|
9548
9671
|
}
|
|
9549
9672
|
try {
|
|
9550
9673
|
if (meta.isDev) {
|
|
9551
|
-
const setupCfg = (0,
|
|
9674
|
+
const setupCfg = (0, import_path19.join)(workPath, "setup.cfg");
|
|
9552
9675
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
9553
9676
|
}
|
|
9554
9677
|
} catch (err) {
|
|
@@ -9562,7 +9685,7 @@ var build = async ({
|
|
|
9562
9685
|
if (declared) {
|
|
9563
9686
|
detected = { entrypoint: declared };
|
|
9564
9687
|
} else if (subscribers.length === 0 && workflows.length === 0) {
|
|
9565
|
-
throw new
|
|
9688
|
+
throw new import_build_utils22.NowBuildError({
|
|
9566
9689
|
code: "PYTHON_PYPROJECT_NOTHING_TO_BUILD",
|
|
9567
9690
|
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.'
|
|
9568
9691
|
});
|
|
@@ -9576,7 +9699,7 @@ var build = async ({
|
|
|
9576
9699
|
filePath: entrypoint,
|
|
9577
9700
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
9578
9701
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
9579
|
-
varName: service && (0,
|
|
9702
|
+
varName: service && (0, import_build_utils22.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
9580
9703
|
} : void 0,
|
|
9581
9704
|
service,
|
|
9582
9705
|
repoRootPath
|
|
@@ -9585,8 +9708,8 @@ var build = async ({
|
|
|
9585
9708
|
if (detected?.error && detected?.baseDir === void 0) {
|
|
9586
9709
|
throw detected?.error;
|
|
9587
9710
|
}
|
|
9588
|
-
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0,
|
|
9589
|
-
const entrypointAbsDir = (0,
|
|
9711
|
+
const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path19.dirname)(entrypoint) : ".");
|
|
9712
|
+
const entrypointAbsDir = (0, import_path19.join)(workPath, entryDirectory);
|
|
9590
9713
|
const rootDir = repoRootPath ?? workPath;
|
|
9591
9714
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
9592
9715
|
() => discoverPackage({
|
|
@@ -9627,12 +9750,12 @@ var build = async ({
|
|
|
9627
9750
|
}
|
|
9628
9751
|
const uvVersion = checkUvBinaryVersion(uv.getPath());
|
|
9629
9752
|
console.log(`Using ${uvVersion}`);
|
|
9630
|
-
const venvPath = service?.name ? (0,
|
|
9631
|
-
const hasCachedVenv =
|
|
9632
|
-
const hasCachedUv =
|
|
9753
|
+
const venvPath = service?.name ? (0, import_path19.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path19.join)(workPath, ".vercel", "python", ".venv");
|
|
9754
|
+
const hasCachedVenv = import_fs19.default.existsSync((0, import_path19.join)(venvPath, "pyvenv.cfg"));
|
|
9755
|
+
const hasCachedUv = import_fs19.default.existsSync(uvCacheDir);
|
|
9633
9756
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
9634
9757
|
if (hasCachedVenv || hasCachedUv) {
|
|
9635
|
-
(0,
|
|
9758
|
+
(0, import_build_utils22.debug)(
|
|
9636
9759
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
9637
9760
|
);
|
|
9638
9761
|
}
|
|
@@ -9644,14 +9767,14 @@ var build = async ({
|
|
|
9644
9767
|
uvCacheDir
|
|
9645
9768
|
});
|
|
9646
9769
|
});
|
|
9647
|
-
if ((0,
|
|
9770
|
+
if ((0, import_build_utils22.isPythonFramework)(framework)) {
|
|
9648
9771
|
const {
|
|
9649
9772
|
cliType,
|
|
9650
9773
|
lockfileVersion,
|
|
9651
9774
|
packageJsonPackageManager,
|
|
9652
9775
|
turboSupportsCorepackHome
|
|
9653
|
-
} = await (0,
|
|
9654
|
-
spawnEnv = (0,
|
|
9776
|
+
} = await (0, import_build_utils22.scanParentDirs)(workPath, true);
|
|
9777
|
+
spawnEnv = (0, import_build_utils22.getEnvForPackageManager)({
|
|
9655
9778
|
cliType,
|
|
9656
9779
|
lockfileVersion,
|
|
9657
9780
|
packageJsonPackageManager,
|
|
@@ -9676,13 +9799,13 @@ var build = async ({
|
|
|
9676
9799
|
let uvLockPath = null;
|
|
9677
9800
|
let uvProjectDir = null;
|
|
9678
9801
|
let projectName;
|
|
9679
|
-
await builderSpan.child(
|
|
9802
|
+
await builderSpan.child(import_build_utils22.BUILDER_INSTALLER_STEP, {
|
|
9680
9803
|
installCommand: projectInstallCommand || void 0,
|
|
9681
9804
|
runtime: "python",
|
|
9682
9805
|
"python.cache.restored": restoredCache
|
|
9683
9806
|
}).trace(async () => {
|
|
9684
9807
|
if (projectInstallCommand) {
|
|
9685
|
-
await
|
|
9808
|
+
await import_fs19.default.promises.rm(venvPath, { recursive: true, force: true });
|
|
9686
9809
|
await ensureVenv({
|
|
9687
9810
|
pythonVersion,
|
|
9688
9811
|
venvPath,
|
|
@@ -9693,7 +9816,7 @@ var build = async ({
|
|
|
9693
9816
|
console.log(
|
|
9694
9817
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
9695
9818
|
);
|
|
9696
|
-
await (0,
|
|
9819
|
+
await (0, import_build_utils22.execCommand)(projectInstallCommand, {
|
|
9697
9820
|
env: pythonEnv,
|
|
9698
9821
|
cwd: workPath
|
|
9699
9822
|
});
|
|
@@ -9714,7 +9837,7 @@ var build = async ({
|
|
|
9714
9837
|
}
|
|
9715
9838
|
if (!assumeDepsInstalled) {
|
|
9716
9839
|
const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
|
|
9717
|
-
const cachedLockPath = (0,
|
|
9840
|
+
const cachedLockPath = (0, import_path19.join)(uvCacheDir, lockCacheKey);
|
|
9718
9841
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
9719
9842
|
workPath,
|
|
9720
9843
|
rootDir,
|
|
@@ -9735,21 +9858,21 @@ var build = async ({
|
|
|
9735
9858
|
locked: !lockFileProvidedByUser,
|
|
9736
9859
|
pythonPlatform: target.uvPlatform
|
|
9737
9860
|
});
|
|
9738
|
-
if (lockPath &&
|
|
9739
|
-
await
|
|
9740
|
-
await
|
|
9861
|
+
if (lockPath && import_fs19.default.existsSync(lockPath)) {
|
|
9862
|
+
await import_fs19.default.promises.mkdir(uvCacheDir, { recursive: true });
|
|
9863
|
+
await import_fs19.default.promises.copyFile(lockPath, cachedLockPath);
|
|
9741
9864
|
}
|
|
9742
9865
|
}
|
|
9743
9866
|
});
|
|
9744
|
-
if ((0,
|
|
9867
|
+
if ((0, import_build_utils22.isPythonFramework)(framework)) {
|
|
9745
9868
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
9746
9869
|
config?.buildCommand;
|
|
9747
|
-
await builderSpan.child(
|
|
9870
|
+
await builderSpan.child(import_build_utils22.BUILDER_COMPILE_STEP, {
|
|
9748
9871
|
buildCommand: projectBuildCommand || void 0
|
|
9749
9872
|
}).trace(async () => {
|
|
9750
9873
|
if (projectBuildCommand) {
|
|
9751
9874
|
console.log(`Running "${projectBuildCommand}"`);
|
|
9752
|
-
await (0,
|
|
9875
|
+
await (0, import_build_utils22.execCommand)(projectBuildCommand, {
|
|
9753
9876
|
env: pythonEnv,
|
|
9754
9877
|
cwd: workPath
|
|
9755
9878
|
});
|
|
@@ -9767,7 +9890,8 @@ var build = async ({
|
|
|
9767
9890
|
workPath,
|
|
9768
9891
|
venvPath,
|
|
9769
9892
|
entrypoint,
|
|
9770
|
-
detected
|
|
9893
|
+
detected,
|
|
9894
|
+
pyprojectData: pythonPackage.manifest?.data
|
|
9771
9895
|
});
|
|
9772
9896
|
const resolved = isPyprojectEntrypoint ? detected?.entrypoint : hookResult?.entrypoint ?? detected?.entrypoint;
|
|
9773
9897
|
if (!resolved && detected?.error) {
|
|
@@ -9776,12 +9900,14 @@ var build = async ({
|
|
|
9776
9900
|
entrypoint = resolved?.entrypoint;
|
|
9777
9901
|
const isWorkersOnly = !entrypoint && isPyprojectEntrypoint && (subscribers.length > 0 || workflows.length > 0);
|
|
9778
9902
|
if (!entrypoint && !isWorkersOnly) {
|
|
9779
|
-
throw new
|
|
9903
|
+
throw new import_build_utils22.NowBuildError({
|
|
9780
9904
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
9781
9905
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
9782
9906
|
});
|
|
9783
9907
|
}
|
|
9784
9908
|
const djangoStatic = hookResult?.djangoStatic ?? null;
|
|
9909
|
+
const fastapiStatic = hookResult?.fastapiStatic ?? null;
|
|
9910
|
+
const cdnOutputDir = djangoStatic?.cdnOutputDir ?? fastapiStatic?.cdnOutputDir ?? null;
|
|
9785
9911
|
const pipPlatformArgs = target.uvPlatform ? ["--python-platform", target.uvPlatform] : [];
|
|
9786
9912
|
await installInjectedPackage({
|
|
9787
9913
|
name: "vercel-runtime",
|
|
@@ -9789,7 +9915,7 @@ var build = async ({
|
|
|
9789
9915
|
envOverride: baseEnv.VERCEL_RUNTIME_PYTHON,
|
|
9790
9916
|
uv,
|
|
9791
9917
|
venvPath,
|
|
9792
|
-
projectDir: (0,
|
|
9918
|
+
projectDir: (0, import_path19.join)(workPath, entryDirectory),
|
|
9793
9919
|
pipPlatformArgs
|
|
9794
9920
|
});
|
|
9795
9921
|
if (shouldInstallVercelWorkers) {
|
|
@@ -9799,7 +9925,7 @@ var build = async ({
|
|
|
9799
9925
|
envOverride: baseEnv.VERCEL_WORKERS_PYTHON,
|
|
9800
9926
|
uv,
|
|
9801
9927
|
venvPath,
|
|
9802
|
-
projectDir: (0,
|
|
9928
|
+
projectDir: (0, import_path19.join)(workPath, entryDirectory),
|
|
9803
9929
|
pipPlatformArgs
|
|
9804
9930
|
});
|
|
9805
9931
|
}
|
|
@@ -9812,11 +9938,11 @@ var build = async ({
|
|
|
9812
9938
|
const capturedEnv = { ...pythonEnv };
|
|
9813
9939
|
const capturedCwd = workPath;
|
|
9814
9940
|
registerPreDeploy(async () => {
|
|
9815
|
-
await builderSpan.child(
|
|
9941
|
+
await builderSpan.child(import_build_utils22.BUILDER_PRE_DEPLOY_STEP, {
|
|
9816
9942
|
preDeployCommand
|
|
9817
9943
|
}).trace(async () => {
|
|
9818
9944
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
9819
|
-
await (0,
|
|
9945
|
+
await (0, import_build_utils22.execCommand)(preDeployCommand, {
|
|
9820
9946
|
env: capturedEnv,
|
|
9821
9947
|
cwd: capturedCwd
|
|
9822
9948
|
});
|
|
@@ -9827,14 +9953,14 @@ var build = async ({
|
|
|
9827
9953
|
let crons;
|
|
9828
9954
|
let runtimeTrampoline;
|
|
9829
9955
|
if (entrypoint) {
|
|
9830
|
-
(0,
|
|
9956
|
+
(0, import_build_utils22.debug)("Entrypoint is", entrypoint);
|
|
9831
9957
|
const moduleName = entrypointToModule(entrypoint);
|
|
9832
9958
|
if (handlerFunction) {
|
|
9833
|
-
const entrypointPath = (0,
|
|
9834
|
-
const source = await
|
|
9959
|
+
const entrypointPath = (0, import_path19.join)(workPath, entrypoint);
|
|
9960
|
+
const source = await import_fs19.default.promises.readFile(entrypointPath, "utf-8");
|
|
9835
9961
|
const found = await (0, import_python_analysis10.containsTopLevelCallable)(source, handlerFunction);
|
|
9836
9962
|
if (!found) {
|
|
9837
|
-
throw new
|
|
9963
|
+
throw new import_build_utils22.NowBuildError({
|
|
9838
9964
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
9839
9965
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
9840
9966
|
});
|
|
@@ -9842,7 +9968,7 @@ var build = async ({
|
|
|
9842
9968
|
}
|
|
9843
9969
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
9844
9970
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
9845
|
-
(0,
|
|
9971
|
+
(0, import_build_utils22.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
9846
9972
|
crons = await getServiceCrons({
|
|
9847
9973
|
service,
|
|
9848
9974
|
entrypoint,
|
|
@@ -9903,16 +10029,17 @@ var build = async ({
|
|
|
9903
10029
|
cwd: workPath,
|
|
9904
10030
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
9905
10031
|
};
|
|
9906
|
-
const files = await (0,
|
|
10032
|
+
const files = await (0, import_build_utils22.glob)("**", globOptions);
|
|
10033
|
+
const appPythonSourceFiles = Object.keys(files).filter((file) => file.endsWith(".py")).map((file) => (0, import_path19.join)(workPath, file)).sort();
|
|
9907
10034
|
if (djangoStatic?.manifestRelPath) {
|
|
9908
|
-
files[djangoStatic.manifestRelPath] = new
|
|
9909
|
-
fsPath: (0,
|
|
10035
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils22.FileFsRef({
|
|
10036
|
+
fsPath: (0, import_path19.join)(workPath, djangoStatic.manifestRelPath)
|
|
9910
10037
|
});
|
|
9911
10038
|
}
|
|
9912
10039
|
const handlerPyFilename = "vc__handler__python";
|
|
9913
10040
|
if (config.framework === "fasthtml") {
|
|
9914
10041
|
const { SESSKEY = "" } = process.env;
|
|
9915
|
-
files[".sesskey"] = new
|
|
10042
|
+
files[".sesskey"] = new import_build_utils22.FileBlob({ data: `"${SESSKEY}"` });
|
|
9916
10043
|
}
|
|
9917
10044
|
await builderSpan.child("vc.builder.python.bundle").trace(async (bundleSpan) => {
|
|
9918
10045
|
const installedDistributions = await InstalledPythonDistributions.load({
|
|
@@ -9944,29 +10071,39 @@ var build = async ({
|
|
|
9944
10071
|
});
|
|
9945
10072
|
}
|
|
9946
10073
|
});
|
|
10074
|
+
const compileAllOptions = compileAllEnabled ? {
|
|
10075
|
+
pythonBin: getVenvPythonBin(venvPath),
|
|
10076
|
+
env: pythonEnv
|
|
10077
|
+
} : null;
|
|
10078
|
+
const compileSources = async ({
|
|
10079
|
+
includePackages,
|
|
10080
|
+
pycachePrefix
|
|
10081
|
+
}) => {
|
|
10082
|
+
if (!compileAllOptions)
|
|
10083
|
+
return;
|
|
10084
|
+
const vendorSourceFiles = installedDistributions.getPythonSourceFiles(includePackages);
|
|
10085
|
+
await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
|
|
10086
|
+
console.log("Compiling Python bytecode...");
|
|
10087
|
+
await runCompileAll({
|
|
10088
|
+
...compileAllOptions,
|
|
10089
|
+
sourceFiles: [...appPythonSourceFiles, ...vendorSourceFiles],
|
|
10090
|
+
pycachePrefix
|
|
10091
|
+
});
|
|
10092
|
+
compileSpan.setAttributes({
|
|
10093
|
+
"python.compileall.enabled": "true",
|
|
10094
|
+
"python.compileall.appSourceFileCount": String(
|
|
10095
|
+
appPythonSourceFiles.length
|
|
10096
|
+
),
|
|
10097
|
+
"python.compileall.vendorSourceFileCount": String(
|
|
10098
|
+
vendorSourceFiles.length
|
|
10099
|
+
)
|
|
10100
|
+
});
|
|
10101
|
+
});
|
|
10102
|
+
};
|
|
9947
10103
|
const runCompileAllAndFillBytecode = async (capacityBytes, vendorPackageTiers) => {
|
|
9948
10104
|
try {
|
|
9949
|
-
await
|
|
9950
|
-
|
|
9951
|
-
const pythonBin = getVenvPythonBin(venvPath);
|
|
9952
|
-
console.log("Compiling Python bytecode...");
|
|
9953
|
-
await runCompileAll({
|
|
9954
|
-
pythonBin,
|
|
9955
|
-
filesOrDirectories: [workPath],
|
|
9956
|
-
env: pythonEnv,
|
|
9957
|
-
excludeRegex: getCompileAllAppExcludeRegex(workPath)
|
|
9958
|
-
});
|
|
9959
|
-
await runCompileAll({
|
|
9960
|
-
pythonBin,
|
|
9961
|
-
filesOrDirectories: sitePackageDirs,
|
|
9962
|
-
env: pythonEnv
|
|
9963
|
-
});
|
|
9964
|
-
compileSpan.setAttributes({
|
|
9965
|
-
"python.compileall.enabled": "true",
|
|
9966
|
-
"python.compileall.sitePackageDirectoryCount": String(
|
|
9967
|
-
sitePackageDirs.length
|
|
9968
|
-
)
|
|
9969
|
-
});
|
|
10105
|
+
await compileSources({
|
|
10106
|
+
includePackages: vendorPackageTiers?.flat()
|
|
9970
10107
|
});
|
|
9971
10108
|
const currentSize = await calculateBundleSize(files);
|
|
9972
10109
|
let remainingCapacity = capacityBytes - currentSize;
|
|
@@ -9994,7 +10131,7 @@ var build = async ({
|
|
|
9994
10131
|
console.log(
|
|
9995
10132
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
9996
10133
|
);
|
|
9997
|
-
(0,
|
|
10134
|
+
(0, import_build_utils22.debug)(`bytecode precompilation error details: ${err}`);
|
|
9998
10135
|
}
|
|
9999
10136
|
};
|
|
10000
10137
|
const runPrefixCompileAndFill = async (bundleResult) => {
|
|
@@ -10006,38 +10143,21 @@ var build = async ({
|
|
|
10006
10143
|
const currentSize = await calculateBundleSize(files);
|
|
10007
10144
|
let remainingCapacity = BYTECODE_FILL_CEILING_BYTES - currentSize;
|
|
10008
10145
|
if (remainingCapacity <= 0) {
|
|
10009
|
-
(0,
|
|
10146
|
+
(0, import_build_utils22.debug)(
|
|
10010
10147
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
10011
10148
|
);
|
|
10012
10149
|
return;
|
|
10013
10150
|
}
|
|
10014
|
-
const stagingDir = (0,
|
|
10015
|
-
await
|
|
10016
|
-
await
|
|
10017
|
-
await
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
env: pythonEnv,
|
|
10025
|
-
excludeRegex: getCompileAllAppExcludeRegex(workPath),
|
|
10026
|
-
pycachePrefix: stagingDir
|
|
10027
|
-
});
|
|
10028
|
-
await runCompileAll({
|
|
10029
|
-
pythonBin,
|
|
10030
|
-
filesOrDirectories: sitePackageDirs,
|
|
10031
|
-
env: pythonEnv,
|
|
10032
|
-
pycachePrefix: stagingDir
|
|
10033
|
-
});
|
|
10034
|
-
compileSpan.setAttributes({
|
|
10035
|
-
"python.compileall.enabled": "true",
|
|
10036
|
-
"python.compileall.mode": "pycache-prefix",
|
|
10037
|
-
"python.compileall.sitePackageDirectoryCount": String(
|
|
10038
|
-
sitePackageDirs.length
|
|
10039
|
-
)
|
|
10040
|
-
});
|
|
10151
|
+
const stagingDir = (0, import_path19.join)(workPath, ".vercel", "python", "pycache");
|
|
10152
|
+
await import_fs19.default.promises.rm(stagingDir, { recursive: true, force: true });
|
|
10153
|
+
await import_fs19.default.promises.mkdir(stagingDir, { recursive: true });
|
|
10154
|
+
await compileSources({
|
|
10155
|
+
includePackages: [
|
|
10156
|
+
...bundleResult.alwaysBundledPackages ?? [],
|
|
10157
|
+
...bundleResult.bundledPublicPackages ?? [],
|
|
10158
|
+
...bundleResult.externalizedPublicPackages ?? []
|
|
10159
|
+
],
|
|
10160
|
+
pycachePrefix: stagingDir
|
|
10041
10161
|
});
|
|
10042
10162
|
const beforeCount = Object.keys(files).length;
|
|
10043
10163
|
const appInfo = await collectAppPrefixBytecodeFiles({
|
|
@@ -10080,7 +10200,7 @@ var build = async ({
|
|
|
10080
10200
|
console.log(
|
|
10081
10201
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
10082
10202
|
);
|
|
10083
|
-
(0,
|
|
10203
|
+
(0, import_build_utils22.debug)(`bytecode precompilation error details: ${err}`);
|
|
10084
10204
|
}
|
|
10085
10205
|
};
|
|
10086
10206
|
const announceLargeFunction = () => console.log(
|
|
@@ -10112,7 +10232,7 @@ var build = async ({
|
|
|
10112
10232
|
bundleResult.bundledPublicPackages ?? []
|
|
10113
10233
|
]);
|
|
10114
10234
|
} else {
|
|
10115
|
-
(0,
|
|
10235
|
+
(0, import_build_utils22.debug)(
|
|
10116
10236
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
10117
10237
|
);
|
|
10118
10238
|
}
|
|
@@ -10136,7 +10256,7 @@ var build = async ({
|
|
|
10136
10256
|
if (capacity > 0) {
|
|
10137
10257
|
await runCompileAllAndFillBytecode(BYTECODE_FILL_CEILING_BYTES);
|
|
10138
10258
|
} else {
|
|
10139
|
-
(0,
|
|
10259
|
+
(0, import_build_utils22.debug)(
|
|
10140
10260
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(depAnalysis.totalBundleSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
10141
10261
|
);
|
|
10142
10262
|
}
|
|
@@ -10154,13 +10274,13 @@ var build = async ({
|
|
|
10154
10274
|
if (entrypoint && runtimeTrampoline) {
|
|
10155
10275
|
const webFiles = {
|
|
10156
10276
|
...files,
|
|
10157
|
-
[`${handlerPyFilename}.py`]: new
|
|
10277
|
+
[`${handlerPyFilename}.py`]: new import_build_utils22.FileBlob({ data: runtimeTrampoline })
|
|
10158
10278
|
};
|
|
10159
10279
|
const lambdaOptions = await getPythonLambdaOptions({
|
|
10160
10280
|
config,
|
|
10161
10281
|
entrypoint
|
|
10162
10282
|
});
|
|
10163
|
-
output = new
|
|
10283
|
+
output = new import_build_utils22.Lambda({
|
|
10164
10284
|
files: webFiles,
|
|
10165
10285
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
10166
10286
|
runtime: pythonVersion.runtime,
|
|
@@ -10182,10 +10302,10 @@ var build = async ({
|
|
|
10182
10302
|
...subscriber.triggerDefaults
|
|
10183
10303
|
})
|
|
10184
10304
|
);
|
|
10185
|
-
subscriberLambdas[outputPath] = new
|
|
10305
|
+
subscriberLambdas[outputPath] = new import_build_utils22.Lambda({
|
|
10186
10306
|
files: {
|
|
10187
10307
|
...files,
|
|
10188
|
-
[`${handlerPyFilename}.py`]: new
|
|
10308
|
+
[`${handlerPyFilename}.py`]: new import_build_utils22.FileBlob({
|
|
10189
10309
|
data: createRuntimeTrampoline({
|
|
10190
10310
|
moduleName: subscriber.moduleName,
|
|
10191
10311
|
entrypoint: subscriber.entrypoint,
|
|
@@ -10217,10 +10337,10 @@ var build = async ({
|
|
|
10217
10337
|
consumer: getWorkflowConsumerName(workflow.name)
|
|
10218
10338
|
}
|
|
10219
10339
|
];
|
|
10220
|
-
workflowLambdas[outputPath] = new
|
|
10340
|
+
workflowLambdas[outputPath] = new import_build_utils22.Lambda({
|
|
10221
10341
|
files: {
|
|
10222
10342
|
...files,
|
|
10223
|
-
[`${handlerPyFilename}.py`]: new
|
|
10343
|
+
[`${handlerPyFilename}.py`]: new import_build_utils22.FileBlob({
|
|
10224
10344
|
data: createRuntimeTrampoline({
|
|
10225
10345
|
moduleName: workflow.moduleName,
|
|
10226
10346
|
entrypoint: workflow.entrypoint,
|
|
@@ -10250,24 +10370,38 @@ var build = async ({
|
|
|
10250
10370
|
pythonVersion,
|
|
10251
10371
|
uvLockPath,
|
|
10252
10372
|
framework,
|
|
10253
|
-
serviceType: service ? (0,
|
|
10373
|
+
serviceType: service ? (0, import_build_utils22.getReportedServiceType)(service) : void 0
|
|
10254
10374
|
});
|
|
10255
10375
|
} catch (err) {
|
|
10256
|
-
(0,
|
|
10376
|
+
(0, import_build_utils22.debug)(
|
|
10257
10377
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
10258
10378
|
);
|
|
10259
10379
|
}
|
|
10260
10380
|
}
|
|
10261
|
-
if (!(0,
|
|
10381
|
+
if (!(0, import_build_utils22.isPythonFramework)(framework) && !service?.name && !isPyprojectEntrypoint) {
|
|
10262
10382
|
(0, import_assert.default)(output, "web Lambda must exist for non-service builds");
|
|
10263
10383
|
return { resultVersion: 3, result: { output } };
|
|
10264
10384
|
}
|
|
10265
|
-
const
|
|
10266
|
-
const
|
|
10385
|
+
const frameworkLambdaName = framework ?? "python";
|
|
10386
|
+
const lambdaPath = service?.name && service.type ? `_svc/${service.name}/index` : frameworkLambdaName;
|
|
10387
|
+
const staticFiles = cdnOutputDir ? await (0, import_build_utils22.glob)("**", { cwd: cdnOutputDir }) : {};
|
|
10267
10388
|
const isNonWebService = service?.name && service.type && service.type !== "web";
|
|
10268
10389
|
const routes = isNonWebService || !output ? void 0 : [
|
|
10269
10390
|
{ handle: "filesystem" },
|
|
10270
|
-
|
|
10391
|
+
// This route matches the resolved destination after rewrites. Copy
|
|
10392
|
+
// that path into the runtime request before dispatching the shared
|
|
10393
|
+
// framework Lambda so application routing observes the rewrite.
|
|
10394
|
+
{
|
|
10395
|
+
src: "/(.*)",
|
|
10396
|
+
dest: `/${lambdaPath}`,
|
|
10397
|
+
transforms: [
|
|
10398
|
+
{
|
|
10399
|
+
type: "request.path",
|
|
10400
|
+
op: "set",
|
|
10401
|
+
args: "/$1"
|
|
10402
|
+
}
|
|
10403
|
+
]
|
|
10404
|
+
}
|
|
10271
10405
|
];
|
|
10272
10406
|
return {
|
|
10273
10407
|
resultVersion: 2,
|
|
@@ -10298,14 +10432,14 @@ var prepareCache = async ({
|
|
|
10298
10432
|
}
|
|
10299
10433
|
} catch {
|
|
10300
10434
|
}
|
|
10301
|
-
return (0,
|
|
10435
|
+
return (0, import_build_utils22.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
10302
10436
|
cwd: root,
|
|
10303
10437
|
ignore
|
|
10304
10438
|
});
|
|
10305
10439
|
};
|
|
10306
10440
|
var shouldServe = (opts) => {
|
|
10307
10441
|
const framework = opts.config.framework;
|
|
10308
|
-
if ((0,
|
|
10442
|
+
if ((0, import_build_utils22.isPythonFramework)(framework)) {
|
|
10309
10443
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
10310
10444
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
10311
10445
|
return false;
|
|
@@ -10324,7 +10458,7 @@ var defaultShouldServe = ({
|
|
|
10324
10458
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
10325
10459
|
return true;
|
|
10326
10460
|
}
|
|
10327
|
-
const { dir, name } = (0,
|
|
10461
|
+
const { dir, name } = (0, import_path19.parse)(entrypoint);
|
|
10328
10462
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
10329
10463
|
return true;
|
|
10330
10464
|
}
|