@vercel/python 6.24.0 → 6.25.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 +688 -293
- package/package.json +5 -4
- package/templates/vc_init_dev.py +1 -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 fs11 = 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
|
+
fs11.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(fs11.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 fs11 = require("fs");
|
|
92
92
|
function isexe(path, options, cb) {
|
|
93
|
-
|
|
93
|
+
fs11.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(fs11.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 fs11 = 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 fs11 = 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 = fs11.openSync(command, "r");
|
|
412
|
+
fs11.readSync(fd, buffer, 0, size, 0);
|
|
413
|
+
fs11.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 debug12;
|
|
427
427
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
428
|
-
|
|
428
|
+
debug12 = 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
|
+
debug12 = 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
|
+
debug12(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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("hyphen replace", range);
|
|
1054
1054
|
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
|
|
1055
|
-
|
|
1055
|
+
debug12("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
|
+
debug12("comp", comp, options);
|
|
1096
1096
|
comp = replaceCarets(comp, options);
|
|
1097
|
-
|
|
1097
|
+
debug12("caret", comp);
|
|
1098
1098
|
comp = replaceTildes(comp, options);
|
|
1099
|
-
|
|
1099
|
+
debug12("tildes", comp);
|
|
1100
1100
|
comp = replaceXRanges(comp, options);
|
|
1101
|
-
|
|
1101
|
+
debug12("xrange", comp);
|
|
1102
1102
|
comp = replaceStars(comp, options);
|
|
1103
|
-
|
|
1103
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("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
|
+
debug12("caret return", ret);
|
|
1180
1180
|
return ret;
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
function replaceXRanges(comp, options) {
|
|
1184
|
-
|
|
1184
|
+
debug12("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
|
+
debug12("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
|
+
debug12("xRange return", ret);
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
function replaceStars(comp, options) {
|
|
1241
|
-
|
|
1241
|
+
debug12("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
|
+
debug12(set[i2].semver);
|
|
1290
1290
|
if (set[i2].semver === ANY) {
|
|
1291
1291
|
continue;
|
|
1292
1292
|
}
|
|
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
|
|
|
1895
1895
|
"../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
|
|
1896
1896
|
var once = require_once();
|
|
1897
1897
|
var eos = require_end_of_stream();
|
|
1898
|
-
var
|
|
1898
|
+
var fs11;
|
|
1899
1899
|
try {
|
|
1900
|
-
|
|
1900
|
+
fs11 = 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 (!fs11)
|
|
1913
1913
|
return false;
|
|
1914
|
-
return (stream instanceof (
|
|
1914
|
+
return (stream instanceof (fs11.ReadStream || noop) || stream instanceof (fs11.WriteStream || noop)) && isFn(stream.close);
|
|
1915
1915
|
};
|
|
1916
1916
|
var isRequest = function(stream) {
|
|
1917
1917
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -2674,27 +2674,27 @@ var require_process = __commonJS({
|
|
|
2674
2674
|
var require_filesystem = __commonJS({
|
|
2675
2675
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
|
|
2676
2676
|
"use strict";
|
|
2677
|
-
var
|
|
2677
|
+
var fs11 = require("fs");
|
|
2678
2678
|
var LDD_PATH = "/usr/bin/ldd";
|
|
2679
2679
|
var SELF_PATH = "/proc/self/exe";
|
|
2680
2680
|
var MAX_LENGTH = 2048;
|
|
2681
2681
|
var readFileSync2 = (path) => {
|
|
2682
|
-
const fd =
|
|
2682
|
+
const fd = fs11.openSync(path, "r");
|
|
2683
2683
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2684
|
-
const bytesRead =
|
|
2685
|
-
|
|
2684
|
+
const bytesRead = fs11.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
2685
|
+
fs11.close(fd, () => {
|
|
2686
2686
|
});
|
|
2687
2687
|
return buffer.subarray(0, bytesRead);
|
|
2688
2688
|
};
|
|
2689
2689
|
var readFile2 = (path) => new Promise((resolve3, reject) => {
|
|
2690
|
-
|
|
2690
|
+
fs11.open(path, "r", (err, fd) => {
|
|
2691
2691
|
if (err) {
|
|
2692
2692
|
reject(err);
|
|
2693
2693
|
} else {
|
|
2694
2694
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
2695
|
-
|
|
2695
|
+
fs11.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
2696
2696
|
resolve3(buffer.subarray(0, bytesRead));
|
|
2697
|
-
|
|
2697
|
+
fs11.close(fd, () => {
|
|
2698
2698
|
});
|
|
2699
2699
|
});
|
|
2700
2700
|
}
|
|
@@ -3005,7 +3005,7 @@ var require_detect_libc = __commonJS({
|
|
|
3005
3005
|
var require_lib = __commonJS({
|
|
3006
3006
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
3007
3007
|
var isexe = require_isexe();
|
|
3008
|
-
var { join:
|
|
3008
|
+
var { join: join13, delimiter: delimiter2, sep: sep2, posix } = require("path");
|
|
3009
3009
|
var isWindows = process.platform === "win32";
|
|
3010
3010
|
var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
|
|
3011
3011
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -3034,7 +3034,7 @@ var require_lib = __commonJS({
|
|
|
3034
3034
|
var getPathPart = (raw, cmd) => {
|
|
3035
3035
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
3036
3036
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
3037
|
-
return prefix +
|
|
3037
|
+
return prefix + join13(pathPart, cmd);
|
|
3038
3038
|
};
|
|
3039
3039
|
var which2 = async (cmd, opt = {}) => {
|
|
3040
3040
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -3213,6 +3213,7 @@ var src_exports = {};
|
|
|
3213
3213
|
__export(src_exports, {
|
|
3214
3214
|
build: () => build,
|
|
3215
3215
|
defaultShouldServe: () => defaultShouldServe,
|
|
3216
|
+
diagnostics: () => diagnostics,
|
|
3216
3217
|
downloadFilesInWorkPath: () => downloadFilesInWorkPath,
|
|
3217
3218
|
installRequirement: () => installRequirement,
|
|
3218
3219
|
installRequirementsFile: () => installRequirementsFile,
|
|
@@ -3222,15 +3223,15 @@ __export(src_exports, {
|
|
|
3222
3223
|
version: () => version
|
|
3223
3224
|
});
|
|
3224
3225
|
module.exports = __toCommonJS(src_exports);
|
|
3225
|
-
var
|
|
3226
|
-
var
|
|
3226
|
+
var import_fs11 = __toESM(require("fs"));
|
|
3227
|
+
var import_path13 = require("path");
|
|
3227
3228
|
|
|
3228
3229
|
// src/package-versions.ts
|
|
3229
|
-
var VERCEL_RUNTIME_VERSION = "0.
|
|
3230
|
-
var VERCEL_WORKERS_VERSION = "0.0.
|
|
3230
|
+
var VERCEL_RUNTIME_VERSION = "0.10.0";
|
|
3231
|
+
var VERCEL_WORKERS_VERSION = "0.0.13";
|
|
3231
3232
|
|
|
3232
3233
|
// src/index.ts
|
|
3233
|
-
var
|
|
3234
|
+
var import_build_utils14 = require("@vercel/build-utils");
|
|
3234
3235
|
|
|
3235
3236
|
// src/install.ts
|
|
3236
3237
|
var import_execa3 = __toESM(require_execa());
|
|
@@ -4661,19 +4662,261 @@ async function calculatePerPackageSizes(venvPath) {
|
|
|
4661
4662
|
return sizes;
|
|
4662
4663
|
}
|
|
4663
4664
|
|
|
4665
|
+
// src/diagnostics.ts
|
|
4666
|
+
var import_fs5 = __toESM(require("fs"));
|
|
4667
|
+
var import_path7 = require("path");
|
|
4668
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
4669
|
+
var import_python_analysis4 = require("@vercel/python-analysis");
|
|
4670
|
+
var MANIFEST_FILENAME = "package-manifest.json";
|
|
4671
|
+
var DIAGNOSTICS_PATH = (0, import_path7.join)(".vercel", "python", MANIFEST_FILENAME);
|
|
4672
|
+
var MANIFEST_VERSION = "20260304";
|
|
4673
|
+
function isDependencyGroupInclude(entry) {
|
|
4674
|
+
return typeof entry === "object" && "include-group" in entry;
|
|
4675
|
+
}
|
|
4676
|
+
function resolveDependencyGroup(groupName, allGroups, ancestors = /* @__PURE__ */ new Set()) {
|
|
4677
|
+
if (ancestors.has(groupName))
|
|
4678
|
+
return [];
|
|
4679
|
+
const entries = allGroups[groupName];
|
|
4680
|
+
if (!Array.isArray(entries))
|
|
4681
|
+
return [];
|
|
4682
|
+
ancestors.add(groupName);
|
|
4683
|
+
const result = [];
|
|
4684
|
+
for (const entry of entries) {
|
|
4685
|
+
if (typeof entry === "string") {
|
|
4686
|
+
result.push(entry);
|
|
4687
|
+
} else if (isDependencyGroupInclude(entry)) {
|
|
4688
|
+
result.push(
|
|
4689
|
+
...resolveDependencyGroup(entry["include-group"], allGroups, ancestors)
|
|
4690
|
+
);
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
ancestors.delete(groupName);
|
|
4694
|
+
return result;
|
|
4695
|
+
}
|
|
4696
|
+
function mapSource(src) {
|
|
4697
|
+
if (!src)
|
|
4698
|
+
return {};
|
|
4699
|
+
if (src.virtual)
|
|
4700
|
+
return {};
|
|
4701
|
+
if (src.registry) {
|
|
4702
|
+
try {
|
|
4703
|
+
const url = new URL(src.registry);
|
|
4704
|
+
return { source: "registry", sourceUrl: url.origin };
|
|
4705
|
+
} catch {
|
|
4706
|
+
return { source: "registry", sourceUrl: src.registry };
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
if (src.git)
|
|
4710
|
+
return { source: "git", sourceUrl: src.git };
|
|
4711
|
+
if (src.url)
|
|
4712
|
+
return { source: "url", sourceUrl: src.url };
|
|
4713
|
+
if (src.editable)
|
|
4714
|
+
return { source: "editable", sourceUrl: src.editable };
|
|
4715
|
+
if (src.path)
|
|
4716
|
+
return { source: "path", sourceUrl: src.path };
|
|
4717
|
+
return {};
|
|
4718
|
+
}
|
|
4719
|
+
async function generateProjectManifest({
|
|
4720
|
+
workPath,
|
|
4721
|
+
pythonPackage,
|
|
4722
|
+
pythonVersion,
|
|
4723
|
+
uvLockPath
|
|
4724
|
+
}) {
|
|
4725
|
+
const resolved = pythonVersionString(pythonVersion);
|
|
4726
|
+
const constraint = pythonPackage.requiresPython?.[0];
|
|
4727
|
+
const requested = constraint?.specifier;
|
|
4728
|
+
const project = pythonPackage.manifest?.data?.project;
|
|
4729
|
+
const pyprojectData = pythonPackage.manifest?.data;
|
|
4730
|
+
const directScopesMap = /* @__PURE__ */ new Map();
|
|
4731
|
+
const directRequested = /* @__PURE__ */ new Map();
|
|
4732
|
+
const allRawDeps = [];
|
|
4733
|
+
if (project?.dependencies && Array.isArray(project.dependencies)) {
|
|
4734
|
+
for (const dep of project.dependencies) {
|
|
4735
|
+
allRawDeps.push({ dep, scope: "main" });
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
const optDeps = project?.["optional-dependencies"];
|
|
4739
|
+
if (optDeps) {
|
|
4740
|
+
for (const [group, deps] of Object.entries(optDeps)) {
|
|
4741
|
+
if (Array.isArray(deps)) {
|
|
4742
|
+
for (const dep of deps) {
|
|
4743
|
+
allRawDeps.push({ dep, scope: group });
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
const depGroups = pyprojectData?.["dependency-groups"];
|
|
4749
|
+
if (depGroups) {
|
|
4750
|
+
for (const group of Object.keys(depGroups)) {
|
|
4751
|
+
const groupDeps = resolveDependencyGroup(group, depGroups);
|
|
4752
|
+
for (const dep of groupDeps) {
|
|
4753
|
+
allRawDeps.push({ dep, scope: group });
|
|
4754
|
+
}
|
|
4755
|
+
}
|
|
4756
|
+
}
|
|
4757
|
+
const uvDevDeps = pyprojectData?.tool?.uv?.["dev-dependencies"];
|
|
4758
|
+
if (uvDevDeps && Array.isArray(uvDevDeps)) {
|
|
4759
|
+
for (const dep of uvDevDeps) {
|
|
4760
|
+
allRawDeps.push({ dep, scope: "dev" });
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
const allParsed = await (0, import_python_analysis4.parsePep508)(allRawDeps.map((d) => d.dep));
|
|
4764
|
+
for (let i = 0; i < allRawDeps.length; i++) {
|
|
4765
|
+
const parsed = allParsed[i];
|
|
4766
|
+
if (!parsed)
|
|
4767
|
+
continue;
|
|
4768
|
+
const { dep, scope } = allRawDeps[i];
|
|
4769
|
+
const normalized = (0, import_python_analysis4.normalizePackageName)(parsed.name);
|
|
4770
|
+
let scopes = directScopesMap.get(normalized);
|
|
4771
|
+
if (!scopes) {
|
|
4772
|
+
scopes = /* @__PURE__ */ new Set();
|
|
4773
|
+
directScopesMap.set(normalized, scopes);
|
|
4774
|
+
}
|
|
4775
|
+
scopes.add(scope);
|
|
4776
|
+
if (!directRequested.has(normalized)) {
|
|
4777
|
+
directRequested.set(normalized, dep);
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
const directEntries = [];
|
|
4781
|
+
const transitiveEntries = [];
|
|
4782
|
+
{
|
|
4783
|
+
const content = await import_fs5.default.promises.readFile(uvLockPath, "utf-8");
|
|
4784
|
+
const uvLock = (0, import_python_analysis4.parseUvLock)(content, uvLockPath);
|
|
4785
|
+
const projectName = project?.name;
|
|
4786
|
+
const excludeSet = new Set(
|
|
4787
|
+
projectName ? [(0, import_python_analysis4.normalizePackageName)(projectName)] : []
|
|
4788
|
+
);
|
|
4789
|
+
const lockMap = /* @__PURE__ */ new Map();
|
|
4790
|
+
const depGraph = /* @__PURE__ */ new Map();
|
|
4791
|
+
for (const pkg of uvLock.packages) {
|
|
4792
|
+
const normalized = (0, import_python_analysis4.normalizePackageName)(pkg.name);
|
|
4793
|
+
if (excludeSet.has(normalized))
|
|
4794
|
+
continue;
|
|
4795
|
+
if (pkg.source?.virtual)
|
|
4796
|
+
continue;
|
|
4797
|
+
lockMap.set(normalized, { version: pkg.version, source: pkg.source });
|
|
4798
|
+
if (pkg.dependencies) {
|
|
4799
|
+
const deps = /* @__PURE__ */ new Set();
|
|
4800
|
+
for (const d of pkg.dependencies) {
|
|
4801
|
+
deps.add((0, import_python_analysis4.normalizePackageName)(d.name));
|
|
4802
|
+
}
|
|
4803
|
+
depGraph.set(normalized, deps);
|
|
4804
|
+
}
|
|
4805
|
+
}
|
|
4806
|
+
const transitiveScopesMap = /* @__PURE__ */ new Map();
|
|
4807
|
+
for (const [name, scopes] of directScopesMap) {
|
|
4808
|
+
const queue = [name];
|
|
4809
|
+
let head = 0;
|
|
4810
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4811
|
+
while (head < queue.length) {
|
|
4812
|
+
const current = queue[head++];
|
|
4813
|
+
if (visited.has(current))
|
|
4814
|
+
continue;
|
|
4815
|
+
visited.add(current);
|
|
4816
|
+
const children = depGraph.get(current);
|
|
4817
|
+
if (!children)
|
|
4818
|
+
continue;
|
|
4819
|
+
for (const child of children) {
|
|
4820
|
+
if (excludeSet.has(child))
|
|
4821
|
+
continue;
|
|
4822
|
+
if (!directScopesMap.has(child)) {
|
|
4823
|
+
let childScopes = transitiveScopesMap.get(child);
|
|
4824
|
+
if (!childScopes) {
|
|
4825
|
+
childScopes = /* @__PURE__ */ new Set();
|
|
4826
|
+
transitiveScopesMap.set(child, childScopes);
|
|
4827
|
+
}
|
|
4828
|
+
for (const s of scopes) {
|
|
4829
|
+
childScopes.add(s);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
if (!visited.has(child)) {
|
|
4833
|
+
queue.push(child);
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
for (const [name, scopes] of directScopesMap) {
|
|
4839
|
+
const info = lockMap.get(name);
|
|
4840
|
+
const entry = {
|
|
4841
|
+
name,
|
|
4842
|
+
type: "direct",
|
|
4843
|
+
scopes: [...scopes].sort(),
|
|
4844
|
+
requested: directRequested.get(name)
|
|
4845
|
+
};
|
|
4846
|
+
if (info) {
|
|
4847
|
+
entry.resolved = info.version;
|
|
4848
|
+
const src = mapSource(info.source);
|
|
4849
|
+
if (src.source)
|
|
4850
|
+
entry.source = src.source;
|
|
4851
|
+
if (src.sourceUrl)
|
|
4852
|
+
entry.sourceUrl = src.sourceUrl;
|
|
4853
|
+
}
|
|
4854
|
+
directEntries.push(entry);
|
|
4855
|
+
}
|
|
4856
|
+
for (const [normalized, info] of lockMap) {
|
|
4857
|
+
if (directScopesMap.has(normalized))
|
|
4858
|
+
continue;
|
|
4859
|
+
const scopes = transitiveScopesMap.get(normalized);
|
|
4860
|
+
if (!scopes || scopes.size === 0)
|
|
4861
|
+
continue;
|
|
4862
|
+
const src = mapSource(info.source);
|
|
4863
|
+
transitiveEntries.push({
|
|
4864
|
+
name: normalized,
|
|
4865
|
+
type: "transitive",
|
|
4866
|
+
scopes: [...scopes].sort(),
|
|
4867
|
+
resolved: info.version,
|
|
4868
|
+
...src.source ? { source: src.source } : {},
|
|
4869
|
+
...src.sourceUrl ? { sourceUrl: src.sourceUrl } : {}
|
|
4870
|
+
});
|
|
4871
|
+
}
|
|
4872
|
+
}
|
|
4873
|
+
const manifest = {
|
|
4874
|
+
version: MANIFEST_VERSION,
|
|
4875
|
+
runtime: "python",
|
|
4876
|
+
runtimeVersion: {
|
|
4877
|
+
...requested ? { requested } : {},
|
|
4878
|
+
...constraint?.source ? { requestedSource: constraint.source } : {},
|
|
4879
|
+
resolved
|
|
4880
|
+
},
|
|
4881
|
+
dependencies: [
|
|
4882
|
+
...directEntries.sort((a, b) => a.name.localeCompare(b.name)),
|
|
4883
|
+
...transitiveEntries.sort((a, b) => a.name.localeCompare(b.name))
|
|
4884
|
+
]
|
|
4885
|
+
};
|
|
4886
|
+
const outPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
|
|
4887
|
+
await import_fs5.default.promises.mkdir((0, import_path7.dirname)(outPath), { recursive: true });
|
|
4888
|
+
await import_fs5.default.promises.writeFile(outPath, JSON.stringify(manifest, null, 2));
|
|
4889
|
+
}
|
|
4890
|
+
var diagnostics = async ({
|
|
4891
|
+
workPath
|
|
4892
|
+
}) => {
|
|
4893
|
+
try {
|
|
4894
|
+
const manifestPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
|
|
4895
|
+
const data = await import_fs5.default.promises.readFile(manifestPath, "utf-8");
|
|
4896
|
+
return {
|
|
4897
|
+
[MANIFEST_FILENAME]: new import_build_utils6.FileBlob({ data })
|
|
4898
|
+
};
|
|
4899
|
+
} catch (err) {
|
|
4900
|
+
(0, import_build_utils6.debug)(
|
|
4901
|
+
`Diagnostics: no cached manifest found: ${err instanceof Error ? err.message : String(err)}`
|
|
4902
|
+
);
|
|
4903
|
+
return {};
|
|
4904
|
+
}
|
|
4905
|
+
};
|
|
4906
|
+
|
|
4664
4907
|
// src/start-dev-server.ts
|
|
4665
4908
|
var import_child_process2 = require("child_process");
|
|
4666
|
-
var
|
|
4667
|
-
var
|
|
4668
|
-
var
|
|
4909
|
+
var import_fs7 = require("fs");
|
|
4910
|
+
var import_path9 = require("path");
|
|
4911
|
+
var import_build_utils9 = require("@vercel/build-utils");
|
|
4669
4912
|
var import_get_port = __toESM(require_get_port());
|
|
4670
4913
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
4671
4914
|
|
|
4672
4915
|
// src/entrypoint.ts
|
|
4673
|
-
var
|
|
4674
|
-
var
|
|
4675
|
-
var import_build_utils6 = require("@vercel/build-utils");
|
|
4916
|
+
var import_fs6 = __toESM(require("fs"));
|
|
4917
|
+
var import_path8 = require("path");
|
|
4676
4918
|
var import_build_utils7 = require("@vercel/build-utils");
|
|
4919
|
+
var import_build_utils8 = require("@vercel/build-utils");
|
|
4677
4920
|
var PYTHON_ENTRYPOINT_FILENAMES = [
|
|
4678
4921
|
"app",
|
|
4679
4922
|
"index",
|
|
@@ -4689,26 +4932,26 @@ var PYTHON_CANDIDATE_ENTRYPOINTS = getCandidateEntrypointsInDirs(
|
|
|
4689
4932
|
function getCandidateEntrypointsInDirs(dirs) {
|
|
4690
4933
|
return dirs.flatMap(
|
|
4691
4934
|
(dir) => PYTHON_ENTRYPOINT_FILENAMES.map(
|
|
4692
|
-
(filename) =>
|
|
4935
|
+
(filename) => import_path8.posix.join(dir, `${filename}.py`)
|
|
4693
4936
|
)
|
|
4694
4937
|
);
|
|
4695
4938
|
}
|
|
4696
4939
|
async function fileExists(filePath) {
|
|
4697
4940
|
try {
|
|
4698
|
-
const stat = await
|
|
4941
|
+
const stat = await import_fs6.default.promises.stat(filePath);
|
|
4699
4942
|
return stat.isFile();
|
|
4700
4943
|
} catch {
|
|
4701
4944
|
return false;
|
|
4702
4945
|
}
|
|
4703
4946
|
}
|
|
4704
4947
|
async function checkEntrypoint(workPath, relPath) {
|
|
4705
|
-
const absPath = (0,
|
|
4948
|
+
const absPath = (0, import_path8.join)(workPath, relPath);
|
|
4706
4949
|
if (!await fileExists(absPath))
|
|
4707
4950
|
return false;
|
|
4708
|
-
return (0,
|
|
4951
|
+
return (0, import_build_utils7.isPythonEntrypoint)({ fsPath: absPath });
|
|
4709
4952
|
}
|
|
4710
4953
|
async function getPyprojectEntrypoint(workPath) {
|
|
4711
|
-
const pyprojectData = await (0,
|
|
4954
|
+
const pyprojectData = await (0, import_build_utils8.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
|
|
4712
4955
|
if (!pyprojectData)
|
|
4713
4956
|
return null;
|
|
4714
4957
|
const scripts = pyprojectData.project?.scripts;
|
|
@@ -4719,30 +4962,32 @@ async function getPyprojectEntrypoint(workPath) {
|
|
|
4719
4962
|
if (!match)
|
|
4720
4963
|
return null;
|
|
4721
4964
|
const modulePath = match[1];
|
|
4965
|
+
const variableName = match[2];
|
|
4722
4966
|
const relPath = modulePath.replace(/\./g, "/");
|
|
4723
4967
|
const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];
|
|
4724
4968
|
for (const candidate of candidates) {
|
|
4725
|
-
if (await fileExists((0,
|
|
4726
|
-
return candidate;
|
|
4969
|
+
if (await fileExists((0, import_path8.join)(workPath, candidate))) {
|
|
4970
|
+
return { entrypoint: candidate, variableName };
|
|
4971
|
+
}
|
|
4727
4972
|
}
|
|
4728
4973
|
return null;
|
|
4729
4974
|
}
|
|
4730
4975
|
async function findValidEntrypoint(workPath, candidates) {
|
|
4731
4976
|
for (const candidate of candidates) {
|
|
4732
4977
|
if (await checkEntrypoint(workPath, candidate)) {
|
|
4733
|
-
(0,
|
|
4978
|
+
(0, import_build_utils7.debug)(`Detected Python entrypoint: ${candidate}`);
|
|
4734
4979
|
return candidate;
|
|
4735
4980
|
}
|
|
4736
4981
|
}
|
|
4737
4982
|
return null;
|
|
4738
4983
|
}
|
|
4739
4984
|
async function checkDjangoManage(workPath) {
|
|
4740
|
-
const managePath = (0,
|
|
4985
|
+
const managePath = (0, import_path8.join)(workPath, "manage.py");
|
|
4741
4986
|
try {
|
|
4742
|
-
const content = await
|
|
4987
|
+
const content = await import_fs6.default.promises.readFile(managePath, "utf-8");
|
|
4743
4988
|
if (!content.includes("DJANGO_SETTINGS_MODULE"))
|
|
4744
4989
|
return false;
|
|
4745
|
-
(0,
|
|
4990
|
+
(0, import_build_utils7.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
|
|
4746
4991
|
return true;
|
|
4747
4992
|
} catch {
|
|
4748
4993
|
return false;
|
|
@@ -4750,7 +4995,7 @@ async function checkDjangoManage(workPath) {
|
|
|
4750
4995
|
}
|
|
4751
4996
|
async function getSubdirectories(workPath) {
|
|
4752
4997
|
try {
|
|
4753
|
-
const entries = await
|
|
4998
|
+
const entries = await import_fs6.default.promises.readdir(workPath, {
|
|
4754
4999
|
withFileTypes: true
|
|
4755
5000
|
});
|
|
4756
5001
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
@@ -4762,7 +5007,7 @@ async function detectGenericPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4762
5007
|
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
4763
5008
|
try {
|
|
4764
5009
|
if (await checkEntrypoint(workPath, entry)) {
|
|
4765
|
-
(0,
|
|
5010
|
+
(0, import_build_utils7.debug)(`Using configured Python entrypoint: ${entry}`);
|
|
4766
5011
|
return { entrypoint: entry };
|
|
4767
5012
|
}
|
|
4768
5013
|
const found = await findValidEntrypoint(
|
|
@@ -4771,7 +5016,7 @@ async function detectGenericPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4771
5016
|
);
|
|
4772
5017
|
return found ? { entrypoint: found } : null;
|
|
4773
5018
|
} catch {
|
|
4774
|
-
(0,
|
|
5019
|
+
(0, import_build_utils7.debug)("Failed to discover Python entrypoint");
|
|
4775
5020
|
return null;
|
|
4776
5021
|
}
|
|
4777
5022
|
}
|
|
@@ -4779,13 +5024,13 @@ async function detectDjangoPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4779
5024
|
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
4780
5025
|
try {
|
|
4781
5026
|
if (await checkEntrypoint(workPath, entry)) {
|
|
4782
|
-
(0,
|
|
5027
|
+
(0, import_build_utils7.debug)(`Using configured Python entrypoint: ${entry}`);
|
|
4783
5028
|
return { entrypoint: entry };
|
|
4784
5029
|
}
|
|
4785
5030
|
const subdirs = await getSubdirectories(workPath);
|
|
4786
5031
|
const rootDirs = ["", ...subdirs];
|
|
4787
5032
|
for (const rootDir of rootDirs) {
|
|
4788
|
-
const currPath = (0,
|
|
5033
|
+
const currPath = (0, import_path8.join)(workPath, rootDir);
|
|
4789
5034
|
const isDjango = await checkDjangoManage(currPath);
|
|
4790
5035
|
if (isDjango) {
|
|
4791
5036
|
return { baseDir: rootDir };
|
|
@@ -4795,7 +5040,7 @@ async function detectDjangoPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4795
5040
|
const found = await findValidEntrypoint(workPath, candidates);
|
|
4796
5041
|
return found ? { entrypoint: found } : null;
|
|
4797
5042
|
} catch {
|
|
4798
|
-
(0,
|
|
5043
|
+
(0, import_build_utils7.debug)("Failed to discover Django Python entrypoint");
|
|
4799
5044
|
return null;
|
|
4800
5045
|
}
|
|
4801
5046
|
}
|
|
@@ -4804,11 +5049,16 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint)
|
|
|
4804
5049
|
if (result)
|
|
4805
5050
|
return result;
|
|
4806
5051
|
const pyprojectEntry = await getPyprojectEntrypoint(workPath);
|
|
4807
|
-
|
|
5052
|
+
if (!pyprojectEntry)
|
|
5053
|
+
return null;
|
|
5054
|
+
return {
|
|
5055
|
+
entrypoint: pyprojectEntry.entrypoint,
|
|
5056
|
+
variableName: pyprojectEntry.variableName
|
|
5057
|
+
};
|
|
4808
5058
|
}
|
|
4809
5059
|
|
|
4810
5060
|
// src/start-dev-server.ts
|
|
4811
|
-
var
|
|
5061
|
+
var import_python_analysis5 = require("@vercel/python-analysis");
|
|
4812
5062
|
var DEV_SERVER_STARTUP_TIMEOUT = 5 * 6e4;
|
|
4813
5063
|
function silenceNodeWarnings() {
|
|
4814
5064
|
const original = process.emitWarning.bind(
|
|
@@ -4835,6 +5085,10 @@ function silenceNodeWarnings() {
|
|
|
4835
5085
|
};
|
|
4836
5086
|
}
|
|
4837
5087
|
var DEV_SHIM_MODULE = "vc_init_dev";
|
|
5088
|
+
function hasWorkerServicesEnabled(env) {
|
|
5089
|
+
const value = env.VERCEL_HAS_WORKER_SERVICES || "";
|
|
5090
|
+
return ["1", "true"].includes(value.trim().toLowerCase());
|
|
5091
|
+
}
|
|
4838
5092
|
function createLogListener(callback, stream) {
|
|
4839
5093
|
return (buf) => {
|
|
4840
5094
|
if (callback) {
|
|
@@ -4890,17 +5144,17 @@ async function syncDependencies({
|
|
|
4890
5144
|
let { manifestPath } = installInfo;
|
|
4891
5145
|
const manifest = pythonPackage.manifest;
|
|
4892
5146
|
if (!manifestType || !manifestPath) {
|
|
4893
|
-
(0,
|
|
5147
|
+
(0, import_build_utils9.debug)("No Python project manifest found, skipping dependency sync");
|
|
4894
5148
|
return;
|
|
4895
5149
|
}
|
|
4896
5150
|
if (manifest?.origin && manifestType === "pyproject.toml") {
|
|
4897
|
-
const syncDir = (0,
|
|
4898
|
-
(0,
|
|
4899
|
-
const tempPyproject = (0,
|
|
4900
|
-
const content = (0,
|
|
4901
|
-
(0,
|
|
5151
|
+
const syncDir = (0, import_path9.join)(workPath, ".vercel", "python", "sync");
|
|
5152
|
+
(0, import_fs7.mkdirSync)(syncDir, { recursive: true });
|
|
5153
|
+
const tempPyproject = (0, import_path9.join)(syncDir, "pyproject.toml");
|
|
5154
|
+
const content = (0, import_python_analysis5.stringifyManifest)(manifest.data);
|
|
5155
|
+
(0, import_fs7.writeFileSync)(tempPyproject, content, "utf8");
|
|
4902
5156
|
manifestPath = tempPyproject;
|
|
4903
|
-
(0,
|
|
5157
|
+
(0, import_build_utils9.debug)(
|
|
4904
5158
|
`Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
|
|
4905
5159
|
);
|
|
4906
5160
|
}
|
|
@@ -4933,7 +5187,7 @@ async function syncDependencies({
|
|
|
4933
5187
|
for (const [channel, chunk] of captured) {
|
|
4934
5188
|
(channel === "stdout" ? writeOut : writeErr)(chunk.toString());
|
|
4935
5189
|
}
|
|
4936
|
-
throw new
|
|
5190
|
+
throw new import_build_utils9.NowBuildError({
|
|
4937
5191
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
4938
5192
|
message: `Failed to install Python dependencies from ${manifestType}: ${err instanceof Error ? err.message : String(err)}`
|
|
4939
5193
|
});
|
|
@@ -4948,14 +5202,14 @@ async function runSync({
|
|
|
4948
5202
|
onStdout,
|
|
4949
5203
|
onStderr
|
|
4950
5204
|
}) {
|
|
4951
|
-
const projectDir = (0,
|
|
5205
|
+
const projectDir = (0, import_path9.dirname)(manifestPath);
|
|
4952
5206
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
4953
5207
|
let spawnCmd;
|
|
4954
5208
|
let spawnArgs;
|
|
4955
5209
|
switch (manifestType) {
|
|
4956
5210
|
case "uv.lock": {
|
|
4957
5211
|
if (!uvPath) {
|
|
4958
|
-
throw new
|
|
5212
|
+
throw new import_build_utils9.NowBuildError({
|
|
4959
5213
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
4960
5214
|
message: "uv is required to install dependencies from uv.lock.",
|
|
4961
5215
|
link: "https://docs.astral.sh/uv/getting-started/installation/",
|
|
@@ -4977,11 +5231,11 @@ async function runSync({
|
|
|
4977
5231
|
break;
|
|
4978
5232
|
}
|
|
4979
5233
|
default:
|
|
4980
|
-
(0,
|
|
5234
|
+
(0, import_build_utils9.debug)(`Unknown manifest type: ${manifestType}`);
|
|
4981
5235
|
return;
|
|
4982
5236
|
}
|
|
4983
5237
|
await new Promise((resolve3, reject) => {
|
|
4984
|
-
(0,
|
|
5238
|
+
(0, import_build_utils9.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
|
|
4985
5239
|
const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
|
|
4986
5240
|
cwd: projectDir,
|
|
4987
5241
|
env: getProtectedUvEnv(env),
|
|
@@ -5016,6 +5270,7 @@ async function runSync({
|
|
|
5016
5270
|
});
|
|
5017
5271
|
}
|
|
5018
5272
|
var PENDING_RUNTIME_INSTALLS = /* @__PURE__ */ new Map();
|
|
5273
|
+
var PENDING_WORKERS_INSTALLS = /* @__PURE__ */ new Map();
|
|
5019
5274
|
async function installVercelRuntime({
|
|
5020
5275
|
workPath,
|
|
5021
5276
|
uvPath,
|
|
@@ -5024,7 +5279,7 @@ async function installVercelRuntime({
|
|
|
5024
5279
|
onStdout,
|
|
5025
5280
|
onStderr
|
|
5026
5281
|
}) {
|
|
5027
|
-
const targetDir = (0,
|
|
5282
|
+
const targetDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5028
5283
|
let pending = PENDING_RUNTIME_INSTALLS.get(targetDir);
|
|
5029
5284
|
if (!pending) {
|
|
5030
5285
|
pending = doInstallVercelRuntime({
|
|
@@ -5050,8 +5305,8 @@ async function doInstallVercelRuntime({
|
|
|
5050
5305
|
onStdout,
|
|
5051
5306
|
onStderr
|
|
5052
5307
|
}) {
|
|
5053
|
-
(0,
|
|
5054
|
-
const localRuntimeDir = (0,
|
|
5308
|
+
(0, import_fs7.mkdirSync)(targetDir, { recursive: true });
|
|
5309
|
+
const localRuntimeDir = (0, import_path9.join)(
|
|
5055
5310
|
__dirname,
|
|
5056
5311
|
"..",
|
|
5057
5312
|
"..",
|
|
@@ -5059,21 +5314,21 @@ async function doInstallVercelRuntime({
|
|
|
5059
5314
|
"python",
|
|
5060
5315
|
"vercel-runtime"
|
|
5061
5316
|
);
|
|
5062
|
-
const isLocalDev = (0,
|
|
5317
|
+
const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localRuntimeDir, "pyproject.toml"));
|
|
5063
5318
|
const runtimeDep = env.VERCEL_RUNTIME_PYTHON || (isLocalDev ? localRuntimeDir : `vercel-runtime==${VERCEL_RUNTIME_VERSION}`);
|
|
5064
5319
|
if (!isLocalDev && !env.VERCEL_RUNTIME_PYTHON) {
|
|
5065
|
-
const distInfo = (0,
|
|
5320
|
+
const distInfo = (0, import_path9.join)(
|
|
5066
5321
|
targetDir,
|
|
5067
5322
|
`vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
|
|
5068
5323
|
);
|
|
5069
|
-
if ((0,
|
|
5070
|
-
(0,
|
|
5324
|
+
if ((0, import_fs7.existsSync)(distInfo)) {
|
|
5325
|
+
(0, import_build_utils9.debug)(
|
|
5071
5326
|
`vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
|
|
5072
5327
|
);
|
|
5073
5328
|
return;
|
|
5074
5329
|
}
|
|
5075
5330
|
}
|
|
5076
|
-
(0,
|
|
5331
|
+
(0, import_build_utils9.debug)(
|
|
5077
5332
|
`Installing vercel-runtime into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${runtimeDep})`
|
|
5078
5333
|
);
|
|
5079
5334
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
@@ -5088,14 +5343,14 @@ async function doInstallVercelRuntime({
|
|
|
5088
5343
|
if (onStdout) {
|
|
5089
5344
|
onStdout(data);
|
|
5090
5345
|
} else {
|
|
5091
|
-
(0,
|
|
5346
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5092
5347
|
}
|
|
5093
5348
|
});
|
|
5094
5349
|
child.stderr?.on("data", (data) => {
|
|
5095
5350
|
if (onStderr) {
|
|
5096
5351
|
onStderr(data);
|
|
5097
5352
|
} else {
|
|
5098
|
-
(0,
|
|
5353
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5099
5354
|
}
|
|
5100
5355
|
});
|
|
5101
5356
|
child.on("error", reject);
|
|
@@ -5112,6 +5367,102 @@ async function doInstallVercelRuntime({
|
|
|
5112
5367
|
});
|
|
5113
5368
|
});
|
|
5114
5369
|
}
|
|
5370
|
+
async function installVercelWorkers({
|
|
5371
|
+
workPath,
|
|
5372
|
+
uvPath,
|
|
5373
|
+
pythonBin,
|
|
5374
|
+
env,
|
|
5375
|
+
onStdout,
|
|
5376
|
+
onStderr
|
|
5377
|
+
}) {
|
|
5378
|
+
const targetDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5379
|
+
let pending = PENDING_WORKERS_INSTALLS.get(targetDir);
|
|
5380
|
+
if (!pending) {
|
|
5381
|
+
pending = doInstallVercelWorkers({
|
|
5382
|
+
targetDir,
|
|
5383
|
+
workPath,
|
|
5384
|
+
uvPath,
|
|
5385
|
+
pythonBin,
|
|
5386
|
+
env,
|
|
5387
|
+
onStdout,
|
|
5388
|
+
onStderr
|
|
5389
|
+
});
|
|
5390
|
+
PENDING_WORKERS_INSTALLS.set(targetDir, pending);
|
|
5391
|
+
pending.finally(() => PENDING_WORKERS_INSTALLS.delete(targetDir));
|
|
5392
|
+
}
|
|
5393
|
+
await pending;
|
|
5394
|
+
}
|
|
5395
|
+
async function doInstallVercelWorkers({
|
|
5396
|
+
targetDir,
|
|
5397
|
+
workPath,
|
|
5398
|
+
uvPath,
|
|
5399
|
+
pythonBin,
|
|
5400
|
+
env,
|
|
5401
|
+
onStdout,
|
|
5402
|
+
onStderr
|
|
5403
|
+
}) {
|
|
5404
|
+
(0, import_fs7.mkdirSync)(targetDir, { recursive: true });
|
|
5405
|
+
const localWorkersDir = (0, import_path9.join)(
|
|
5406
|
+
__dirname,
|
|
5407
|
+
"..",
|
|
5408
|
+
"..",
|
|
5409
|
+
"..",
|
|
5410
|
+
"python",
|
|
5411
|
+
"vercel-workers"
|
|
5412
|
+
);
|
|
5413
|
+
const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localWorkersDir, "pyproject.toml"));
|
|
5414
|
+
const workersDep = env.VERCEL_WORKERS_PYTHON || (isLocalDev ? localWorkersDir : `vercel-workers==${VERCEL_WORKERS_VERSION}`);
|
|
5415
|
+
if (!isLocalDev && !env.VERCEL_WORKERS_PYTHON) {
|
|
5416
|
+
const distInfo = (0, import_path9.join)(
|
|
5417
|
+
targetDir,
|
|
5418
|
+
`vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
|
|
5419
|
+
);
|
|
5420
|
+
if ((0, import_fs7.existsSync)(distInfo)) {
|
|
5421
|
+
(0, import_build_utils9.debug)(
|
|
5422
|
+
`vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
|
|
5423
|
+
);
|
|
5424
|
+
return;
|
|
5425
|
+
}
|
|
5426
|
+
}
|
|
5427
|
+
(0, import_build_utils9.debug)(
|
|
5428
|
+
`Installing vercel-workers into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${workersDep})`
|
|
5429
|
+
);
|
|
5430
|
+
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
5431
|
+
const spawnArgs = [...pip.prefix, "--target", targetDir, workersDep];
|
|
5432
|
+
await new Promise((resolve3, reject) => {
|
|
5433
|
+
const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
|
|
5434
|
+
cwd: workPath,
|
|
5435
|
+
env: getProtectedUvEnv(env),
|
|
5436
|
+
stdio: ["inherit", "pipe", "pipe"]
|
|
5437
|
+
});
|
|
5438
|
+
child.stdout?.on("data", (data) => {
|
|
5439
|
+
if (onStdout) {
|
|
5440
|
+
onStdout(data);
|
|
5441
|
+
} else {
|
|
5442
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5443
|
+
}
|
|
5444
|
+
});
|
|
5445
|
+
child.stderr?.on("data", (data) => {
|
|
5446
|
+
if (onStderr) {
|
|
5447
|
+
onStderr(data);
|
|
5448
|
+
} else {
|
|
5449
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5450
|
+
}
|
|
5451
|
+
});
|
|
5452
|
+
child.on("error", reject);
|
|
5453
|
+
child.on("exit", (code, signal) => {
|
|
5454
|
+
if (code === 0) {
|
|
5455
|
+
resolve3();
|
|
5456
|
+
} else {
|
|
5457
|
+
reject(
|
|
5458
|
+
new Error(
|
|
5459
|
+
`Installing vercel-workers failed with code ${code}, signal ${signal}`
|
|
5460
|
+
)
|
|
5461
|
+
);
|
|
5462
|
+
}
|
|
5463
|
+
});
|
|
5464
|
+
});
|
|
5465
|
+
}
|
|
5115
5466
|
var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
|
|
5116
5467
|
var PENDING_STARTS = /* @__PURE__ */ new Map();
|
|
5117
5468
|
var restoreWarnings = null;
|
|
@@ -5125,12 +5476,12 @@ function installGlobalCleanupHandlers() {
|
|
|
5125
5476
|
try {
|
|
5126
5477
|
process.kill(info.pid, "SIGTERM");
|
|
5127
5478
|
} catch (err) {
|
|
5128
|
-
(0,
|
|
5479
|
+
(0, import_build_utils9.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
5129
5480
|
}
|
|
5130
5481
|
try {
|
|
5131
5482
|
process.kill(info.pid, "SIGKILL");
|
|
5132
5483
|
} catch (err) {
|
|
5133
|
-
(0,
|
|
5484
|
+
(0, import_build_utils9.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
5134
5485
|
}
|
|
5135
5486
|
PERSISTENT_SERVERS.delete(key);
|
|
5136
5487
|
}
|
|
@@ -5138,7 +5489,7 @@ function installGlobalCleanupHandlers() {
|
|
|
5138
5489
|
try {
|
|
5139
5490
|
restoreWarnings();
|
|
5140
5491
|
} catch (err) {
|
|
5141
|
-
(0,
|
|
5492
|
+
(0, import_build_utils9.debug)(`Error restoring warnings: ${err}`);
|
|
5142
5493
|
}
|
|
5143
5494
|
restoreWarnings = null;
|
|
5144
5495
|
}
|
|
@@ -5153,52 +5504,52 @@ function installGlobalCleanupHandlers() {
|
|
|
5153
5504
|
killAll();
|
|
5154
5505
|
});
|
|
5155
5506
|
}
|
|
5156
|
-
function createDevShim(workPath, entry, modulePath, serviceName, framework) {
|
|
5507
|
+
function createDevShim(workPath, entry, modulePath, serviceName, framework, variableName) {
|
|
5157
5508
|
try {
|
|
5158
|
-
const vercelPythonDir = serviceName ? (0,
|
|
5159
|
-
(0,
|
|
5509
|
+
const vercelPythonDir = serviceName ? (0, import_path9.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5510
|
+
(0, import_fs7.mkdirSync)(vercelPythonDir, { recursive: true });
|
|
5160
5511
|
let qualifiedModule = modulePath;
|
|
5161
5512
|
let extraPythonPath;
|
|
5162
|
-
if ((0,
|
|
5163
|
-
const pkgName = (0,
|
|
5513
|
+
if ((0, import_fs7.existsSync)((0, import_path9.join)(workPath, "__init__.py"))) {
|
|
5514
|
+
const pkgName = (0, import_path9.basename)(workPath);
|
|
5164
5515
|
qualifiedModule = `${pkgName}.${modulePath}`;
|
|
5165
|
-
extraPythonPath = (0,
|
|
5516
|
+
extraPythonPath = (0, import_path9.dirname)(workPath);
|
|
5166
5517
|
}
|
|
5167
|
-
const entryAbs = (0,
|
|
5168
|
-
const shimPath = (0,
|
|
5169
|
-
const templatePath = (0,
|
|
5518
|
+
const entryAbs = (0, import_path9.join)(workPath, entry);
|
|
5519
|
+
const shimPath = (0, import_path9.join)(vercelPythonDir, `${DEV_SHIM_MODULE}.py`);
|
|
5520
|
+
const templatePath = (0, import_path9.join)(
|
|
5170
5521
|
__dirname,
|
|
5171
5522
|
"..",
|
|
5172
5523
|
"templates",
|
|
5173
5524
|
`${DEV_SHIM_MODULE}.py`
|
|
5174
5525
|
);
|
|
5175
|
-
const template = (0,
|
|
5176
|
-
const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs).replace(/__VC_DEV_FRAMEWORK__/g, framework);
|
|
5177
|
-
(0,
|
|
5178
|
-
(0,
|
|
5526
|
+
const template = (0, import_fs7.readFileSync)(templatePath, "utf8");
|
|
5527
|
+
const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs).replace(/__VC_DEV_FRAMEWORK__/g, framework).replace(/__VC_DEV_VARIABLE_NAME__/g, variableName);
|
|
5528
|
+
(0, import_fs7.writeFileSync)(shimPath, shimSource, "utf8");
|
|
5529
|
+
(0, import_build_utils9.debug)(`Prepared Python dev shim at ${shimPath}`);
|
|
5179
5530
|
return {
|
|
5180
5531
|
module: DEV_SHIM_MODULE,
|
|
5181
5532
|
extraPythonPath,
|
|
5182
5533
|
shimDir: vercelPythonDir
|
|
5183
5534
|
};
|
|
5184
5535
|
} catch (err) {
|
|
5185
|
-
(0,
|
|
5536
|
+
(0, import_build_utils9.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
|
|
5186
5537
|
return null;
|
|
5187
5538
|
}
|
|
5188
5539
|
}
|
|
5189
5540
|
async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath) {
|
|
5190
5541
|
const { pythonCmd, venvRoot } = useVirtualEnv(workPath, env, systemPython);
|
|
5191
5542
|
if (venvRoot) {
|
|
5192
|
-
(0,
|
|
5543
|
+
(0, import_build_utils9.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
|
|
5193
5544
|
return { command: pythonCmd, args: [] };
|
|
5194
5545
|
}
|
|
5195
|
-
const venvPath = (0,
|
|
5546
|
+
const venvPath = (0, import_path9.join)(workPath, ".venv");
|
|
5196
5547
|
await ensureVenv({ pythonPath: systemPython, venvPath, uvPath, quiet: true });
|
|
5197
|
-
(0,
|
|
5548
|
+
(0, import_build_utils9.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
|
|
5198
5549
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
5199
5550
|
const binDir = getVenvBinDir(venvPath);
|
|
5200
5551
|
env.VIRTUAL_ENV = venvPath;
|
|
5201
|
-
env.PATH = `${binDir}${
|
|
5552
|
+
env.PATH = `${binDir}${import_path9.delimiter}${env.PATH || ""}`;
|
|
5202
5553
|
return { command: pythonBin, args: [] };
|
|
5203
5554
|
}
|
|
5204
5555
|
var startDevServer = async (opts) => {
|
|
@@ -5243,6 +5594,7 @@ var startDevServer = async (opts) => {
|
|
|
5243
5594
|
const env = { ...process.env, ...meta.env || {} };
|
|
5244
5595
|
const serviceType = env.VERCEL_SERVICE_TYPE;
|
|
5245
5596
|
let entry;
|
|
5597
|
+
let variableName;
|
|
5246
5598
|
if ((serviceType === "cron" || serviceType === "worker") && rawEntrypoint?.endsWith(".py")) {
|
|
5247
5599
|
entry = rawEntrypoint;
|
|
5248
5600
|
} else {
|
|
@@ -5252,19 +5604,21 @@ var startDevServer = async (opts) => {
|
|
|
5252
5604
|
rawEntrypoint
|
|
5253
5605
|
);
|
|
5254
5606
|
entry = detected?.entrypoint;
|
|
5607
|
+
variableName = detected?.variableName;
|
|
5255
5608
|
if (!entry) {
|
|
5256
5609
|
const hookResult = await runFrameworkHook(framework, {
|
|
5257
5610
|
pythonEnv: env,
|
|
5258
|
-
projectDir: (0,
|
|
5611
|
+
projectDir: (0, import_path9.join)(workPath, detected?.baseDir ?? ""),
|
|
5259
5612
|
workPath,
|
|
5260
5613
|
entrypoint: rawEntrypoint,
|
|
5261
5614
|
detected: detected ?? void 0
|
|
5262
5615
|
});
|
|
5263
5616
|
entry = hookResult?.entrypoint;
|
|
5617
|
+
variableName = hookResult?.variableName;
|
|
5264
5618
|
}
|
|
5265
5619
|
if (!entry) {
|
|
5266
5620
|
const searched = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
5267
|
-
throw new
|
|
5621
|
+
throw new import_build_utils9.NowBuildError({
|
|
5268
5622
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
5269
5623
|
message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searched}.`,
|
|
5270
5624
|
link: `https://vercel.com/docs/frameworks/backend/${framework?.toLowerCase()}#exporting-the-${framework?.toLowerCase()}-application`,
|
|
@@ -5295,7 +5649,7 @@ var startDevServer = async (opts) => {
|
|
|
5295
5649
|
const yellow = "\x1B[33m";
|
|
5296
5650
|
const white = "\x1B[1m";
|
|
5297
5651
|
const reset = "\x1B[0m";
|
|
5298
|
-
throw new
|
|
5652
|
+
throw new import_build_utils9.NowBuildError({
|
|
5299
5653
|
code: "PYTHON_EXTERNAL_VENV_DETECTED",
|
|
5300
5654
|
message: `Detected activated venv at ${yellow}${venv}${reset}, ${white}vercel dev${reset} manages virtual environments automatically.
|
|
5301
5655
|
Run ${white}deactivate${reset} and try again.`
|
|
@@ -5312,11 +5666,11 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
5312
5666
|
);
|
|
5313
5667
|
spawnCommand = runner.command;
|
|
5314
5668
|
spawnArgsPrefix = runner.args;
|
|
5315
|
-
(0,
|
|
5669
|
+
(0, import_build_utils9.debug)(
|
|
5316
5670
|
`Multi-service Python runner: ${spawnCommand} ${spawnArgsPrefix.join(" ")}`
|
|
5317
5671
|
);
|
|
5318
5672
|
} else if (venv) {
|
|
5319
|
-
(0,
|
|
5673
|
+
(0, import_build_utils9.debug)(`Running in virtualenv at ${venv}`);
|
|
5320
5674
|
} else {
|
|
5321
5675
|
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
5322
5676
|
workPath,
|
|
@@ -5325,9 +5679,9 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
5325
5679
|
);
|
|
5326
5680
|
spawnCommand = venvPythonCmd;
|
|
5327
5681
|
if (venvRoot) {
|
|
5328
|
-
(0,
|
|
5682
|
+
(0, import_build_utils9.debug)(`Using virtualenv at ${venvRoot}`);
|
|
5329
5683
|
} else {
|
|
5330
|
-
(0,
|
|
5684
|
+
(0, import_build_utils9.debug)("No virtualenv found");
|
|
5331
5685
|
try {
|
|
5332
5686
|
const yellow = "\x1B[33m";
|
|
5333
5687
|
const reset = "\x1B[0m";
|
|
@@ -5366,24 +5720,35 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5366
5720
|
pythonBin: spawnCommand,
|
|
5367
5721
|
env
|
|
5368
5722
|
});
|
|
5723
|
+
if (hasWorkerServicesEnabled(env)) {
|
|
5724
|
+
await installVercelWorkers({
|
|
5725
|
+
workPath,
|
|
5726
|
+
uvPath,
|
|
5727
|
+
pythonBin: spawnCommand,
|
|
5728
|
+
env,
|
|
5729
|
+
onStdout,
|
|
5730
|
+
onStderr
|
|
5731
|
+
});
|
|
5732
|
+
}
|
|
5369
5733
|
const port = typeof meta.port === "number" ? meta.port : await (0, import_get_port.default)();
|
|
5370
5734
|
env.PORT = `${port}`;
|
|
5371
5735
|
if (config.handlerFunction && typeof config?.handlerFunction === "string") {
|
|
5372
5736
|
env.__VC_HANDLER_FUNC_NAME = config.handlerFunction;
|
|
5373
5737
|
}
|
|
5374
5738
|
if (entry) {
|
|
5375
|
-
env.__VC_HANDLER_ENTRYPOINT_ABS = (0,
|
|
5739
|
+
env.__VC_HANDLER_ENTRYPOINT_ABS = (0, import_path9.join)(workPath, entry);
|
|
5376
5740
|
}
|
|
5377
5741
|
const devShim = createDevShim(
|
|
5378
5742
|
workPath,
|
|
5379
5743
|
entry,
|
|
5380
5744
|
modulePath,
|
|
5381
5745
|
serviceName,
|
|
5382
|
-
framework
|
|
5746
|
+
framework,
|
|
5747
|
+
variableName ?? ""
|
|
5383
5748
|
);
|
|
5384
5749
|
if (devShim) {
|
|
5385
|
-
const shimDir = devShim.shimDir || (0,
|
|
5386
|
-
const runtimeDir = (0,
|
|
5750
|
+
const shimDir = devShim.shimDir || (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5751
|
+
const runtimeDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5387
5752
|
const pathParts = shimDir !== runtimeDir ? [shimDir, runtimeDir] : [shimDir];
|
|
5388
5753
|
if (devShim.extraPythonPath) {
|
|
5389
5754
|
pathParts.push(devShim.extraPythonPath);
|
|
@@ -5392,12 +5757,12 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5392
5757
|
if (existingPythonPath) {
|
|
5393
5758
|
pathParts.push(existingPythonPath);
|
|
5394
5759
|
}
|
|
5395
|
-
env.PYTHONPATH = pathParts.join(
|
|
5760
|
+
env.PYTHONPATH = pathParts.join(import_path9.delimiter);
|
|
5396
5761
|
}
|
|
5397
5762
|
const moduleToRun = devShim?.module || modulePath;
|
|
5398
5763
|
const pythonArgs = ["-u", "-m", moduleToRun];
|
|
5399
5764
|
const argv = [...spawnArgsPrefix, ...pythonArgs];
|
|
5400
|
-
(0,
|
|
5765
|
+
(0, import_build_utils9.debug)(
|
|
5401
5766
|
`Starting Python dev server (${framework}): ${spawnCommand} ${argv.join(" ")} [PORT=${port}]`
|
|
5402
5767
|
);
|
|
5403
5768
|
if (process.stdout.columns) {
|
|
@@ -5451,8 +5816,8 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5451
5816
|
};
|
|
5452
5817
|
|
|
5453
5818
|
// src/quirks/index.ts
|
|
5454
|
-
var
|
|
5455
|
-
var
|
|
5819
|
+
var import_build_utils12 = require("@vercel/build-utils");
|
|
5820
|
+
var import_python_analysis7 = require("@vercel/python-analysis");
|
|
5456
5821
|
|
|
5457
5822
|
// src/quirks/matplotlib.ts
|
|
5458
5823
|
var matplotlibQuirk = {
|
|
@@ -5465,9 +5830,9 @@ var matplotlibQuirk = {
|
|
|
5465
5830
|
};
|
|
5466
5831
|
|
|
5467
5832
|
// src/quirks/litellm.ts
|
|
5468
|
-
var
|
|
5469
|
-
var
|
|
5470
|
-
var
|
|
5833
|
+
var import_fs8 = __toESM(require("fs"));
|
|
5834
|
+
var import_path10 = require("path");
|
|
5835
|
+
var import_build_utils10 = require("@vercel/build-utils");
|
|
5471
5836
|
var LAMBDA_ROOT = "/var/task";
|
|
5472
5837
|
var CONFIG_CANDIDATES = [
|
|
5473
5838
|
"litellm_config.yaml",
|
|
@@ -5477,9 +5842,9 @@ var CONFIG_CANDIDATES = [
|
|
|
5477
5842
|
];
|
|
5478
5843
|
async function findConfigFile(workPath) {
|
|
5479
5844
|
for (const name of CONFIG_CANDIDATES) {
|
|
5480
|
-
const candidate = (0,
|
|
5845
|
+
const candidate = (0, import_path10.join)(workPath, name);
|
|
5481
5846
|
try {
|
|
5482
|
-
await
|
|
5847
|
+
await import_fs8.default.promises.access(candidate);
|
|
5483
5848
|
return name;
|
|
5484
5849
|
} catch {
|
|
5485
5850
|
}
|
|
@@ -5494,32 +5859,32 @@ var litellmQuirk = {
|
|
|
5494
5859
|
const env = {};
|
|
5495
5860
|
const sitePackagesDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
5496
5861
|
for (const sitePackages of sitePackagesDirs) {
|
|
5497
|
-
const schemaPath = (0,
|
|
5862
|
+
const schemaPath = (0, import_path10.join)(
|
|
5498
5863
|
sitePackages,
|
|
5499
5864
|
"litellm",
|
|
5500
5865
|
"proxy",
|
|
5501
5866
|
"schema.prisma"
|
|
5502
5867
|
);
|
|
5503
5868
|
try {
|
|
5504
|
-
await
|
|
5505
|
-
(0,
|
|
5869
|
+
await import_fs8.default.promises.access(schemaPath);
|
|
5870
|
+
(0, import_build_utils10.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
|
|
5506
5871
|
buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
|
|
5507
5872
|
break;
|
|
5508
5873
|
} catch {
|
|
5509
5874
|
}
|
|
5510
5875
|
}
|
|
5511
5876
|
if (!buildEnv.PRISMA_SCHEMA_PATH) {
|
|
5512
|
-
(0,
|
|
5877
|
+
(0, import_build_utils10.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
|
|
5513
5878
|
}
|
|
5514
5879
|
if (!process.env.CONFIG_FILE_PATH) {
|
|
5515
5880
|
const configName = await findConfigFile(ctx.workPath);
|
|
5516
5881
|
if (configName) {
|
|
5517
|
-
(0,
|
|
5518
|
-
buildEnv.CONFIG_FILE_PATH = (0,
|
|
5519
|
-
env.CONFIG_FILE_PATH = (0,
|
|
5882
|
+
(0, import_build_utils10.debug)(`LiteLLM quirk: found config at ${configName}`);
|
|
5883
|
+
buildEnv.CONFIG_FILE_PATH = (0, import_path10.join)(ctx.workPath, configName);
|
|
5884
|
+
env.CONFIG_FILE_PATH = (0, import_path10.join)(LAMBDA_ROOT, configName);
|
|
5520
5885
|
}
|
|
5521
5886
|
} else {
|
|
5522
|
-
(0,
|
|
5887
|
+
(0, import_build_utils10.debug)(
|
|
5523
5888
|
`LiteLLM quirk: CONFIG_FILE_PATH already set to ${process.env.CONFIG_FILE_PATH}`
|
|
5524
5889
|
);
|
|
5525
5890
|
}
|
|
@@ -5528,11 +5893,11 @@ var litellmQuirk = {
|
|
|
5528
5893
|
};
|
|
5529
5894
|
|
|
5530
5895
|
// src/quirks/prisma.ts
|
|
5531
|
-
var
|
|
5532
|
-
var
|
|
5896
|
+
var import_fs9 = __toESM(require("fs"));
|
|
5897
|
+
var import_path11 = require("path");
|
|
5533
5898
|
var import_execa4 = __toESM(require_execa());
|
|
5534
|
-
var
|
|
5535
|
-
var
|
|
5899
|
+
var import_build_utils11 = require("@vercel/build-utils");
|
|
5900
|
+
var import_python_analysis6 = require("@vercel/python-analysis");
|
|
5536
5901
|
function execErrorMessage(err) {
|
|
5537
5902
|
if (err != null && typeof err === "object" && "stderr" in err) {
|
|
5538
5903
|
const stderr = String(err.stderr);
|
|
@@ -5569,22 +5934,22 @@ model DummyModel {
|
|
|
5569
5934
|
async function findUserSchema(workPath) {
|
|
5570
5935
|
const envPath = process.env.PRISMA_SCHEMA_PATH;
|
|
5571
5936
|
if (envPath) {
|
|
5572
|
-
const resolved = (0,
|
|
5937
|
+
const resolved = (0, import_path11.isAbsolute)(envPath) ? envPath : (0, import_path11.join)(workPath, envPath);
|
|
5573
5938
|
try {
|
|
5574
|
-
await
|
|
5939
|
+
await import_fs9.default.promises.access(resolved);
|
|
5575
5940
|
return resolved;
|
|
5576
5941
|
} catch {
|
|
5577
|
-
(0,
|
|
5942
|
+
(0, import_build_utils11.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
|
|
5578
5943
|
return null;
|
|
5579
5944
|
}
|
|
5580
5945
|
}
|
|
5581
5946
|
const candidates = [
|
|
5582
|
-
(0,
|
|
5583
|
-
(0,
|
|
5947
|
+
(0, import_path11.join)(workPath, "schema.prisma"),
|
|
5948
|
+
(0, import_path11.join)(workPath, "prisma", "schema.prisma")
|
|
5584
5949
|
];
|
|
5585
5950
|
for (const candidate of candidates) {
|
|
5586
5951
|
try {
|
|
5587
|
-
await
|
|
5952
|
+
await import_fs9.default.promises.access(candidate);
|
|
5588
5953
|
return candidate;
|
|
5589
5954
|
} catch {
|
|
5590
5955
|
}
|
|
@@ -5595,32 +5960,32 @@ async function collectFiles(dir, base) {
|
|
|
5595
5960
|
const result = [];
|
|
5596
5961
|
let entries;
|
|
5597
5962
|
try {
|
|
5598
|
-
entries = await
|
|
5963
|
+
entries = await import_fs9.default.promises.readdir(dir, { withFileTypes: true });
|
|
5599
5964
|
} catch {
|
|
5600
5965
|
return result;
|
|
5601
5966
|
}
|
|
5602
5967
|
for (const entry of entries) {
|
|
5603
5968
|
if (entry.name === "__pycache__")
|
|
5604
5969
|
continue;
|
|
5605
|
-
const full = (0,
|
|
5970
|
+
const full = (0, import_path11.join)(dir, entry.name);
|
|
5606
5971
|
if (entry.isDirectory()) {
|
|
5607
5972
|
result.push(...await collectFiles(full, base));
|
|
5608
5973
|
} else {
|
|
5609
|
-
result.push((0,
|
|
5974
|
+
result.push((0, import_path11.relative)(base, full));
|
|
5610
5975
|
}
|
|
5611
5976
|
}
|
|
5612
5977
|
return result;
|
|
5613
5978
|
}
|
|
5614
5979
|
async function cleanCacheArtifacts(cacheDir, extras = []) {
|
|
5615
5980
|
const paths = [
|
|
5616
|
-
(0,
|
|
5617
|
-
(0,
|
|
5618
|
-
(0,
|
|
5981
|
+
(0, import_path11.join)(cacheDir, "node_modules"),
|
|
5982
|
+
(0, import_path11.join)(cacheDir, "package.json"),
|
|
5983
|
+
(0, import_path11.join)(cacheDir, "package-lock.json"),
|
|
5619
5984
|
...extras
|
|
5620
5985
|
];
|
|
5621
5986
|
for (const p of paths) {
|
|
5622
5987
|
try {
|
|
5623
|
-
await
|
|
5988
|
+
await import_fs9.default.promises.rm(p, { recursive: true, force: true });
|
|
5624
5989
|
} catch (err) {
|
|
5625
5990
|
console.warn(
|
|
5626
5991
|
`could not clean up ${p}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -5644,7 +6009,7 @@ var prismaQuirk = {
|
|
|
5644
6009
|
async run(ctx) {
|
|
5645
6010
|
const { venvPath, pythonEnv, workPath } = ctx;
|
|
5646
6011
|
const pythonPath = getVenvPythonBin(venvPath);
|
|
5647
|
-
const runtimeCacheDir = (0,
|
|
6012
|
+
const runtimeCacheDir = (0, import_path11.join)(
|
|
5648
6013
|
LAMBDA_ROOT2,
|
|
5649
6014
|
resolveVendorDir(),
|
|
5650
6015
|
"prisma",
|
|
@@ -5654,7 +6019,7 @@ var prismaQuirk = {
|
|
|
5654
6019
|
let sitePackages;
|
|
5655
6020
|
for (const dir of sitePackagesDirs) {
|
|
5656
6021
|
try {
|
|
5657
|
-
await
|
|
6022
|
+
await import_fs9.default.promises.access((0, import_path11.join)(dir, "prisma"));
|
|
5658
6023
|
sitePackages = dir;
|
|
5659
6024
|
break;
|
|
5660
6025
|
} catch {
|
|
@@ -5666,19 +6031,19 @@ var prismaQuirk = {
|
|
|
5666
6031
|
);
|
|
5667
6032
|
return {};
|
|
5668
6033
|
}
|
|
5669
|
-
const cacheDir = (0,
|
|
5670
|
-
await
|
|
6034
|
+
const cacheDir = (0, import_path11.join)(sitePackages, "prisma", "__bincache__");
|
|
6035
|
+
await import_fs9.default.promises.mkdir(cacheDir, { recursive: true });
|
|
5671
6036
|
const generateEnv = {
|
|
5672
6037
|
...pythonEnv,
|
|
5673
6038
|
PRISMA_BINARY_CACHE_DIR: cacheDir
|
|
5674
6039
|
};
|
|
5675
|
-
const generatedDir = (0,
|
|
5676
|
-
const dummySchemaPath = (0,
|
|
5677
|
-
await
|
|
6040
|
+
const generatedDir = (0, import_path11.join)(workPath, "_prisma_generated");
|
|
6041
|
+
const dummySchemaPath = (0, import_path11.join)(workPath, DUMMY_SCHEMA_NAME);
|
|
6042
|
+
await import_fs9.default.promises.writeFile(
|
|
5678
6043
|
dummySchemaPath,
|
|
5679
6044
|
buildDummySchema(generatedDir)
|
|
5680
6045
|
);
|
|
5681
|
-
(0,
|
|
6046
|
+
(0, import_build_utils11.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
|
|
5682
6047
|
try {
|
|
5683
6048
|
const dummyResult = await (0, import_execa4.default)(
|
|
5684
6049
|
pythonPath,
|
|
@@ -5690,11 +6055,11 @@ var prismaQuirk = {
|
|
|
5690
6055
|
}
|
|
5691
6056
|
);
|
|
5692
6057
|
if (dummyResult.stdout)
|
|
5693
|
-
(0,
|
|
6058
|
+
(0, import_build_utils11.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
|
|
5694
6059
|
if (dummyResult.stderr)
|
|
5695
|
-
(0,
|
|
6060
|
+
(0, import_build_utils11.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
|
|
5696
6061
|
} catch (err) {
|
|
5697
|
-
throw new
|
|
6062
|
+
throw new import_build_utils11.NowBuildError({
|
|
5698
6063
|
code: "PRISMA_GENERATE_FAILED",
|
|
5699
6064
|
message: `Prisma engine download failed during \`prisma generate\`. Check that your prisma version is compatible with this Python version.
|
|
5700
6065
|
` + execErrorMessage(err)
|
|
@@ -5702,47 +6067,47 @@ var prismaQuirk = {
|
|
|
5702
6067
|
}
|
|
5703
6068
|
const srcBinaryPrefix = `query-engine-${getLambdaBinaryTarget()}`;
|
|
5704
6069
|
const runtimeName = `prisma-query-engine-rhel-openssl-${RUNTIME_OPENSSL_VERSION}.x`;
|
|
5705
|
-
const nodeModulesDir = (0,
|
|
6070
|
+
const nodeModulesDir = (0, import_path11.join)(cacheDir, "node_modules", "prisma");
|
|
5706
6071
|
let engineCopied = false;
|
|
5707
6072
|
try {
|
|
5708
|
-
const entries = await
|
|
6073
|
+
const entries = await import_fs9.default.promises.readdir(nodeModulesDir);
|
|
5709
6074
|
for (const entry of entries) {
|
|
5710
6075
|
if (!entry.startsWith(srcBinaryPrefix))
|
|
5711
6076
|
continue;
|
|
5712
|
-
const srcPath = (0,
|
|
5713
|
-
const destPath = (0,
|
|
6077
|
+
const srcPath = (0, import_path11.join)(nodeModulesDir, entry);
|
|
6078
|
+
const destPath = (0, import_path11.join)(cacheDir, runtimeName);
|
|
5714
6079
|
try {
|
|
5715
|
-
await
|
|
5716
|
-
(0,
|
|
6080
|
+
await import_fs9.default.promises.access(destPath);
|
|
6081
|
+
(0, import_build_utils11.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
|
|
5717
6082
|
} catch {
|
|
5718
|
-
(0,
|
|
5719
|
-
await
|
|
6083
|
+
(0, import_build_utils11.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
|
|
6084
|
+
await import_fs9.default.promises.copyFile(srcPath, destPath);
|
|
5720
6085
|
}
|
|
5721
6086
|
engineCopied = true;
|
|
5722
6087
|
}
|
|
5723
6088
|
} catch (err) {
|
|
5724
|
-
throw new
|
|
6089
|
+
throw new import_build_utils11.NowBuildError({
|
|
5725
6090
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
5726
6091
|
message: `could not read Prisma engine directory "${nodeModulesDir}". This may indicate an incompatible prisma version.
|
|
5727
6092
|
` + (err instanceof Error ? err.message : String(err))
|
|
5728
6093
|
});
|
|
5729
6094
|
}
|
|
5730
6095
|
if (!engineCopied) {
|
|
5731
|
-
throw new
|
|
6096
|
+
throw new import_build_utils11.NowBuildError({
|
|
5732
6097
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
5733
6098
|
message: `could not find engine binary matching "${srcBinaryPrefix}*" in "${nodeModulesDir}". This may indicate an incompatible prisma version or an unsupported platform (${process.arch}).`
|
|
5734
6099
|
});
|
|
5735
6100
|
}
|
|
5736
|
-
const shimPath = (0,
|
|
5737
|
-
await
|
|
6101
|
+
const shimPath = (0, import_path11.join)(cacheDir, "openssl");
|
|
6102
|
+
await import_fs9.default.promises.writeFile(
|
|
5738
6103
|
shimPath,
|
|
5739
6104
|
`#!/bin/sh
|
|
5740
6105
|
echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIME_OPENSSL_VERSION}.0)"
|
|
5741
6106
|
`
|
|
5742
6107
|
);
|
|
5743
|
-
await
|
|
6108
|
+
await import_fs9.default.promises.chmod(shimPath, 493);
|
|
5744
6109
|
for (const p of [generatedDir, dummySchemaPath]) {
|
|
5745
|
-
await
|
|
6110
|
+
await import_fs9.default.promises.rm(p, { recursive: true, force: true });
|
|
5746
6111
|
}
|
|
5747
6112
|
await cleanCacheArtifacts(cacheDir);
|
|
5748
6113
|
const generateMode = (process.env.VERCEL_PRISMA_GENERATE_CLIENT ?? "auto").toLowerCase();
|
|
@@ -5755,14 +6120,14 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5755
6120
|
pythonEnv
|
|
5756
6121
|
);
|
|
5757
6122
|
if (clientAlreadyGenerated) {
|
|
5758
|
-
(0,
|
|
6123
|
+
(0, import_build_utils11.debug)(
|
|
5759
6124
|
"Prisma quirk: client already generated, skipping user schema generate"
|
|
5760
6125
|
);
|
|
5761
6126
|
shouldGenerate = false;
|
|
5762
6127
|
}
|
|
5763
6128
|
}
|
|
5764
6129
|
if (shouldGenerate) {
|
|
5765
|
-
(0,
|
|
6130
|
+
(0, import_build_utils11.debug)(`Running prisma generate with user schema: ${userSchema}`);
|
|
5766
6131
|
try {
|
|
5767
6132
|
const userResult = await (0, import_execa4.default)(
|
|
5768
6133
|
pythonPath,
|
|
@@ -5774,11 +6139,11 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5774
6139
|
}
|
|
5775
6140
|
);
|
|
5776
6141
|
if (userResult.stdout)
|
|
5777
|
-
(0,
|
|
6142
|
+
(0, import_build_utils11.debug)(`prisma generate stdout: ${userResult.stdout}`);
|
|
5778
6143
|
if (userResult.stderr)
|
|
5779
|
-
(0,
|
|
6144
|
+
(0, import_build_utils11.debug)(`prisma generate stderr: ${userResult.stderr}`);
|
|
5780
6145
|
} catch (err) {
|
|
5781
|
-
throw new
|
|
6146
|
+
throw new import_build_utils11.NowBuildError({
|
|
5782
6147
|
code: "PRISMA_GENERATE_FAILED",
|
|
5783
6148
|
message: `\`prisma generate\` failed for schema "${userSchema}".
|
|
5784
6149
|
` + execErrorMessage(err)
|
|
@@ -5789,12 +6154,12 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5789
6154
|
}
|
|
5790
6155
|
try {
|
|
5791
6156
|
const allFiles = await collectFiles(
|
|
5792
|
-
(0,
|
|
6157
|
+
(0, import_path11.join)(sitePackages, "prisma"),
|
|
5793
6158
|
sitePackages
|
|
5794
6159
|
);
|
|
5795
|
-
const count = await (0,
|
|
6160
|
+
const count = await (0, import_python_analysis6.extendDistRecord)(sitePackages, "prisma", allFiles);
|
|
5796
6161
|
if (count > 0) {
|
|
5797
|
-
(0,
|
|
6162
|
+
(0, import_build_utils11.debug)(`Appended ${count} entries to prisma RECORD`);
|
|
5798
6163
|
}
|
|
5799
6164
|
} catch (err) {
|
|
5800
6165
|
console.warn(
|
|
@@ -5817,7 +6182,7 @@ var quirks = [litellmQuirk, prismaQuirk, matplotlibQuirk];
|
|
|
5817
6182
|
function toposortQuirks(activated) {
|
|
5818
6183
|
const nameToQuirk = /* @__PURE__ */ new Map();
|
|
5819
6184
|
for (const q of activated) {
|
|
5820
|
-
nameToQuirk.set((0,
|
|
6185
|
+
nameToQuirk.set((0, import_python_analysis7.normalizePackageName)(q.dependency), q);
|
|
5821
6186
|
}
|
|
5822
6187
|
const adj = /* @__PURE__ */ new Map();
|
|
5823
6188
|
const inDegree = /* @__PURE__ */ new Map();
|
|
@@ -5828,7 +6193,7 @@ function toposortQuirks(activated) {
|
|
|
5828
6193
|
for (const q of activated) {
|
|
5829
6194
|
if (q.runsBefore) {
|
|
5830
6195
|
for (const dep of q.runsBefore) {
|
|
5831
|
-
const target = nameToQuirk.get((0,
|
|
6196
|
+
const target = nameToQuirk.get((0, import_python_analysis7.normalizePackageName)(dep));
|
|
5832
6197
|
if (target) {
|
|
5833
6198
|
adj.get(q).add(target);
|
|
5834
6199
|
inDegree.set(target, inDegree.get(target) + 1);
|
|
@@ -5837,7 +6202,7 @@ function toposortQuirks(activated) {
|
|
|
5837
6202
|
}
|
|
5838
6203
|
if (q.runsAfter) {
|
|
5839
6204
|
for (const dep of q.runsAfter) {
|
|
5840
|
-
const source = nameToQuirk.get((0,
|
|
6205
|
+
const source = nameToQuirk.get((0, import_python_analysis7.normalizePackageName)(dep));
|
|
5841
6206
|
if (source) {
|
|
5842
6207
|
adj.get(source).add(q);
|
|
5843
6208
|
inDegree.set(q, inDegree.get(q) + 1);
|
|
@@ -5878,23 +6243,23 @@ async function runQuirks(ctx) {
|
|
|
5878
6243
|
const installedNames = /* @__PURE__ */ new Set();
|
|
5879
6244
|
const sitePackageDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
5880
6245
|
for (const dir of sitePackageDirs) {
|
|
5881
|
-
const distributions = await (0,
|
|
6246
|
+
const distributions = await (0, import_python_analysis7.scanDistributions)(dir);
|
|
5882
6247
|
for (const name of distributions.keys()) {
|
|
5883
|
-
installedNames.add((0,
|
|
6248
|
+
installedNames.add((0, import_python_analysis7.normalizePackageName)(name));
|
|
5884
6249
|
}
|
|
5885
6250
|
}
|
|
5886
6251
|
const activated = quirks.filter((quirk) => {
|
|
5887
6252
|
const installed = installedNames.has(
|
|
5888
|
-
(0,
|
|
6253
|
+
(0, import_python_analysis7.normalizePackageName)(quirk.dependency)
|
|
5889
6254
|
);
|
|
5890
6255
|
if (!installed) {
|
|
5891
|
-
(0,
|
|
6256
|
+
(0, import_build_utils12.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
|
|
5892
6257
|
}
|
|
5893
6258
|
return installed;
|
|
5894
6259
|
});
|
|
5895
6260
|
const sorted = toposortQuirks(activated);
|
|
5896
6261
|
for (const quirk of sorted) {
|
|
5897
|
-
(0,
|
|
6262
|
+
(0, import_build_utils12.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
|
|
5898
6263
|
const result = await quirk.run(ctx);
|
|
5899
6264
|
if (result.env) {
|
|
5900
6265
|
Object.assign(mergedEnv, result.env);
|
|
@@ -5915,12 +6280,12 @@ async function runQuirks(ctx) {
|
|
|
5915
6280
|
}
|
|
5916
6281
|
|
|
5917
6282
|
// src/django.ts
|
|
5918
|
-
var
|
|
5919
|
-
var
|
|
6283
|
+
var import_fs10 = __toESM(require("fs"));
|
|
6284
|
+
var import_path12 = require("path");
|
|
5920
6285
|
var import_execa5 = __toESM(require_execa());
|
|
5921
|
-
var
|
|
5922
|
-
var scriptPath = (0,
|
|
5923
|
-
var script =
|
|
6286
|
+
var import_build_utils13 = require("@vercel/build-utils");
|
|
6287
|
+
var scriptPath = (0, import_path12.join)(__dirname, "..", "templates", "vc_django_settings.py");
|
|
6288
|
+
var script = import_fs10.default.readFileSync(scriptPath, "utf-8");
|
|
5924
6289
|
async function getDjangoSettings(projectDir, env) {
|
|
5925
6290
|
try {
|
|
5926
6291
|
const { stdout } = await (0, import_execa5.default)("python", ["-c", script], {
|
|
@@ -5935,7 +6300,7 @@ async function getDjangoSettings(projectDir, env) {
|
|
|
5935
6300
|
djangoSettings: parsed.django_settings
|
|
5936
6301
|
};
|
|
5937
6302
|
} catch (err) {
|
|
5938
|
-
(0,
|
|
6303
|
+
(0, import_build_utils13.debug)(`Django hook: failed to discover settings from manage.py: ${err}`);
|
|
5939
6304
|
return null;
|
|
5940
6305
|
}
|
|
5941
6306
|
}
|
|
@@ -5949,10 +6314,10 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5949
6314
|
const installedApps = djangoSettings["INSTALLED_APPS"] ?? [];
|
|
5950
6315
|
const staticfilesDirs = djangoSettings["STATICFILES_DIRS"] ?? [];
|
|
5951
6316
|
const staticSourceDirs = [
|
|
5952
|
-
...installedApps.map((app) => (0,
|
|
6317
|
+
...installedApps.map((app) => (0, import_path12.join)(workPath, ...app.split("."), "static")),
|
|
5953
6318
|
// TODO: Deal with optional prefixes in STATICFILES_DIRS.
|
|
5954
6319
|
...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
|
|
5955
|
-
].filter((d) =>
|
|
6320
|
+
].filter((d) => import_fs10.default.existsSync(d));
|
|
5956
6321
|
if (storageBackend.startsWith("storages.backends.")) {
|
|
5957
6322
|
console.log(
|
|
5958
6323
|
"django-storages detected \u2014 running collectstatic with original settings"
|
|
@@ -5963,7 +6328,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5963
6328
|
});
|
|
5964
6329
|
return {
|
|
5965
6330
|
staticSourceDirs,
|
|
5966
|
-
staticRoot: staticRoot ? (0,
|
|
6331
|
+
staticRoot: staticRoot ? (0, import_path12.resolve)(workPath, staticRoot) : null,
|
|
5967
6332
|
manifestRelPath: null
|
|
5968
6333
|
};
|
|
5969
6334
|
}
|
|
@@ -5974,9 +6339,9 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5974
6339
|
return null;
|
|
5975
6340
|
}
|
|
5976
6341
|
const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
|
|
5977
|
-
const staticOutputDir = (0,
|
|
5978
|
-
await
|
|
5979
|
-
const shimPath = (0,
|
|
6342
|
+
const staticOutputDir = (0, import_path12.join)(outputStaticDir, staticUrlPath);
|
|
6343
|
+
await import_fs10.default.promises.mkdir(staticOutputDir, { recursive: true });
|
|
6344
|
+
const shimPath = (0, import_path12.join)(workPath, "_vercel_collectstatic_settings.py");
|
|
5980
6345
|
const shimLines = [
|
|
5981
6346
|
`from ${settingsModule} import *`,
|
|
5982
6347
|
`STATIC_ROOT = ${JSON.stringify(staticOutputDir)}`
|
|
@@ -5984,7 +6349,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5984
6349
|
if (whitenoiseUseFinders) {
|
|
5985
6350
|
shimLines.push(`WHITENOISE_USE_FINDERS = False`);
|
|
5986
6351
|
}
|
|
5987
|
-
await
|
|
6352
|
+
await import_fs10.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
|
|
5988
6353
|
try {
|
|
5989
6354
|
console.log("Running collectstatic...");
|
|
5990
6355
|
await (0, import_execa5.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
|
|
@@ -5995,7 +6360,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5995
6360
|
cwd: workPath
|
|
5996
6361
|
});
|
|
5997
6362
|
} finally {
|
|
5998
|
-
await
|
|
6363
|
+
await import_fs10.default.promises.unlink(shimPath).catch(() => {
|
|
5999
6364
|
});
|
|
6000
6365
|
}
|
|
6001
6366
|
const MANIFEST_STORAGE_BACKENDS = [
|
|
@@ -6004,24 +6369,24 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
6004
6369
|
];
|
|
6005
6370
|
let manifestRelPath = null;
|
|
6006
6371
|
if (MANIFEST_STORAGE_BACKENDS.includes(storageBackend) && staticRoot) {
|
|
6007
|
-
const manifestSrc = (0,
|
|
6008
|
-
const resolvedStaticRoot = (0,
|
|
6009
|
-
const manifestDest = (0,
|
|
6010
|
-
await
|
|
6011
|
-
await
|
|
6012
|
-
manifestRelPath = (0,
|
|
6013
|
-
(0,
|
|
6372
|
+
const manifestSrc = (0, import_path12.join)(staticOutputDir, "staticfiles.json");
|
|
6373
|
+
const resolvedStaticRoot = (0, import_path12.resolve)(workPath, staticRoot);
|
|
6374
|
+
const manifestDest = (0, import_path12.join)(resolvedStaticRoot, "staticfiles.json");
|
|
6375
|
+
await import_fs10.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
|
|
6376
|
+
await import_fs10.default.promises.copyFile(manifestSrc, manifestDest);
|
|
6377
|
+
manifestRelPath = (0, import_path12.relative)(workPath, manifestDest);
|
|
6378
|
+
(0, import_build_utils13.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
|
|
6014
6379
|
}
|
|
6015
6380
|
return {
|
|
6016
6381
|
staticSourceDirs,
|
|
6017
|
-
staticRoot: staticRoot ? (0,
|
|
6382
|
+
staticRoot: staticRoot ? (0, import_path12.resolve)(workPath, staticRoot) : null,
|
|
6018
6383
|
manifestRelPath
|
|
6019
6384
|
};
|
|
6020
6385
|
}
|
|
6021
6386
|
|
|
6022
6387
|
// src/index.ts
|
|
6023
|
-
var
|
|
6024
|
-
var writeFile =
|
|
6388
|
+
var import_python_analysis8 = require("@vercel/python-analysis");
|
|
6389
|
+
var writeFile = import_fs11.default.promises.writeFile;
|
|
6025
6390
|
var version = 3;
|
|
6026
6391
|
async function runFrameworkHook(framework, ctx) {
|
|
6027
6392
|
const hook = framework ? frameworkHooks[framework] : void 0;
|
|
@@ -6036,32 +6401,41 @@ var frameworkHooks = {
|
|
|
6036
6401
|
detected
|
|
6037
6402
|
}) => {
|
|
6038
6403
|
if (detected?.baseDir === void 0) {
|
|
6039
|
-
(0,
|
|
6404
|
+
(0, import_build_utils14.debug)("Django hook: no manage.py detected, skipping");
|
|
6040
6405
|
return;
|
|
6041
6406
|
}
|
|
6042
6407
|
const settingsResult = await getDjangoSettings(projectDir, pythonEnv);
|
|
6043
|
-
(0,
|
|
6408
|
+
(0, import_build_utils14.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
6044
6409
|
if (!settingsResult)
|
|
6045
6410
|
return;
|
|
6046
6411
|
const { djangoSettings, settingsModule } = settingsResult;
|
|
6047
6412
|
let entrypoint;
|
|
6413
|
+
let variableName;
|
|
6048
6414
|
const baseDir = detected?.baseDir ?? "";
|
|
6049
6415
|
const asgiApp = djangoSettings["ASGI_APPLICATION"];
|
|
6050
6416
|
if (typeof asgiApp === "string") {
|
|
6051
|
-
const
|
|
6417
|
+
const parts = asgiApp.split(".");
|
|
6418
|
+
variableName = parts.at(-1);
|
|
6419
|
+
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
6052
6420
|
entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
|
|
6053
|
-
(0,
|
|
6421
|
+
(0, import_build_utils14.debug)(
|
|
6422
|
+
`Django hook: ASGI entrypoint: ${entrypoint} (variable: ${variableName})`
|
|
6423
|
+
);
|
|
6054
6424
|
} else {
|
|
6055
6425
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
6056
6426
|
if (typeof wsgiApp === "string") {
|
|
6057
|
-
const
|
|
6427
|
+
const parts = wsgiApp.split(".");
|
|
6428
|
+
variableName = parts.at(-1);
|
|
6429
|
+
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
6058
6430
|
entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
|
|
6059
|
-
(0,
|
|
6431
|
+
(0, import_build_utils14.debug)(
|
|
6432
|
+
`Django hook: WSGI entrypoint: ${entrypoint} (variable: ${variableName})`
|
|
6433
|
+
);
|
|
6060
6434
|
}
|
|
6061
6435
|
}
|
|
6062
6436
|
let djangoStatic = null;
|
|
6063
|
-
if (venvPath) {
|
|
6064
|
-
const outputStaticDir = (0,
|
|
6437
|
+
if (workPath && venvPath) {
|
|
6438
|
+
const outputStaticDir = (0, import_path13.join)(workPath, ".vercel", "output", "static");
|
|
6065
6439
|
djangoStatic = await runDjangoCollectStatic(
|
|
6066
6440
|
venvPath,
|
|
6067
6441
|
workPath,
|
|
@@ -6071,7 +6445,7 @@ var frameworkHooks = {
|
|
|
6071
6445
|
djangoSettings
|
|
6072
6446
|
);
|
|
6073
6447
|
}
|
|
6074
|
-
return { entrypoint, djangoStatic };
|
|
6448
|
+
return { entrypoint, variableName, djangoStatic };
|
|
6075
6449
|
}
|
|
6076
6450
|
};
|
|
6077
6451
|
async function downloadFilesInWorkPath({
|
|
@@ -6080,13 +6454,13 @@ async function downloadFilesInWorkPath({
|
|
|
6080
6454
|
files,
|
|
6081
6455
|
meta = {}
|
|
6082
6456
|
}) {
|
|
6083
|
-
(0,
|
|
6084
|
-
let downloadedFiles = await (0,
|
|
6457
|
+
(0, import_build_utils14.debug)("Downloading user files...");
|
|
6458
|
+
let downloadedFiles = await (0, import_build_utils14.download)(files, workPath, meta);
|
|
6085
6459
|
if (meta.isDev) {
|
|
6086
|
-
const { devCacheDir = (0,
|
|
6087
|
-
const destCache = (0,
|
|
6088
|
-
await (0,
|
|
6089
|
-
downloadedFiles = await (0,
|
|
6460
|
+
const { devCacheDir = (0, import_path13.join)(workPath, ".now", "cache") } = meta;
|
|
6461
|
+
const destCache = (0, import_path13.join)(devCacheDir, (0, import_path13.basename)(entrypoint, ".py"));
|
|
6462
|
+
await (0, import_build_utils14.download)(downloadedFiles, destCache);
|
|
6463
|
+
downloadedFiles = await (0, import_build_utils14.glob)("**", destCache);
|
|
6090
6464
|
workPath = destCache;
|
|
6091
6465
|
}
|
|
6092
6466
|
return workPath;
|
|
@@ -6098,15 +6472,16 @@ var build = async ({
|
|
|
6098
6472
|
entrypoint,
|
|
6099
6473
|
meta = {},
|
|
6100
6474
|
config,
|
|
6101
|
-
span: parentSpan
|
|
6475
|
+
span: parentSpan,
|
|
6476
|
+
service
|
|
6102
6477
|
}) => {
|
|
6103
|
-
const builderSpan = parentSpan ?? new
|
|
6478
|
+
const builderSpan = parentSpan ?? new import_build_utils14.Span({ name: "vc.builder" });
|
|
6104
6479
|
const framework = config?.framework;
|
|
6105
6480
|
const shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
6106
6481
|
let spawnEnv;
|
|
6107
6482
|
let projectInstallCommand;
|
|
6108
6483
|
let hasCustomCommand = false;
|
|
6109
|
-
(0,
|
|
6484
|
+
(0, import_build_utils14.debug)(`workPath: ${workPath}`);
|
|
6110
6485
|
workPath = await downloadFilesInWorkPath({
|
|
6111
6486
|
workPath,
|
|
6112
6487
|
files: originalFiles,
|
|
@@ -6115,17 +6490,17 @@ var build = async ({
|
|
|
6115
6490
|
});
|
|
6116
6491
|
try {
|
|
6117
6492
|
if (meta.isDev) {
|
|
6118
|
-
const setupCfg = (0,
|
|
6493
|
+
const setupCfg = (0, import_path13.join)(workPath, "setup.cfg");
|
|
6119
6494
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
6120
6495
|
}
|
|
6121
6496
|
} catch (err) {
|
|
6122
6497
|
console.log('Failed to create "setup.cfg" file');
|
|
6123
6498
|
throw err;
|
|
6124
6499
|
}
|
|
6125
|
-
let fsFiles = await (0,
|
|
6500
|
+
let fsFiles = await (0, import_build_utils14.glob)("**", workPath);
|
|
6126
6501
|
let detected;
|
|
6127
6502
|
let entrypointNotFound;
|
|
6128
|
-
if ((0,
|
|
6503
|
+
if ((0, import_build_utils14.isPythonFramework)(framework) && // XXX: we might want to detect anyway for django!
|
|
6129
6504
|
(!fsFiles[entrypoint] || !entrypoint.endsWith(".py"))) {
|
|
6130
6505
|
detected = await detectPythonEntrypoint(
|
|
6131
6506
|
config.framework,
|
|
@@ -6133,13 +6508,13 @@ var build = async ({
|
|
|
6133
6508
|
entrypoint
|
|
6134
6509
|
) ?? void 0;
|
|
6135
6510
|
if (detected?.entrypoint) {
|
|
6136
|
-
(0,
|
|
6511
|
+
(0, import_build_utils14.debug)(
|
|
6137
6512
|
`Resolved Python entrypoint to "${detected.entrypoint}" (configured "${entrypoint}" not found).`
|
|
6138
6513
|
);
|
|
6139
6514
|
entrypoint = detected.entrypoint;
|
|
6140
6515
|
} else {
|
|
6141
6516
|
const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
6142
|
-
entrypointNotFound = new
|
|
6517
|
+
entrypointNotFound = new import_build_utils14.NowBuildError({
|
|
6143
6518
|
code: `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`,
|
|
6144
6519
|
message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searchedList}.`,
|
|
6145
6520
|
link: `https://vercel.com/docs/frameworks/backend/${framework}#exporting-the-${framework}-application`,
|
|
@@ -6150,8 +6525,8 @@ var build = async ({
|
|
|
6150
6525
|
if (entrypointNotFound && detected?.baseDir === void 0) {
|
|
6151
6526
|
throw entrypointNotFound;
|
|
6152
6527
|
}
|
|
6153
|
-
const entryDirectory = detected?.baseDir ?? (0,
|
|
6154
|
-
const entrypointAbsDir = (0,
|
|
6528
|
+
const entryDirectory = detected?.baseDir ?? (0, import_path13.dirname)(entrypoint);
|
|
6529
|
+
const entrypointAbsDir = (0, import_path13.join)(workPath, entryDirectory);
|
|
6155
6530
|
const rootDir = repoRootPath ?? workPath;
|
|
6156
6531
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
6157
6532
|
() => discoverPackage({
|
|
@@ -6181,22 +6556,22 @@ var build = async ({
|
|
|
6181
6556
|
`
|
|
6182
6557
|
);
|
|
6183
6558
|
}
|
|
6184
|
-
fsFiles = await (0,
|
|
6185
|
-
const venvPath = (0,
|
|
6559
|
+
fsFiles = await (0, import_build_utils14.glob)("**", workPath);
|
|
6560
|
+
const venvPath = service?.name ? (0, import_path13.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path13.join)(workPath, ".vercel", "python", ".venv");
|
|
6186
6561
|
await builderSpan.child("vc.builder.python.venv").trace(async () => {
|
|
6187
6562
|
await ensureVenv({
|
|
6188
6563
|
pythonPath: pythonVersion.pythonPath,
|
|
6189
6564
|
venvPath
|
|
6190
6565
|
});
|
|
6191
6566
|
});
|
|
6192
|
-
if ((0,
|
|
6567
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6193
6568
|
const {
|
|
6194
6569
|
cliType,
|
|
6195
6570
|
lockfileVersion,
|
|
6196
6571
|
packageJsonPackageManager,
|
|
6197
6572
|
turboSupportsCorepackHome
|
|
6198
|
-
} = await (0,
|
|
6199
|
-
spawnEnv = (0,
|
|
6573
|
+
} = await (0, import_build_utils14.scanParentDirs)(workPath, true);
|
|
6574
|
+
spawnEnv = (0, import_build_utils14.getEnvForPackageManager)({
|
|
6200
6575
|
cliType,
|
|
6201
6576
|
lockfileVersion,
|
|
6202
6577
|
packageJsonPackageManager,
|
|
@@ -6232,14 +6607,14 @@ var build = async ({
|
|
|
6232
6607
|
let uvLockPath = null;
|
|
6233
6608
|
let uvProjectDir = null;
|
|
6234
6609
|
let projectName;
|
|
6235
|
-
await builderSpan.child(
|
|
6610
|
+
await builderSpan.child(import_build_utils14.BUILDER_INSTALLER_STEP, {
|
|
6236
6611
|
installCommand: projectInstallCommand || void 0
|
|
6237
6612
|
}).trace(async () => {
|
|
6238
6613
|
if (projectInstallCommand) {
|
|
6239
6614
|
console.log(
|
|
6240
6615
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
6241
6616
|
);
|
|
6242
|
-
await (0,
|
|
6617
|
+
await (0, import_build_utils14.execCommand)(projectInstallCommand, {
|
|
6243
6618
|
env: pythonEnv,
|
|
6244
6619
|
cwd: workPath
|
|
6245
6620
|
});
|
|
@@ -6278,15 +6653,15 @@ var build = async ({
|
|
|
6278
6653
|
});
|
|
6279
6654
|
}
|
|
6280
6655
|
});
|
|
6281
|
-
if ((0,
|
|
6656
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6282
6657
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
6283
6658
|
config?.buildCommand;
|
|
6284
|
-
await builderSpan.child(
|
|
6659
|
+
await builderSpan.child(import_build_utils14.BUILDER_COMPILE_STEP, {
|
|
6285
6660
|
buildCommand: projectBuildCommand || void 0
|
|
6286
6661
|
}).trace(async () => {
|
|
6287
6662
|
if (projectBuildCommand) {
|
|
6288
6663
|
console.log(`Running "${projectBuildCommand}"`);
|
|
6289
|
-
await (0,
|
|
6664
|
+
await (0, import_build_utils14.execCommand)(projectBuildCommand, {
|
|
6290
6665
|
env: pythonEnv,
|
|
6291
6666
|
cwd: workPath
|
|
6292
6667
|
});
|
|
@@ -6301,7 +6676,7 @@ var build = async ({
|
|
|
6301
6676
|
}
|
|
6302
6677
|
const hookResult = await runFrameworkHook(framework, {
|
|
6303
6678
|
pythonEnv,
|
|
6304
|
-
projectDir: (0,
|
|
6679
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6305
6680
|
workPath,
|
|
6306
6681
|
venvPath,
|
|
6307
6682
|
entrypoint,
|
|
@@ -6316,18 +6691,18 @@ var build = async ({
|
|
|
6316
6691
|
}
|
|
6317
6692
|
const djangoStatic = hookResult?.djangoStatic ?? null;
|
|
6318
6693
|
const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
|
|
6319
|
-
(0,
|
|
6694
|
+
(0, import_build_utils14.debug)(`Installing ${runtimeDep}`);
|
|
6320
6695
|
await uv.pip({
|
|
6321
6696
|
venvPath,
|
|
6322
|
-
projectDir: (0,
|
|
6697
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6323
6698
|
args: ["install", runtimeDep]
|
|
6324
6699
|
});
|
|
6325
6700
|
if (shouldInstallVercelWorkers) {
|
|
6326
6701
|
const workersDep = baseEnv.VERCEL_WORKERS_PYTHON || `vercel-workers==${VERCEL_WORKERS_VERSION}`;
|
|
6327
|
-
(0,
|
|
6702
|
+
(0, import_build_utils14.debug)(`Installing ${workersDep}`);
|
|
6328
6703
|
await uv.pip({
|
|
6329
6704
|
venvPath,
|
|
6330
|
-
projectDir: (0,
|
|
6705
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6331
6706
|
args: ["install", workersDep]
|
|
6332
6707
|
});
|
|
6333
6708
|
}
|
|
@@ -6335,15 +6710,15 @@ var build = async ({
|
|
|
6335
6710
|
if (quirksResult.buildEnv) {
|
|
6336
6711
|
Object.assign(pythonEnv, quirksResult.buildEnv);
|
|
6337
6712
|
}
|
|
6338
|
-
(0,
|
|
6713
|
+
(0, import_build_utils14.debug)("Entrypoint is", entrypoint);
|
|
6339
6714
|
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
|
|
6340
6715
|
const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
|
|
6341
6716
|
if (handlerFunction) {
|
|
6342
|
-
const entrypointPath = (0,
|
|
6343
|
-
const source = await
|
|
6344
|
-
const found = await (0,
|
|
6717
|
+
const entrypointPath = (0, import_path13.join)(workPath, entrypoint);
|
|
6718
|
+
const source = await import_fs11.default.promises.readFile(entrypointPath, "utf-8");
|
|
6719
|
+
const found = await (0, import_python_analysis8.containsTopLevelCallable)(source, handlerFunction);
|
|
6345
6720
|
if (!found) {
|
|
6346
|
-
throw new
|
|
6721
|
+
throw new import_build_utils14.NowBuildError({
|
|
6347
6722
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
6348
6723
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
6349
6724
|
});
|
|
@@ -6352,9 +6727,10 @@ var build = async ({
|
|
|
6352
6727
|
const vendorDir = resolveVendorDir();
|
|
6353
6728
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
6354
6729
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
6355
|
-
(0,
|
|
6730
|
+
(0, import_build_utils14.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
6356
6731
|
const handlerFuncEnvLine = handlerFunction ? `
|
|
6357
6732
|
"__VC_HANDLER_FUNC_NAME": "${handlerFunction}",` : "";
|
|
6733
|
+
const variableName = hookResult?.variableName ?? detected?.variableName ?? "";
|
|
6358
6734
|
const runtimeTrampoline = `
|
|
6359
6735
|
import importlib
|
|
6360
6736
|
import os
|
|
@@ -6368,7 +6744,8 @@ os.environ.update({
|
|
|
6368
6744
|
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
6369
6745
|
"__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
|
|
6370
6746
|
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
|
|
6371
|
-
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}"
|
|
6747
|
+
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
6748
|
+
"__VC_HANDLER_VARIABLE_NAME": "${variableName}",${handlerFuncEnvLine}
|
|
6372
6749
|
})
|
|
6373
6750
|
|
|
6374
6751
|
_vendor_rel = '${vendorDir}'
|
|
@@ -6417,7 +6794,7 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6417
6794
|
...djangoStatic.staticRoot ? [djangoStatic.staticRoot] : []
|
|
6418
6795
|
];
|
|
6419
6796
|
for (const absDir of dirsToExclude) {
|
|
6420
|
-
const rel = (0,
|
|
6797
|
+
const rel = (0, import_path13.relative)(workPath, absDir);
|
|
6421
6798
|
if (!rel.startsWith("..")) {
|
|
6422
6799
|
predefinedExcludes.push(`${rel}/**`);
|
|
6423
6800
|
}
|
|
@@ -6426,14 +6803,17 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6426
6803
|
const lambdaEnv = {};
|
|
6427
6804
|
lambdaEnv.PYTHONPATH = vendorDir;
|
|
6428
6805
|
Object.assign(lambdaEnv, quirksResult.env);
|
|
6806
|
+
if (shouldInstallVercelWorkers) {
|
|
6807
|
+
lambdaEnv.VERCEL_HAS_WORKER_SERVICES = "1";
|
|
6808
|
+
}
|
|
6429
6809
|
const globOptions = {
|
|
6430
6810
|
cwd: workPath,
|
|
6431
6811
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
6432
6812
|
};
|
|
6433
|
-
const files = await (0,
|
|
6813
|
+
const files = await (0, import_build_utils14.glob)("**", globOptions);
|
|
6434
6814
|
if (djangoStatic?.manifestRelPath) {
|
|
6435
|
-
files[djangoStatic.manifestRelPath] = new
|
|
6436
|
-
fsPath: (0,
|
|
6815
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils14.FileFsRef({
|
|
6816
|
+
fsPath: (0, import_path13.join)(workPath, djangoStatic.manifestRelPath)
|
|
6437
6817
|
});
|
|
6438
6818
|
}
|
|
6439
6819
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
@@ -6469,23 +6849,37 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6469
6849
|
}
|
|
6470
6850
|
});
|
|
6471
6851
|
const handlerPyFilename = "vc__handler__python";
|
|
6472
|
-
files[`${handlerPyFilename}.py`] = new
|
|
6852
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils14.FileBlob({ data: runtimeTrampoline });
|
|
6473
6853
|
if (config.framework === "fasthtml") {
|
|
6474
6854
|
const { SESSKEY = "" } = process.env;
|
|
6475
|
-
files[".sesskey"] = new
|
|
6855
|
+
files[".sesskey"] = new import_build_utils14.FileBlob({ data: `"${SESSKEY}"` });
|
|
6476
6856
|
}
|
|
6477
|
-
const output = new
|
|
6857
|
+
const output = new import_build_utils14.Lambda({
|
|
6478
6858
|
files,
|
|
6479
6859
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
6480
6860
|
runtime: pythonVersion.runtime,
|
|
6481
6861
|
environment: lambdaEnv,
|
|
6482
6862
|
supportsResponseStreaming: true
|
|
6483
6863
|
});
|
|
6864
|
+
if (uvLockPath) {
|
|
6865
|
+
try {
|
|
6866
|
+
await generateProjectManifest({
|
|
6867
|
+
workPath,
|
|
6868
|
+
pythonPackage,
|
|
6869
|
+
pythonVersion,
|
|
6870
|
+
uvLockPath
|
|
6871
|
+
});
|
|
6872
|
+
} catch (err) {
|
|
6873
|
+
(0, import_build_utils14.debug)(
|
|
6874
|
+
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
6875
|
+
);
|
|
6876
|
+
}
|
|
6877
|
+
}
|
|
6484
6878
|
return { output };
|
|
6485
6879
|
};
|
|
6486
6880
|
var shouldServe = (opts) => {
|
|
6487
6881
|
const framework = opts.config.framework;
|
|
6488
|
-
if ((0,
|
|
6882
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6489
6883
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
6490
6884
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
6491
6885
|
return false;
|
|
@@ -6504,7 +6898,7 @@ var defaultShouldServe = ({
|
|
|
6504
6898
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
6505
6899
|
return true;
|
|
6506
6900
|
}
|
|
6507
|
-
const { dir, name } = (0,
|
|
6901
|
+
const { dir, name } = (0, import_path13.parse)(entrypoint);
|
|
6508
6902
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
6509
6903
|
return true;
|
|
6510
6904
|
}
|
|
@@ -6517,6 +6911,7 @@ function hasProp(obj, key) {
|
|
|
6517
6911
|
0 && (module.exports = {
|
|
6518
6912
|
build,
|
|
6519
6913
|
defaultShouldServe,
|
|
6914
|
+
diagnostics,
|
|
6520
6915
|
downloadFilesInWorkPath,
|
|
6521
6916
|
installRequirement,
|
|
6522
6917
|
installRequirementsFile,
|