@vercel/python 6.24.0 → 6.26.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 +722 -330
- 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.1";
|
|
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());
|
|
@@ -3330,34 +3331,16 @@ var UvRunner = class {
|
|
|
3330
3331
|
args.push("--no-editable");
|
|
3331
3332
|
await this.runUvCmd(args, projectDir, venvPath);
|
|
3332
3333
|
}
|
|
3333
|
-
async lock(
|
|
3334
|
-
const
|
|
3335
|
-
|
|
3334
|
+
async lock(options) {
|
|
3335
|
+
const { projectDir, venvPath, noBuild, upgrade } = options;
|
|
3336
|
+
const args = ["lock", "--python", getVenvPythonBin(venvPath)];
|
|
3337
|
+
if (noBuild) {
|
|
3336
3338
|
args.push("--no-build");
|
|
3337
3339
|
}
|
|
3338
|
-
if (
|
|
3340
|
+
if (upgrade) {
|
|
3339
3341
|
args.push("--upgrade");
|
|
3340
3342
|
}
|
|
3341
|
-
|
|
3342
|
-
(0, import_build_utils.debug)(`Running "${pretty}" in ${projectDir}...`);
|
|
3343
|
-
try {
|
|
3344
|
-
await (0, import_execa.default)(this.uvPath, args, {
|
|
3345
|
-
cwd: projectDir,
|
|
3346
|
-
env: getProtectedUvEnv(process.env)
|
|
3347
|
-
});
|
|
3348
|
-
} catch (err) {
|
|
3349
|
-
const error = new Error(
|
|
3350
|
-
`Failed to run "${pretty}": ${err instanceof Error ? err.message : String(err)}`
|
|
3351
|
-
);
|
|
3352
|
-
if (err && typeof err === "object") {
|
|
3353
|
-
if ("code" in err) {
|
|
3354
|
-
error.code = err.code;
|
|
3355
|
-
} else if ("signal" in err) {
|
|
3356
|
-
error.code = err.signal;
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
throw error;
|
|
3360
|
-
}
|
|
3343
|
+
await this.runUvCmd(args, projectDir, venvPath);
|
|
3361
3344
|
}
|
|
3362
3345
|
async addDependencies(options) {
|
|
3363
3346
|
const { venvPath, projectDir, dependencies } = options;
|
|
@@ -4016,6 +3999,7 @@ function detectInstallSource(pythonPackage, rootDir) {
|
|
|
4016
3999
|
async function ensureUvProject({
|
|
4017
4000
|
workPath,
|
|
4018
4001
|
rootDir,
|
|
4002
|
+
venvPath,
|
|
4019
4003
|
pythonPackage,
|
|
4020
4004
|
pythonVersion,
|
|
4021
4005
|
uv,
|
|
@@ -4072,16 +4056,18 @@ async function ensureUvProject({
|
|
|
4072
4056
|
if (workspaceLockFile) {
|
|
4073
4057
|
lockPath = (0, import_path5.join)(rootDir, workspaceLockFile.path);
|
|
4074
4058
|
} else {
|
|
4075
|
-
await uv.lock(
|
|
4059
|
+
await uv.lock({
|
|
4076
4060
|
projectDir,
|
|
4077
|
-
|
|
4078
|
-
|
|
4061
|
+
venvPath,
|
|
4062
|
+
...requireBinaryWheels ? { noBuild: true, upgrade: true } : {}
|
|
4063
|
+
});
|
|
4079
4064
|
}
|
|
4080
4065
|
if (generateLockFile && !lockPath) {
|
|
4081
|
-
await uv.lock(
|
|
4066
|
+
await uv.lock({
|
|
4082
4067
|
projectDir,
|
|
4083
|
-
|
|
4084
|
-
|
|
4068
|
+
venvPath,
|
|
4069
|
+
...requireBinaryWheels ? { noBuild: true, upgrade: true } : {}
|
|
4070
|
+
});
|
|
4085
4071
|
}
|
|
4086
4072
|
} else {
|
|
4087
4073
|
projectDir = workPath;
|
|
@@ -4097,10 +4083,11 @@ async function ensureUvProject({
|
|
|
4097
4083
|
});
|
|
4098
4084
|
const content = (0, import_python_analysis2.stringifyManifest)(minimalManifest);
|
|
4099
4085
|
await import_fs3.default.promises.writeFile(pyprojectPath, content);
|
|
4100
|
-
await uv.lock(
|
|
4086
|
+
await uv.lock({
|
|
4101
4087
|
projectDir,
|
|
4102
|
-
|
|
4103
|
-
|
|
4088
|
+
venvPath,
|
|
4089
|
+
...requireBinaryWheels ? { noBuild: true, upgrade: true } : {}
|
|
4090
|
+
});
|
|
4104
4091
|
}
|
|
4105
4092
|
const resolvedLockPath = lockPath && import_fs3.default.existsSync(lockPath) ? lockPath : (0, import_path5.join)(projectDir, "uv.lock");
|
|
4106
4093
|
return {
|
|
@@ -4417,6 +4404,19 @@ To fix this, either:
|
|
|
4417
4404
|
runtimeToolingOverhead = 50 * 1024 * 1024;
|
|
4418
4405
|
}
|
|
4419
4406
|
}
|
|
4407
|
+
runtimeToolingOverhead += 4 * 1024;
|
|
4408
|
+
const projectDirRel = (0, import_path6.relative)(this.workPath, this.uvProjectDir);
|
|
4409
|
+
const uvLockRel = (0, import_path6.relative)(this.workPath, this.uvLockPath);
|
|
4410
|
+
const isOutsideWorkPath = projectDirRel.startsWith("..") || uvLockRel.startsWith("..");
|
|
4411
|
+
if (isOutsideWorkPath) {
|
|
4412
|
+
const pyprojectPath = (0, import_path6.join)(this.uvProjectDir, "pyproject.toml");
|
|
4413
|
+
const pyprojectStats = await import_fs4.default.promises.stat(pyprojectPath).catch(() => null);
|
|
4414
|
+
const uvLockStats = await import_fs4.default.promises.stat(this.uvLockPath).catch(() => null);
|
|
4415
|
+
if (pyprojectStats)
|
|
4416
|
+
runtimeToolingOverhead += pyprojectStats.size;
|
|
4417
|
+
if (uvLockStats)
|
|
4418
|
+
runtimeToolingOverhead += uvLockStats.size;
|
|
4419
|
+
}
|
|
4420
4420
|
const remainingCapacity = LAMBDA_SIZE_THRESHOLD_BYTES - fixedOverhead - runtimeToolingOverhead;
|
|
4421
4421
|
(0, import_build_utils5.debug)(
|
|
4422
4422
|
`Fixed overhead: ${(fixedOverhead / (1024 * 1024)).toFixed(2)} MB, runtime tooling: ${(runtimeToolingOverhead / (1024 * 1024)).toFixed(2)} MB, remaining capacity for public packages: ${(remainingCapacity / (1024 * 1024)).toFixed(2)} MB`
|
|
@@ -4445,9 +4445,6 @@ To fix this, either:
|
|
|
4445
4445
|
...this.alwaysBundlePackages,
|
|
4446
4446
|
...forceBundledDueToWheels
|
|
4447
4447
|
];
|
|
4448
|
-
const projectDirRel = (0, import_path6.relative)(this.workPath, this.uvProjectDir);
|
|
4449
|
-
const uvLockRel = (0, import_path6.relative)(this.workPath, this.uvLockPath);
|
|
4450
|
-
const isOutsideWorkPath = projectDirRel.startsWith("..") || uvLockRel.startsWith("..");
|
|
4451
4448
|
if (isOutsideWorkPath) {
|
|
4452
4449
|
const srcPyproject = (0, import_path6.join)(this.uvProjectDir, "pyproject.toml");
|
|
4453
4450
|
files[`${UV_BUNDLE_DIR}/pyproject.toml`] = new import_build_utils5.FileFsRef({
|
|
@@ -4487,7 +4484,7 @@ To fix this, either:
|
|
|
4487
4484
|
}
|
|
4488
4485
|
}
|
|
4489
4486
|
const finalBundleSize = await calculateBundleSize(files);
|
|
4490
|
-
if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
|
|
4487
|
+
if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES + 100 * 1024) {
|
|
4491
4488
|
const finalSizeMB = (finalBundleSize / (1024 * 1024)).toFixed(2);
|
|
4492
4489
|
const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
|
|
4493
4490
|
throw new import_build_utils5.NowBuildError({
|
|
@@ -4661,19 +4658,261 @@ async function calculatePerPackageSizes(venvPath) {
|
|
|
4661
4658
|
return sizes;
|
|
4662
4659
|
}
|
|
4663
4660
|
|
|
4661
|
+
// src/diagnostics.ts
|
|
4662
|
+
var import_fs5 = __toESM(require("fs"));
|
|
4663
|
+
var import_path7 = require("path");
|
|
4664
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
4665
|
+
var import_python_analysis4 = require("@vercel/python-analysis");
|
|
4666
|
+
var MANIFEST_FILENAME = "package-manifest.json";
|
|
4667
|
+
var DIAGNOSTICS_PATH = (0, import_path7.join)(".vercel", "python", MANIFEST_FILENAME);
|
|
4668
|
+
var MANIFEST_VERSION = "20260304";
|
|
4669
|
+
function isDependencyGroupInclude(entry) {
|
|
4670
|
+
return typeof entry === "object" && "include-group" in entry;
|
|
4671
|
+
}
|
|
4672
|
+
function resolveDependencyGroup(groupName, allGroups, ancestors = /* @__PURE__ */ new Set()) {
|
|
4673
|
+
if (ancestors.has(groupName))
|
|
4674
|
+
return [];
|
|
4675
|
+
const entries = allGroups[groupName];
|
|
4676
|
+
if (!Array.isArray(entries))
|
|
4677
|
+
return [];
|
|
4678
|
+
ancestors.add(groupName);
|
|
4679
|
+
const result = [];
|
|
4680
|
+
for (const entry of entries) {
|
|
4681
|
+
if (typeof entry === "string") {
|
|
4682
|
+
result.push(entry);
|
|
4683
|
+
} else if (isDependencyGroupInclude(entry)) {
|
|
4684
|
+
result.push(
|
|
4685
|
+
...resolveDependencyGroup(entry["include-group"], allGroups, ancestors)
|
|
4686
|
+
);
|
|
4687
|
+
}
|
|
4688
|
+
}
|
|
4689
|
+
ancestors.delete(groupName);
|
|
4690
|
+
return result;
|
|
4691
|
+
}
|
|
4692
|
+
function mapSource(src) {
|
|
4693
|
+
if (!src)
|
|
4694
|
+
return {};
|
|
4695
|
+
if (src.virtual)
|
|
4696
|
+
return {};
|
|
4697
|
+
if (src.registry) {
|
|
4698
|
+
try {
|
|
4699
|
+
const url = new URL(src.registry);
|
|
4700
|
+
return { source: "registry", sourceUrl: url.origin };
|
|
4701
|
+
} catch {
|
|
4702
|
+
return { source: "registry", sourceUrl: src.registry };
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
if (src.git)
|
|
4706
|
+
return { source: "git", sourceUrl: src.git };
|
|
4707
|
+
if (src.url)
|
|
4708
|
+
return { source: "url", sourceUrl: src.url };
|
|
4709
|
+
if (src.editable)
|
|
4710
|
+
return { source: "editable", sourceUrl: src.editable };
|
|
4711
|
+
if (src.path)
|
|
4712
|
+
return { source: "path", sourceUrl: src.path };
|
|
4713
|
+
return {};
|
|
4714
|
+
}
|
|
4715
|
+
async function generateProjectManifest({
|
|
4716
|
+
workPath,
|
|
4717
|
+
pythonPackage,
|
|
4718
|
+
pythonVersion,
|
|
4719
|
+
uvLockPath
|
|
4720
|
+
}) {
|
|
4721
|
+
const resolved = pythonVersionString(pythonVersion);
|
|
4722
|
+
const constraint = pythonPackage.requiresPython?.[0];
|
|
4723
|
+
const requested = constraint?.specifier;
|
|
4724
|
+
const project = pythonPackage.manifest?.data?.project;
|
|
4725
|
+
const pyprojectData = pythonPackage.manifest?.data;
|
|
4726
|
+
const directScopesMap = /* @__PURE__ */ new Map();
|
|
4727
|
+
const directRequested = /* @__PURE__ */ new Map();
|
|
4728
|
+
const allRawDeps = [];
|
|
4729
|
+
if (project?.dependencies && Array.isArray(project.dependencies)) {
|
|
4730
|
+
for (const dep of project.dependencies) {
|
|
4731
|
+
allRawDeps.push({ dep, scope: "main" });
|
|
4732
|
+
}
|
|
4733
|
+
}
|
|
4734
|
+
const optDeps = project?.["optional-dependencies"];
|
|
4735
|
+
if (optDeps) {
|
|
4736
|
+
for (const [group, deps] of Object.entries(optDeps)) {
|
|
4737
|
+
if (Array.isArray(deps)) {
|
|
4738
|
+
for (const dep of deps) {
|
|
4739
|
+
allRawDeps.push({ dep, scope: group });
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
const depGroups = pyprojectData?.["dependency-groups"];
|
|
4745
|
+
if (depGroups) {
|
|
4746
|
+
for (const group of Object.keys(depGroups)) {
|
|
4747
|
+
const groupDeps = resolveDependencyGroup(group, depGroups);
|
|
4748
|
+
for (const dep of groupDeps) {
|
|
4749
|
+
allRawDeps.push({ dep, scope: group });
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
const uvDevDeps = pyprojectData?.tool?.uv?.["dev-dependencies"];
|
|
4754
|
+
if (uvDevDeps && Array.isArray(uvDevDeps)) {
|
|
4755
|
+
for (const dep of uvDevDeps) {
|
|
4756
|
+
allRawDeps.push({ dep, scope: "dev" });
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
const allParsed = await (0, import_python_analysis4.parsePep508)(allRawDeps.map((d) => d.dep));
|
|
4760
|
+
for (let i = 0; i < allRawDeps.length; i++) {
|
|
4761
|
+
const parsed = allParsed[i];
|
|
4762
|
+
if (!parsed)
|
|
4763
|
+
continue;
|
|
4764
|
+
const { dep, scope } = allRawDeps[i];
|
|
4765
|
+
const normalized = (0, import_python_analysis4.normalizePackageName)(parsed.name);
|
|
4766
|
+
let scopes = directScopesMap.get(normalized);
|
|
4767
|
+
if (!scopes) {
|
|
4768
|
+
scopes = /* @__PURE__ */ new Set();
|
|
4769
|
+
directScopesMap.set(normalized, scopes);
|
|
4770
|
+
}
|
|
4771
|
+
scopes.add(scope);
|
|
4772
|
+
if (!directRequested.has(normalized)) {
|
|
4773
|
+
directRequested.set(normalized, dep);
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
const directEntries = [];
|
|
4777
|
+
const transitiveEntries = [];
|
|
4778
|
+
{
|
|
4779
|
+
const content = await import_fs5.default.promises.readFile(uvLockPath, "utf-8");
|
|
4780
|
+
const uvLock = (0, import_python_analysis4.parseUvLock)(content, uvLockPath);
|
|
4781
|
+
const projectName = project?.name;
|
|
4782
|
+
const excludeSet = new Set(
|
|
4783
|
+
projectName ? [(0, import_python_analysis4.normalizePackageName)(projectName)] : []
|
|
4784
|
+
);
|
|
4785
|
+
const lockMap = /* @__PURE__ */ new Map();
|
|
4786
|
+
const depGraph = /* @__PURE__ */ new Map();
|
|
4787
|
+
for (const pkg of uvLock.packages) {
|
|
4788
|
+
const normalized = (0, import_python_analysis4.normalizePackageName)(pkg.name);
|
|
4789
|
+
if (excludeSet.has(normalized))
|
|
4790
|
+
continue;
|
|
4791
|
+
if (pkg.source?.virtual)
|
|
4792
|
+
continue;
|
|
4793
|
+
lockMap.set(normalized, { version: pkg.version, source: pkg.source });
|
|
4794
|
+
if (pkg.dependencies) {
|
|
4795
|
+
const deps = /* @__PURE__ */ new Set();
|
|
4796
|
+
for (const d of pkg.dependencies) {
|
|
4797
|
+
deps.add((0, import_python_analysis4.normalizePackageName)(d.name));
|
|
4798
|
+
}
|
|
4799
|
+
depGraph.set(normalized, deps);
|
|
4800
|
+
}
|
|
4801
|
+
}
|
|
4802
|
+
const transitiveScopesMap = /* @__PURE__ */ new Map();
|
|
4803
|
+
for (const [name, scopes] of directScopesMap) {
|
|
4804
|
+
const queue = [name];
|
|
4805
|
+
let head = 0;
|
|
4806
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4807
|
+
while (head < queue.length) {
|
|
4808
|
+
const current = queue[head++];
|
|
4809
|
+
if (visited.has(current))
|
|
4810
|
+
continue;
|
|
4811
|
+
visited.add(current);
|
|
4812
|
+
const children = depGraph.get(current);
|
|
4813
|
+
if (!children)
|
|
4814
|
+
continue;
|
|
4815
|
+
for (const child of children) {
|
|
4816
|
+
if (excludeSet.has(child))
|
|
4817
|
+
continue;
|
|
4818
|
+
if (!directScopesMap.has(child)) {
|
|
4819
|
+
let childScopes = transitiveScopesMap.get(child);
|
|
4820
|
+
if (!childScopes) {
|
|
4821
|
+
childScopes = /* @__PURE__ */ new Set();
|
|
4822
|
+
transitiveScopesMap.set(child, childScopes);
|
|
4823
|
+
}
|
|
4824
|
+
for (const s of scopes) {
|
|
4825
|
+
childScopes.add(s);
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
if (!visited.has(child)) {
|
|
4829
|
+
queue.push(child);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
for (const [name, scopes] of directScopesMap) {
|
|
4835
|
+
const info = lockMap.get(name);
|
|
4836
|
+
const entry = {
|
|
4837
|
+
name,
|
|
4838
|
+
type: "direct",
|
|
4839
|
+
scopes: [...scopes].sort(),
|
|
4840
|
+
requested: directRequested.get(name)
|
|
4841
|
+
};
|
|
4842
|
+
if (info) {
|
|
4843
|
+
entry.resolved = info.version;
|
|
4844
|
+
const src = mapSource(info.source);
|
|
4845
|
+
if (src.source)
|
|
4846
|
+
entry.source = src.source;
|
|
4847
|
+
if (src.sourceUrl)
|
|
4848
|
+
entry.sourceUrl = src.sourceUrl;
|
|
4849
|
+
}
|
|
4850
|
+
directEntries.push(entry);
|
|
4851
|
+
}
|
|
4852
|
+
for (const [normalized, info] of lockMap) {
|
|
4853
|
+
if (directScopesMap.has(normalized))
|
|
4854
|
+
continue;
|
|
4855
|
+
const scopes = transitiveScopesMap.get(normalized);
|
|
4856
|
+
if (!scopes || scopes.size === 0)
|
|
4857
|
+
continue;
|
|
4858
|
+
const src = mapSource(info.source);
|
|
4859
|
+
transitiveEntries.push({
|
|
4860
|
+
name: normalized,
|
|
4861
|
+
type: "transitive",
|
|
4862
|
+
scopes: [...scopes].sort(),
|
|
4863
|
+
resolved: info.version,
|
|
4864
|
+
...src.source ? { source: src.source } : {},
|
|
4865
|
+
...src.sourceUrl ? { sourceUrl: src.sourceUrl } : {}
|
|
4866
|
+
});
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
const manifest = {
|
|
4870
|
+
version: MANIFEST_VERSION,
|
|
4871
|
+
runtime: "python",
|
|
4872
|
+
runtimeVersion: {
|
|
4873
|
+
...requested ? { requested } : {},
|
|
4874
|
+
...constraint?.source ? { requestedSource: constraint.source } : {},
|
|
4875
|
+
resolved
|
|
4876
|
+
},
|
|
4877
|
+
dependencies: [
|
|
4878
|
+
...directEntries.sort((a, b) => a.name.localeCompare(b.name)),
|
|
4879
|
+
...transitiveEntries.sort((a, b) => a.name.localeCompare(b.name))
|
|
4880
|
+
]
|
|
4881
|
+
};
|
|
4882
|
+
const outPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
|
|
4883
|
+
await import_fs5.default.promises.mkdir((0, import_path7.dirname)(outPath), { recursive: true });
|
|
4884
|
+
await import_fs5.default.promises.writeFile(outPath, JSON.stringify(manifest, null, 2));
|
|
4885
|
+
}
|
|
4886
|
+
var diagnostics = async ({
|
|
4887
|
+
workPath
|
|
4888
|
+
}) => {
|
|
4889
|
+
try {
|
|
4890
|
+
const manifestPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
|
|
4891
|
+
const data = await import_fs5.default.promises.readFile(manifestPath, "utf-8");
|
|
4892
|
+
return {
|
|
4893
|
+
[MANIFEST_FILENAME]: new import_build_utils6.FileBlob({ data })
|
|
4894
|
+
};
|
|
4895
|
+
} catch (err) {
|
|
4896
|
+
(0, import_build_utils6.debug)(
|
|
4897
|
+
`Diagnostics: no cached manifest found: ${err instanceof Error ? err.message : String(err)}`
|
|
4898
|
+
);
|
|
4899
|
+
return {};
|
|
4900
|
+
}
|
|
4901
|
+
};
|
|
4902
|
+
|
|
4664
4903
|
// src/start-dev-server.ts
|
|
4665
4904
|
var import_child_process2 = require("child_process");
|
|
4666
|
-
var
|
|
4667
|
-
var
|
|
4668
|
-
var
|
|
4905
|
+
var import_fs7 = require("fs");
|
|
4906
|
+
var import_path9 = require("path");
|
|
4907
|
+
var import_build_utils9 = require("@vercel/build-utils");
|
|
4669
4908
|
var import_get_port = __toESM(require_get_port());
|
|
4670
4909
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
4671
4910
|
|
|
4672
4911
|
// src/entrypoint.ts
|
|
4673
|
-
var
|
|
4674
|
-
var
|
|
4675
|
-
var import_build_utils6 = require("@vercel/build-utils");
|
|
4912
|
+
var import_fs6 = __toESM(require("fs"));
|
|
4913
|
+
var import_path8 = require("path");
|
|
4676
4914
|
var import_build_utils7 = require("@vercel/build-utils");
|
|
4915
|
+
var import_build_utils8 = require("@vercel/build-utils");
|
|
4677
4916
|
var PYTHON_ENTRYPOINT_FILENAMES = [
|
|
4678
4917
|
"app",
|
|
4679
4918
|
"index",
|
|
@@ -4689,26 +4928,26 @@ var PYTHON_CANDIDATE_ENTRYPOINTS = getCandidateEntrypointsInDirs(
|
|
|
4689
4928
|
function getCandidateEntrypointsInDirs(dirs) {
|
|
4690
4929
|
return dirs.flatMap(
|
|
4691
4930
|
(dir) => PYTHON_ENTRYPOINT_FILENAMES.map(
|
|
4692
|
-
(filename) =>
|
|
4931
|
+
(filename) => import_path8.posix.join(dir, `${filename}.py`)
|
|
4693
4932
|
)
|
|
4694
4933
|
);
|
|
4695
4934
|
}
|
|
4696
4935
|
async function fileExists(filePath) {
|
|
4697
4936
|
try {
|
|
4698
|
-
const stat = await
|
|
4937
|
+
const stat = await import_fs6.default.promises.stat(filePath);
|
|
4699
4938
|
return stat.isFile();
|
|
4700
4939
|
} catch {
|
|
4701
4940
|
return false;
|
|
4702
4941
|
}
|
|
4703
4942
|
}
|
|
4704
4943
|
async function checkEntrypoint(workPath, relPath) {
|
|
4705
|
-
const absPath = (0,
|
|
4944
|
+
const absPath = (0, import_path8.join)(workPath, relPath);
|
|
4706
4945
|
if (!await fileExists(absPath))
|
|
4707
4946
|
return false;
|
|
4708
|
-
return (0,
|
|
4947
|
+
return (0, import_build_utils7.isPythonEntrypoint)({ fsPath: absPath });
|
|
4709
4948
|
}
|
|
4710
4949
|
async function getPyprojectEntrypoint(workPath) {
|
|
4711
|
-
const pyprojectData = await (0,
|
|
4950
|
+
const pyprojectData = await (0, import_build_utils8.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
|
|
4712
4951
|
if (!pyprojectData)
|
|
4713
4952
|
return null;
|
|
4714
4953
|
const scripts = pyprojectData.project?.scripts;
|
|
@@ -4719,30 +4958,32 @@ async function getPyprojectEntrypoint(workPath) {
|
|
|
4719
4958
|
if (!match)
|
|
4720
4959
|
return null;
|
|
4721
4960
|
const modulePath = match[1];
|
|
4961
|
+
const variableName = match[2];
|
|
4722
4962
|
const relPath = modulePath.replace(/\./g, "/");
|
|
4723
4963
|
const candidates = [`${relPath}.py`, `${relPath}/__init__.py`];
|
|
4724
4964
|
for (const candidate of candidates) {
|
|
4725
|
-
if (await fileExists((0,
|
|
4726
|
-
return candidate;
|
|
4965
|
+
if (await fileExists((0, import_path8.join)(workPath, candidate))) {
|
|
4966
|
+
return { entrypoint: candidate, variableName };
|
|
4967
|
+
}
|
|
4727
4968
|
}
|
|
4728
4969
|
return null;
|
|
4729
4970
|
}
|
|
4730
4971
|
async function findValidEntrypoint(workPath, candidates) {
|
|
4731
4972
|
for (const candidate of candidates) {
|
|
4732
4973
|
if (await checkEntrypoint(workPath, candidate)) {
|
|
4733
|
-
(0,
|
|
4974
|
+
(0, import_build_utils7.debug)(`Detected Python entrypoint: ${candidate}`);
|
|
4734
4975
|
return candidate;
|
|
4735
4976
|
}
|
|
4736
4977
|
}
|
|
4737
4978
|
return null;
|
|
4738
4979
|
}
|
|
4739
4980
|
async function checkDjangoManage(workPath) {
|
|
4740
|
-
const managePath = (0,
|
|
4981
|
+
const managePath = (0, import_path8.join)(workPath, "manage.py");
|
|
4741
4982
|
try {
|
|
4742
|
-
const content = await
|
|
4983
|
+
const content = await import_fs6.default.promises.readFile(managePath, "utf-8");
|
|
4743
4984
|
if (!content.includes("DJANGO_SETTINGS_MODULE"))
|
|
4744
4985
|
return false;
|
|
4745
|
-
(0,
|
|
4986
|
+
(0, import_build_utils7.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
|
|
4746
4987
|
return true;
|
|
4747
4988
|
} catch {
|
|
4748
4989
|
return false;
|
|
@@ -4750,7 +4991,7 @@ async function checkDjangoManage(workPath) {
|
|
|
4750
4991
|
}
|
|
4751
4992
|
async function getSubdirectories(workPath) {
|
|
4752
4993
|
try {
|
|
4753
|
-
const entries = await
|
|
4994
|
+
const entries = await import_fs6.default.promises.readdir(workPath, {
|
|
4754
4995
|
withFileTypes: true
|
|
4755
4996
|
});
|
|
4756
4997
|
return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
@@ -4762,7 +5003,7 @@ async function detectGenericPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4762
5003
|
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
4763
5004
|
try {
|
|
4764
5005
|
if (await checkEntrypoint(workPath, entry)) {
|
|
4765
|
-
(0,
|
|
5006
|
+
(0, import_build_utils7.debug)(`Using configured Python entrypoint: ${entry}`);
|
|
4766
5007
|
return { entrypoint: entry };
|
|
4767
5008
|
}
|
|
4768
5009
|
const found = await findValidEntrypoint(
|
|
@@ -4771,7 +5012,7 @@ async function detectGenericPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4771
5012
|
);
|
|
4772
5013
|
return found ? { entrypoint: found } : null;
|
|
4773
5014
|
} catch {
|
|
4774
|
-
(0,
|
|
5015
|
+
(0, import_build_utils7.debug)("Failed to discover Python entrypoint");
|
|
4775
5016
|
return null;
|
|
4776
5017
|
}
|
|
4777
5018
|
}
|
|
@@ -4779,13 +5020,13 @@ async function detectDjangoPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4779
5020
|
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
4780
5021
|
try {
|
|
4781
5022
|
if (await checkEntrypoint(workPath, entry)) {
|
|
4782
|
-
(0,
|
|
5023
|
+
(0, import_build_utils7.debug)(`Using configured Python entrypoint: ${entry}`);
|
|
4783
5024
|
return { entrypoint: entry };
|
|
4784
5025
|
}
|
|
4785
5026
|
const subdirs = await getSubdirectories(workPath);
|
|
4786
5027
|
const rootDirs = ["", ...subdirs];
|
|
4787
5028
|
for (const rootDir of rootDirs) {
|
|
4788
|
-
const currPath = (0,
|
|
5029
|
+
const currPath = (0, import_path8.join)(workPath, rootDir);
|
|
4789
5030
|
const isDjango = await checkDjangoManage(currPath);
|
|
4790
5031
|
if (isDjango) {
|
|
4791
5032
|
return { baseDir: rootDir };
|
|
@@ -4795,7 +5036,7 @@ async function detectDjangoPythonEntrypoint(workPath, configuredEntrypoint) {
|
|
|
4795
5036
|
const found = await findValidEntrypoint(workPath, candidates);
|
|
4796
5037
|
return found ? { entrypoint: found } : null;
|
|
4797
5038
|
} catch {
|
|
4798
|
-
(0,
|
|
5039
|
+
(0, import_build_utils7.debug)("Failed to discover Django Python entrypoint");
|
|
4799
5040
|
return null;
|
|
4800
5041
|
}
|
|
4801
5042
|
}
|
|
@@ -4804,11 +5045,16 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint)
|
|
|
4804
5045
|
if (result)
|
|
4805
5046
|
return result;
|
|
4806
5047
|
const pyprojectEntry = await getPyprojectEntrypoint(workPath);
|
|
4807
|
-
|
|
5048
|
+
if (!pyprojectEntry)
|
|
5049
|
+
return null;
|
|
5050
|
+
return {
|
|
5051
|
+
entrypoint: pyprojectEntry.entrypoint,
|
|
5052
|
+
variableName: pyprojectEntry.variableName
|
|
5053
|
+
};
|
|
4808
5054
|
}
|
|
4809
5055
|
|
|
4810
5056
|
// src/start-dev-server.ts
|
|
4811
|
-
var
|
|
5057
|
+
var import_python_analysis5 = require("@vercel/python-analysis");
|
|
4812
5058
|
var DEV_SERVER_STARTUP_TIMEOUT = 5 * 6e4;
|
|
4813
5059
|
function silenceNodeWarnings() {
|
|
4814
5060
|
const original = process.emitWarning.bind(
|
|
@@ -4835,6 +5081,10 @@ function silenceNodeWarnings() {
|
|
|
4835
5081
|
};
|
|
4836
5082
|
}
|
|
4837
5083
|
var DEV_SHIM_MODULE = "vc_init_dev";
|
|
5084
|
+
function hasWorkerServicesEnabled(env) {
|
|
5085
|
+
const value = env.VERCEL_HAS_WORKER_SERVICES || "";
|
|
5086
|
+
return ["1", "true"].includes(value.trim().toLowerCase());
|
|
5087
|
+
}
|
|
4838
5088
|
function createLogListener(callback, stream) {
|
|
4839
5089
|
return (buf) => {
|
|
4840
5090
|
if (callback) {
|
|
@@ -4890,17 +5140,17 @@ async function syncDependencies({
|
|
|
4890
5140
|
let { manifestPath } = installInfo;
|
|
4891
5141
|
const manifest = pythonPackage.manifest;
|
|
4892
5142
|
if (!manifestType || !manifestPath) {
|
|
4893
|
-
(0,
|
|
5143
|
+
(0, import_build_utils9.debug)("No Python project manifest found, skipping dependency sync");
|
|
4894
5144
|
return;
|
|
4895
5145
|
}
|
|
4896
5146
|
if (manifest?.origin && manifestType === "pyproject.toml") {
|
|
4897
|
-
const syncDir = (0,
|
|
4898
|
-
(0,
|
|
4899
|
-
const tempPyproject = (0,
|
|
4900
|
-
const content = (0,
|
|
4901
|
-
(0,
|
|
5147
|
+
const syncDir = (0, import_path9.join)(workPath, ".vercel", "python", "sync");
|
|
5148
|
+
(0, import_fs7.mkdirSync)(syncDir, { recursive: true });
|
|
5149
|
+
const tempPyproject = (0, import_path9.join)(syncDir, "pyproject.toml");
|
|
5150
|
+
const content = (0, import_python_analysis5.stringifyManifest)(manifest.data);
|
|
5151
|
+
(0, import_fs7.writeFileSync)(tempPyproject, content, "utf8");
|
|
4902
5152
|
manifestPath = tempPyproject;
|
|
4903
|
-
(0,
|
|
5153
|
+
(0, import_build_utils9.debug)(
|
|
4904
5154
|
`Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
|
|
4905
5155
|
);
|
|
4906
5156
|
}
|
|
@@ -4933,7 +5183,7 @@ async function syncDependencies({
|
|
|
4933
5183
|
for (const [channel, chunk] of captured) {
|
|
4934
5184
|
(channel === "stdout" ? writeOut : writeErr)(chunk.toString());
|
|
4935
5185
|
}
|
|
4936
|
-
throw new
|
|
5186
|
+
throw new import_build_utils9.NowBuildError({
|
|
4937
5187
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
4938
5188
|
message: `Failed to install Python dependencies from ${manifestType}: ${err instanceof Error ? err.message : String(err)}`
|
|
4939
5189
|
});
|
|
@@ -4948,14 +5198,14 @@ async function runSync({
|
|
|
4948
5198
|
onStdout,
|
|
4949
5199
|
onStderr
|
|
4950
5200
|
}) {
|
|
4951
|
-
const projectDir = (0,
|
|
5201
|
+
const projectDir = (0, import_path9.dirname)(manifestPath);
|
|
4952
5202
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
4953
5203
|
let spawnCmd;
|
|
4954
5204
|
let spawnArgs;
|
|
4955
5205
|
switch (manifestType) {
|
|
4956
5206
|
case "uv.lock": {
|
|
4957
5207
|
if (!uvPath) {
|
|
4958
|
-
throw new
|
|
5208
|
+
throw new import_build_utils9.NowBuildError({
|
|
4959
5209
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
4960
5210
|
message: "uv is required to install dependencies from uv.lock.",
|
|
4961
5211
|
link: "https://docs.astral.sh/uv/getting-started/installation/",
|
|
@@ -4977,11 +5227,11 @@ async function runSync({
|
|
|
4977
5227
|
break;
|
|
4978
5228
|
}
|
|
4979
5229
|
default:
|
|
4980
|
-
(0,
|
|
5230
|
+
(0, import_build_utils9.debug)(`Unknown manifest type: ${manifestType}`);
|
|
4981
5231
|
return;
|
|
4982
5232
|
}
|
|
4983
5233
|
await new Promise((resolve3, reject) => {
|
|
4984
|
-
(0,
|
|
5234
|
+
(0, import_build_utils9.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
|
|
4985
5235
|
const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
|
|
4986
5236
|
cwd: projectDir,
|
|
4987
5237
|
env: getProtectedUvEnv(env),
|
|
@@ -5016,6 +5266,7 @@ async function runSync({
|
|
|
5016
5266
|
});
|
|
5017
5267
|
}
|
|
5018
5268
|
var PENDING_RUNTIME_INSTALLS = /* @__PURE__ */ new Map();
|
|
5269
|
+
var PENDING_WORKERS_INSTALLS = /* @__PURE__ */ new Map();
|
|
5019
5270
|
async function installVercelRuntime({
|
|
5020
5271
|
workPath,
|
|
5021
5272
|
uvPath,
|
|
@@ -5024,7 +5275,7 @@ async function installVercelRuntime({
|
|
|
5024
5275
|
onStdout,
|
|
5025
5276
|
onStderr
|
|
5026
5277
|
}) {
|
|
5027
|
-
const targetDir = (0,
|
|
5278
|
+
const targetDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5028
5279
|
let pending = PENDING_RUNTIME_INSTALLS.get(targetDir);
|
|
5029
5280
|
if (!pending) {
|
|
5030
5281
|
pending = doInstallVercelRuntime({
|
|
@@ -5050,8 +5301,8 @@ async function doInstallVercelRuntime({
|
|
|
5050
5301
|
onStdout,
|
|
5051
5302
|
onStderr
|
|
5052
5303
|
}) {
|
|
5053
|
-
(0,
|
|
5054
|
-
const localRuntimeDir = (0,
|
|
5304
|
+
(0, import_fs7.mkdirSync)(targetDir, { recursive: true });
|
|
5305
|
+
const localRuntimeDir = (0, import_path9.join)(
|
|
5055
5306
|
__dirname,
|
|
5056
5307
|
"..",
|
|
5057
5308
|
"..",
|
|
@@ -5059,21 +5310,21 @@ async function doInstallVercelRuntime({
|
|
|
5059
5310
|
"python",
|
|
5060
5311
|
"vercel-runtime"
|
|
5061
5312
|
);
|
|
5062
|
-
const isLocalDev = (0,
|
|
5313
|
+
const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localRuntimeDir, "pyproject.toml"));
|
|
5063
5314
|
const runtimeDep = env.VERCEL_RUNTIME_PYTHON || (isLocalDev ? localRuntimeDir : `vercel-runtime==${VERCEL_RUNTIME_VERSION}`);
|
|
5064
5315
|
if (!isLocalDev && !env.VERCEL_RUNTIME_PYTHON) {
|
|
5065
|
-
const distInfo = (0,
|
|
5316
|
+
const distInfo = (0, import_path9.join)(
|
|
5066
5317
|
targetDir,
|
|
5067
5318
|
`vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
|
|
5068
5319
|
);
|
|
5069
|
-
if ((0,
|
|
5070
|
-
(0,
|
|
5320
|
+
if ((0, import_fs7.existsSync)(distInfo)) {
|
|
5321
|
+
(0, import_build_utils9.debug)(
|
|
5071
5322
|
`vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
|
|
5072
5323
|
);
|
|
5073
5324
|
return;
|
|
5074
5325
|
}
|
|
5075
5326
|
}
|
|
5076
|
-
(0,
|
|
5327
|
+
(0, import_build_utils9.debug)(
|
|
5077
5328
|
`Installing vercel-runtime into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${runtimeDep})`
|
|
5078
5329
|
);
|
|
5079
5330
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
@@ -5088,14 +5339,14 @@ async function doInstallVercelRuntime({
|
|
|
5088
5339
|
if (onStdout) {
|
|
5089
5340
|
onStdout(data);
|
|
5090
5341
|
} else {
|
|
5091
|
-
(0,
|
|
5342
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5092
5343
|
}
|
|
5093
5344
|
});
|
|
5094
5345
|
child.stderr?.on("data", (data) => {
|
|
5095
5346
|
if (onStderr) {
|
|
5096
5347
|
onStderr(data);
|
|
5097
5348
|
} else {
|
|
5098
|
-
(0,
|
|
5349
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5099
5350
|
}
|
|
5100
5351
|
});
|
|
5101
5352
|
child.on("error", reject);
|
|
@@ -5112,6 +5363,102 @@ async function doInstallVercelRuntime({
|
|
|
5112
5363
|
});
|
|
5113
5364
|
});
|
|
5114
5365
|
}
|
|
5366
|
+
async function installVercelWorkers({
|
|
5367
|
+
workPath,
|
|
5368
|
+
uvPath,
|
|
5369
|
+
pythonBin,
|
|
5370
|
+
env,
|
|
5371
|
+
onStdout,
|
|
5372
|
+
onStderr
|
|
5373
|
+
}) {
|
|
5374
|
+
const targetDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5375
|
+
let pending = PENDING_WORKERS_INSTALLS.get(targetDir);
|
|
5376
|
+
if (!pending) {
|
|
5377
|
+
pending = doInstallVercelWorkers({
|
|
5378
|
+
targetDir,
|
|
5379
|
+
workPath,
|
|
5380
|
+
uvPath,
|
|
5381
|
+
pythonBin,
|
|
5382
|
+
env,
|
|
5383
|
+
onStdout,
|
|
5384
|
+
onStderr
|
|
5385
|
+
});
|
|
5386
|
+
PENDING_WORKERS_INSTALLS.set(targetDir, pending);
|
|
5387
|
+
pending.finally(() => PENDING_WORKERS_INSTALLS.delete(targetDir));
|
|
5388
|
+
}
|
|
5389
|
+
await pending;
|
|
5390
|
+
}
|
|
5391
|
+
async function doInstallVercelWorkers({
|
|
5392
|
+
targetDir,
|
|
5393
|
+
workPath,
|
|
5394
|
+
uvPath,
|
|
5395
|
+
pythonBin,
|
|
5396
|
+
env,
|
|
5397
|
+
onStdout,
|
|
5398
|
+
onStderr
|
|
5399
|
+
}) {
|
|
5400
|
+
(0, import_fs7.mkdirSync)(targetDir, { recursive: true });
|
|
5401
|
+
const localWorkersDir = (0, import_path9.join)(
|
|
5402
|
+
__dirname,
|
|
5403
|
+
"..",
|
|
5404
|
+
"..",
|
|
5405
|
+
"..",
|
|
5406
|
+
"python",
|
|
5407
|
+
"vercel-workers"
|
|
5408
|
+
);
|
|
5409
|
+
const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localWorkersDir, "pyproject.toml"));
|
|
5410
|
+
const workersDep = env.VERCEL_WORKERS_PYTHON || (isLocalDev ? localWorkersDir : `vercel-workers==${VERCEL_WORKERS_VERSION}`);
|
|
5411
|
+
if (!isLocalDev && !env.VERCEL_WORKERS_PYTHON) {
|
|
5412
|
+
const distInfo = (0, import_path9.join)(
|
|
5413
|
+
targetDir,
|
|
5414
|
+
`vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
|
|
5415
|
+
);
|
|
5416
|
+
if ((0, import_fs7.existsSync)(distInfo)) {
|
|
5417
|
+
(0, import_build_utils9.debug)(
|
|
5418
|
+
`vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
|
|
5419
|
+
);
|
|
5420
|
+
return;
|
|
5421
|
+
}
|
|
5422
|
+
}
|
|
5423
|
+
(0, import_build_utils9.debug)(
|
|
5424
|
+
`Installing vercel-workers into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${workersDep})`
|
|
5425
|
+
);
|
|
5426
|
+
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
5427
|
+
const spawnArgs = [...pip.prefix, "--target", targetDir, workersDep];
|
|
5428
|
+
await new Promise((resolve3, reject) => {
|
|
5429
|
+
const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
|
|
5430
|
+
cwd: workPath,
|
|
5431
|
+
env: getProtectedUvEnv(env),
|
|
5432
|
+
stdio: ["inherit", "pipe", "pipe"]
|
|
5433
|
+
});
|
|
5434
|
+
child.stdout?.on("data", (data) => {
|
|
5435
|
+
if (onStdout) {
|
|
5436
|
+
onStdout(data);
|
|
5437
|
+
} else {
|
|
5438
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5439
|
+
}
|
|
5440
|
+
});
|
|
5441
|
+
child.stderr?.on("data", (data) => {
|
|
5442
|
+
if (onStderr) {
|
|
5443
|
+
onStderr(data);
|
|
5444
|
+
} else {
|
|
5445
|
+
(0, import_build_utils9.debug)(data.toString());
|
|
5446
|
+
}
|
|
5447
|
+
});
|
|
5448
|
+
child.on("error", reject);
|
|
5449
|
+
child.on("exit", (code, signal) => {
|
|
5450
|
+
if (code === 0) {
|
|
5451
|
+
resolve3();
|
|
5452
|
+
} else {
|
|
5453
|
+
reject(
|
|
5454
|
+
new Error(
|
|
5455
|
+
`Installing vercel-workers failed with code ${code}, signal ${signal}`
|
|
5456
|
+
)
|
|
5457
|
+
);
|
|
5458
|
+
}
|
|
5459
|
+
});
|
|
5460
|
+
});
|
|
5461
|
+
}
|
|
5115
5462
|
var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
|
|
5116
5463
|
var PENDING_STARTS = /* @__PURE__ */ new Map();
|
|
5117
5464
|
var restoreWarnings = null;
|
|
@@ -5125,12 +5472,12 @@ function installGlobalCleanupHandlers() {
|
|
|
5125
5472
|
try {
|
|
5126
5473
|
process.kill(info.pid, "SIGTERM");
|
|
5127
5474
|
} catch (err) {
|
|
5128
|
-
(0,
|
|
5475
|
+
(0, import_build_utils9.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
5129
5476
|
}
|
|
5130
5477
|
try {
|
|
5131
5478
|
process.kill(info.pid, "SIGKILL");
|
|
5132
5479
|
} catch (err) {
|
|
5133
|
-
(0,
|
|
5480
|
+
(0, import_build_utils9.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
5134
5481
|
}
|
|
5135
5482
|
PERSISTENT_SERVERS.delete(key);
|
|
5136
5483
|
}
|
|
@@ -5138,7 +5485,7 @@ function installGlobalCleanupHandlers() {
|
|
|
5138
5485
|
try {
|
|
5139
5486
|
restoreWarnings();
|
|
5140
5487
|
} catch (err) {
|
|
5141
|
-
(0,
|
|
5488
|
+
(0, import_build_utils9.debug)(`Error restoring warnings: ${err}`);
|
|
5142
5489
|
}
|
|
5143
5490
|
restoreWarnings = null;
|
|
5144
5491
|
}
|
|
@@ -5153,52 +5500,52 @@ function installGlobalCleanupHandlers() {
|
|
|
5153
5500
|
killAll();
|
|
5154
5501
|
});
|
|
5155
5502
|
}
|
|
5156
|
-
function createDevShim(workPath, entry, modulePath, serviceName, framework) {
|
|
5503
|
+
function createDevShim(workPath, entry, modulePath, serviceName, framework, variableName) {
|
|
5157
5504
|
try {
|
|
5158
|
-
const vercelPythonDir = serviceName ? (0,
|
|
5159
|
-
(0,
|
|
5505
|
+
const vercelPythonDir = serviceName ? (0, import_path9.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5506
|
+
(0, import_fs7.mkdirSync)(vercelPythonDir, { recursive: true });
|
|
5160
5507
|
let qualifiedModule = modulePath;
|
|
5161
5508
|
let extraPythonPath;
|
|
5162
|
-
if ((0,
|
|
5163
|
-
const pkgName = (0,
|
|
5509
|
+
if ((0, import_fs7.existsSync)((0, import_path9.join)(workPath, "__init__.py"))) {
|
|
5510
|
+
const pkgName = (0, import_path9.basename)(workPath);
|
|
5164
5511
|
qualifiedModule = `${pkgName}.${modulePath}`;
|
|
5165
|
-
extraPythonPath = (0,
|
|
5512
|
+
extraPythonPath = (0, import_path9.dirname)(workPath);
|
|
5166
5513
|
}
|
|
5167
|
-
const entryAbs = (0,
|
|
5168
|
-
const shimPath = (0,
|
|
5169
|
-
const templatePath = (0,
|
|
5514
|
+
const entryAbs = (0, import_path9.join)(workPath, entry);
|
|
5515
|
+
const shimPath = (0, import_path9.join)(vercelPythonDir, `${DEV_SHIM_MODULE}.py`);
|
|
5516
|
+
const templatePath = (0, import_path9.join)(
|
|
5170
5517
|
__dirname,
|
|
5171
5518
|
"..",
|
|
5172
5519
|
"templates",
|
|
5173
5520
|
`${DEV_SHIM_MODULE}.py`
|
|
5174
5521
|
);
|
|
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,
|
|
5522
|
+
const template = (0, import_fs7.readFileSync)(templatePath, "utf8");
|
|
5523
|
+
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);
|
|
5524
|
+
(0, import_fs7.writeFileSync)(shimPath, shimSource, "utf8");
|
|
5525
|
+
(0, import_build_utils9.debug)(`Prepared Python dev shim at ${shimPath}`);
|
|
5179
5526
|
return {
|
|
5180
5527
|
module: DEV_SHIM_MODULE,
|
|
5181
5528
|
extraPythonPath,
|
|
5182
5529
|
shimDir: vercelPythonDir
|
|
5183
5530
|
};
|
|
5184
5531
|
} catch (err) {
|
|
5185
|
-
(0,
|
|
5532
|
+
(0, import_build_utils9.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
|
|
5186
5533
|
return null;
|
|
5187
5534
|
}
|
|
5188
5535
|
}
|
|
5189
5536
|
async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath) {
|
|
5190
5537
|
const { pythonCmd, venvRoot } = useVirtualEnv(workPath, env, systemPython);
|
|
5191
5538
|
if (venvRoot) {
|
|
5192
|
-
(0,
|
|
5539
|
+
(0, import_build_utils9.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
|
|
5193
5540
|
return { command: pythonCmd, args: [] };
|
|
5194
5541
|
}
|
|
5195
|
-
const venvPath = (0,
|
|
5542
|
+
const venvPath = (0, import_path9.join)(workPath, ".venv");
|
|
5196
5543
|
await ensureVenv({ pythonPath: systemPython, venvPath, uvPath, quiet: true });
|
|
5197
|
-
(0,
|
|
5544
|
+
(0, import_build_utils9.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
|
|
5198
5545
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
5199
5546
|
const binDir = getVenvBinDir(venvPath);
|
|
5200
5547
|
env.VIRTUAL_ENV = venvPath;
|
|
5201
|
-
env.PATH = `${binDir}${
|
|
5548
|
+
env.PATH = `${binDir}${import_path9.delimiter}${env.PATH || ""}`;
|
|
5202
5549
|
return { command: pythonBin, args: [] };
|
|
5203
5550
|
}
|
|
5204
5551
|
var startDevServer = async (opts) => {
|
|
@@ -5243,6 +5590,7 @@ var startDevServer = async (opts) => {
|
|
|
5243
5590
|
const env = { ...process.env, ...meta.env || {} };
|
|
5244
5591
|
const serviceType = env.VERCEL_SERVICE_TYPE;
|
|
5245
5592
|
let entry;
|
|
5593
|
+
let variableName;
|
|
5246
5594
|
if ((serviceType === "cron" || serviceType === "worker") && rawEntrypoint?.endsWith(".py")) {
|
|
5247
5595
|
entry = rawEntrypoint;
|
|
5248
5596
|
} else {
|
|
@@ -5252,19 +5600,21 @@ var startDevServer = async (opts) => {
|
|
|
5252
5600
|
rawEntrypoint
|
|
5253
5601
|
);
|
|
5254
5602
|
entry = detected?.entrypoint;
|
|
5603
|
+
variableName = detected?.variableName;
|
|
5255
5604
|
if (!entry) {
|
|
5256
5605
|
const hookResult = await runFrameworkHook(framework, {
|
|
5257
5606
|
pythonEnv: env,
|
|
5258
|
-
projectDir: (0,
|
|
5607
|
+
projectDir: (0, import_path9.join)(workPath, detected?.baseDir ?? ""),
|
|
5259
5608
|
workPath,
|
|
5260
5609
|
entrypoint: rawEntrypoint,
|
|
5261
5610
|
detected: detected ?? void 0
|
|
5262
5611
|
});
|
|
5263
5612
|
entry = hookResult?.entrypoint;
|
|
5613
|
+
variableName = hookResult?.variableName;
|
|
5264
5614
|
}
|
|
5265
5615
|
if (!entry) {
|
|
5266
5616
|
const searched = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
5267
|
-
throw new
|
|
5617
|
+
throw new import_build_utils9.NowBuildError({
|
|
5268
5618
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
5269
5619
|
message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searched}.`,
|
|
5270
5620
|
link: `https://vercel.com/docs/frameworks/backend/${framework?.toLowerCase()}#exporting-the-${framework?.toLowerCase()}-application`,
|
|
@@ -5295,7 +5645,7 @@ var startDevServer = async (opts) => {
|
|
|
5295
5645
|
const yellow = "\x1B[33m";
|
|
5296
5646
|
const white = "\x1B[1m";
|
|
5297
5647
|
const reset = "\x1B[0m";
|
|
5298
|
-
throw new
|
|
5648
|
+
throw new import_build_utils9.NowBuildError({
|
|
5299
5649
|
code: "PYTHON_EXTERNAL_VENV_DETECTED",
|
|
5300
5650
|
message: `Detected activated venv at ${yellow}${venv}${reset}, ${white}vercel dev${reset} manages virtual environments automatically.
|
|
5301
5651
|
Run ${white}deactivate${reset} and try again.`
|
|
@@ -5312,11 +5662,11 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
5312
5662
|
);
|
|
5313
5663
|
spawnCommand = runner.command;
|
|
5314
5664
|
spawnArgsPrefix = runner.args;
|
|
5315
|
-
(0,
|
|
5665
|
+
(0, import_build_utils9.debug)(
|
|
5316
5666
|
`Multi-service Python runner: ${spawnCommand} ${spawnArgsPrefix.join(" ")}`
|
|
5317
5667
|
);
|
|
5318
5668
|
} else if (venv) {
|
|
5319
|
-
(0,
|
|
5669
|
+
(0, import_build_utils9.debug)(`Running in virtualenv at ${venv}`);
|
|
5320
5670
|
} else {
|
|
5321
5671
|
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
5322
5672
|
workPath,
|
|
@@ -5325,9 +5675,9 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
5325
5675
|
);
|
|
5326
5676
|
spawnCommand = venvPythonCmd;
|
|
5327
5677
|
if (venvRoot) {
|
|
5328
|
-
(0,
|
|
5678
|
+
(0, import_build_utils9.debug)(`Using virtualenv at ${venvRoot}`);
|
|
5329
5679
|
} else {
|
|
5330
|
-
(0,
|
|
5680
|
+
(0, import_build_utils9.debug)("No virtualenv found");
|
|
5331
5681
|
try {
|
|
5332
5682
|
const yellow = "\x1B[33m";
|
|
5333
5683
|
const reset = "\x1B[0m";
|
|
@@ -5366,24 +5716,35 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5366
5716
|
pythonBin: spawnCommand,
|
|
5367
5717
|
env
|
|
5368
5718
|
});
|
|
5719
|
+
if (hasWorkerServicesEnabled(env)) {
|
|
5720
|
+
await installVercelWorkers({
|
|
5721
|
+
workPath,
|
|
5722
|
+
uvPath,
|
|
5723
|
+
pythonBin: spawnCommand,
|
|
5724
|
+
env,
|
|
5725
|
+
onStdout,
|
|
5726
|
+
onStderr
|
|
5727
|
+
});
|
|
5728
|
+
}
|
|
5369
5729
|
const port = typeof meta.port === "number" ? meta.port : await (0, import_get_port.default)();
|
|
5370
5730
|
env.PORT = `${port}`;
|
|
5371
5731
|
if (config.handlerFunction && typeof config?.handlerFunction === "string") {
|
|
5372
5732
|
env.__VC_HANDLER_FUNC_NAME = config.handlerFunction;
|
|
5373
5733
|
}
|
|
5374
5734
|
if (entry) {
|
|
5375
|
-
env.__VC_HANDLER_ENTRYPOINT_ABS = (0,
|
|
5735
|
+
env.__VC_HANDLER_ENTRYPOINT_ABS = (0, import_path9.join)(workPath, entry);
|
|
5376
5736
|
}
|
|
5377
5737
|
const devShim = createDevShim(
|
|
5378
5738
|
workPath,
|
|
5379
5739
|
entry,
|
|
5380
5740
|
modulePath,
|
|
5381
5741
|
serviceName,
|
|
5382
|
-
framework
|
|
5742
|
+
framework,
|
|
5743
|
+
variableName ?? ""
|
|
5383
5744
|
);
|
|
5384
5745
|
if (devShim) {
|
|
5385
|
-
const shimDir = devShim.shimDir || (0,
|
|
5386
|
-
const runtimeDir = (0,
|
|
5746
|
+
const shimDir = devShim.shimDir || (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5747
|
+
const runtimeDir = (0, import_path9.join)(workPath, ".vercel", "python");
|
|
5387
5748
|
const pathParts = shimDir !== runtimeDir ? [shimDir, runtimeDir] : [shimDir];
|
|
5388
5749
|
if (devShim.extraPythonPath) {
|
|
5389
5750
|
pathParts.push(devShim.extraPythonPath);
|
|
@@ -5392,12 +5753,12 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5392
5753
|
if (existingPythonPath) {
|
|
5393
5754
|
pathParts.push(existingPythonPath);
|
|
5394
5755
|
}
|
|
5395
|
-
env.PYTHONPATH = pathParts.join(
|
|
5756
|
+
env.PYTHONPATH = pathParts.join(import_path9.delimiter);
|
|
5396
5757
|
}
|
|
5397
5758
|
const moduleToRun = devShim?.module || modulePath;
|
|
5398
5759
|
const pythonArgs = ["-u", "-m", moduleToRun];
|
|
5399
5760
|
const argv = [...spawnArgsPrefix, ...pythonArgs];
|
|
5400
|
-
(0,
|
|
5761
|
+
(0, import_build_utils9.debug)(
|
|
5401
5762
|
`Starting Python dev server (${framework}): ${spawnCommand} ${argv.join(" ")} [PORT=${port}]`
|
|
5402
5763
|
);
|
|
5403
5764
|
if (process.stdout.columns) {
|
|
@@ -5451,8 +5812,8 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
5451
5812
|
};
|
|
5452
5813
|
|
|
5453
5814
|
// src/quirks/index.ts
|
|
5454
|
-
var
|
|
5455
|
-
var
|
|
5815
|
+
var import_build_utils12 = require("@vercel/build-utils");
|
|
5816
|
+
var import_python_analysis7 = require("@vercel/python-analysis");
|
|
5456
5817
|
|
|
5457
5818
|
// src/quirks/matplotlib.ts
|
|
5458
5819
|
var matplotlibQuirk = {
|
|
@@ -5465,9 +5826,9 @@ var matplotlibQuirk = {
|
|
|
5465
5826
|
};
|
|
5466
5827
|
|
|
5467
5828
|
// src/quirks/litellm.ts
|
|
5468
|
-
var
|
|
5469
|
-
var
|
|
5470
|
-
var
|
|
5829
|
+
var import_fs8 = __toESM(require("fs"));
|
|
5830
|
+
var import_path10 = require("path");
|
|
5831
|
+
var import_build_utils10 = require("@vercel/build-utils");
|
|
5471
5832
|
var LAMBDA_ROOT = "/var/task";
|
|
5472
5833
|
var CONFIG_CANDIDATES = [
|
|
5473
5834
|
"litellm_config.yaml",
|
|
@@ -5477,9 +5838,9 @@ var CONFIG_CANDIDATES = [
|
|
|
5477
5838
|
];
|
|
5478
5839
|
async function findConfigFile(workPath) {
|
|
5479
5840
|
for (const name of CONFIG_CANDIDATES) {
|
|
5480
|
-
const candidate = (0,
|
|
5841
|
+
const candidate = (0, import_path10.join)(workPath, name);
|
|
5481
5842
|
try {
|
|
5482
|
-
await
|
|
5843
|
+
await import_fs8.default.promises.access(candidate);
|
|
5483
5844
|
return name;
|
|
5484
5845
|
} catch {
|
|
5485
5846
|
}
|
|
@@ -5494,32 +5855,32 @@ var litellmQuirk = {
|
|
|
5494
5855
|
const env = {};
|
|
5495
5856
|
const sitePackagesDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
5496
5857
|
for (const sitePackages of sitePackagesDirs) {
|
|
5497
|
-
const schemaPath = (0,
|
|
5858
|
+
const schemaPath = (0, import_path10.join)(
|
|
5498
5859
|
sitePackages,
|
|
5499
5860
|
"litellm",
|
|
5500
5861
|
"proxy",
|
|
5501
5862
|
"schema.prisma"
|
|
5502
5863
|
);
|
|
5503
5864
|
try {
|
|
5504
|
-
await
|
|
5505
|
-
(0,
|
|
5865
|
+
await import_fs8.default.promises.access(schemaPath);
|
|
5866
|
+
(0, import_build_utils10.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
|
|
5506
5867
|
buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
|
|
5507
5868
|
break;
|
|
5508
5869
|
} catch {
|
|
5509
5870
|
}
|
|
5510
5871
|
}
|
|
5511
5872
|
if (!buildEnv.PRISMA_SCHEMA_PATH) {
|
|
5512
|
-
(0,
|
|
5873
|
+
(0, import_build_utils10.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
|
|
5513
5874
|
}
|
|
5514
5875
|
if (!process.env.CONFIG_FILE_PATH) {
|
|
5515
5876
|
const configName = await findConfigFile(ctx.workPath);
|
|
5516
5877
|
if (configName) {
|
|
5517
|
-
(0,
|
|
5518
|
-
buildEnv.CONFIG_FILE_PATH = (0,
|
|
5519
|
-
env.CONFIG_FILE_PATH = (0,
|
|
5878
|
+
(0, import_build_utils10.debug)(`LiteLLM quirk: found config at ${configName}`);
|
|
5879
|
+
buildEnv.CONFIG_FILE_PATH = (0, import_path10.join)(ctx.workPath, configName);
|
|
5880
|
+
env.CONFIG_FILE_PATH = (0, import_path10.join)(LAMBDA_ROOT, configName);
|
|
5520
5881
|
}
|
|
5521
5882
|
} else {
|
|
5522
|
-
(0,
|
|
5883
|
+
(0, import_build_utils10.debug)(
|
|
5523
5884
|
`LiteLLM quirk: CONFIG_FILE_PATH already set to ${process.env.CONFIG_FILE_PATH}`
|
|
5524
5885
|
);
|
|
5525
5886
|
}
|
|
@@ -5528,11 +5889,11 @@ var litellmQuirk = {
|
|
|
5528
5889
|
};
|
|
5529
5890
|
|
|
5530
5891
|
// src/quirks/prisma.ts
|
|
5531
|
-
var
|
|
5532
|
-
var
|
|
5892
|
+
var import_fs9 = __toESM(require("fs"));
|
|
5893
|
+
var import_path11 = require("path");
|
|
5533
5894
|
var import_execa4 = __toESM(require_execa());
|
|
5534
|
-
var
|
|
5535
|
-
var
|
|
5895
|
+
var import_build_utils11 = require("@vercel/build-utils");
|
|
5896
|
+
var import_python_analysis6 = require("@vercel/python-analysis");
|
|
5536
5897
|
function execErrorMessage(err) {
|
|
5537
5898
|
if (err != null && typeof err === "object" && "stderr" in err) {
|
|
5538
5899
|
const stderr = String(err.stderr);
|
|
@@ -5569,22 +5930,22 @@ model DummyModel {
|
|
|
5569
5930
|
async function findUserSchema(workPath) {
|
|
5570
5931
|
const envPath = process.env.PRISMA_SCHEMA_PATH;
|
|
5571
5932
|
if (envPath) {
|
|
5572
|
-
const resolved = (0,
|
|
5933
|
+
const resolved = (0, import_path11.isAbsolute)(envPath) ? envPath : (0, import_path11.join)(workPath, envPath);
|
|
5573
5934
|
try {
|
|
5574
|
-
await
|
|
5935
|
+
await import_fs9.default.promises.access(resolved);
|
|
5575
5936
|
return resolved;
|
|
5576
5937
|
} catch {
|
|
5577
|
-
(0,
|
|
5938
|
+
(0, import_build_utils11.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
|
|
5578
5939
|
return null;
|
|
5579
5940
|
}
|
|
5580
5941
|
}
|
|
5581
5942
|
const candidates = [
|
|
5582
|
-
(0,
|
|
5583
|
-
(0,
|
|
5943
|
+
(0, import_path11.join)(workPath, "schema.prisma"),
|
|
5944
|
+
(0, import_path11.join)(workPath, "prisma", "schema.prisma")
|
|
5584
5945
|
];
|
|
5585
5946
|
for (const candidate of candidates) {
|
|
5586
5947
|
try {
|
|
5587
|
-
await
|
|
5948
|
+
await import_fs9.default.promises.access(candidate);
|
|
5588
5949
|
return candidate;
|
|
5589
5950
|
} catch {
|
|
5590
5951
|
}
|
|
@@ -5595,32 +5956,32 @@ async function collectFiles(dir, base) {
|
|
|
5595
5956
|
const result = [];
|
|
5596
5957
|
let entries;
|
|
5597
5958
|
try {
|
|
5598
|
-
entries = await
|
|
5959
|
+
entries = await import_fs9.default.promises.readdir(dir, { withFileTypes: true });
|
|
5599
5960
|
} catch {
|
|
5600
5961
|
return result;
|
|
5601
5962
|
}
|
|
5602
5963
|
for (const entry of entries) {
|
|
5603
5964
|
if (entry.name === "__pycache__")
|
|
5604
5965
|
continue;
|
|
5605
|
-
const full = (0,
|
|
5966
|
+
const full = (0, import_path11.join)(dir, entry.name);
|
|
5606
5967
|
if (entry.isDirectory()) {
|
|
5607
5968
|
result.push(...await collectFiles(full, base));
|
|
5608
5969
|
} else {
|
|
5609
|
-
result.push((0,
|
|
5970
|
+
result.push((0, import_path11.relative)(base, full));
|
|
5610
5971
|
}
|
|
5611
5972
|
}
|
|
5612
5973
|
return result;
|
|
5613
5974
|
}
|
|
5614
5975
|
async function cleanCacheArtifacts(cacheDir, extras = []) {
|
|
5615
5976
|
const paths = [
|
|
5616
|
-
(0,
|
|
5617
|
-
(0,
|
|
5618
|
-
(0,
|
|
5977
|
+
(0, import_path11.join)(cacheDir, "node_modules"),
|
|
5978
|
+
(0, import_path11.join)(cacheDir, "package.json"),
|
|
5979
|
+
(0, import_path11.join)(cacheDir, "package-lock.json"),
|
|
5619
5980
|
...extras
|
|
5620
5981
|
];
|
|
5621
5982
|
for (const p of paths) {
|
|
5622
5983
|
try {
|
|
5623
|
-
await
|
|
5984
|
+
await import_fs9.default.promises.rm(p, { recursive: true, force: true });
|
|
5624
5985
|
} catch (err) {
|
|
5625
5986
|
console.warn(
|
|
5626
5987
|
`could not clean up ${p}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -5644,7 +6005,7 @@ var prismaQuirk = {
|
|
|
5644
6005
|
async run(ctx) {
|
|
5645
6006
|
const { venvPath, pythonEnv, workPath } = ctx;
|
|
5646
6007
|
const pythonPath = getVenvPythonBin(venvPath);
|
|
5647
|
-
const runtimeCacheDir = (0,
|
|
6008
|
+
const runtimeCacheDir = (0, import_path11.join)(
|
|
5648
6009
|
LAMBDA_ROOT2,
|
|
5649
6010
|
resolveVendorDir(),
|
|
5650
6011
|
"prisma",
|
|
@@ -5654,7 +6015,7 @@ var prismaQuirk = {
|
|
|
5654
6015
|
let sitePackages;
|
|
5655
6016
|
for (const dir of sitePackagesDirs) {
|
|
5656
6017
|
try {
|
|
5657
|
-
await
|
|
6018
|
+
await import_fs9.default.promises.access((0, import_path11.join)(dir, "prisma"));
|
|
5658
6019
|
sitePackages = dir;
|
|
5659
6020
|
break;
|
|
5660
6021
|
} catch {
|
|
@@ -5666,19 +6027,19 @@ var prismaQuirk = {
|
|
|
5666
6027
|
);
|
|
5667
6028
|
return {};
|
|
5668
6029
|
}
|
|
5669
|
-
const cacheDir = (0,
|
|
5670
|
-
await
|
|
6030
|
+
const cacheDir = (0, import_path11.join)(sitePackages, "prisma", "__bincache__");
|
|
6031
|
+
await import_fs9.default.promises.mkdir(cacheDir, { recursive: true });
|
|
5671
6032
|
const generateEnv = {
|
|
5672
6033
|
...pythonEnv,
|
|
5673
6034
|
PRISMA_BINARY_CACHE_DIR: cacheDir
|
|
5674
6035
|
};
|
|
5675
|
-
const generatedDir = (0,
|
|
5676
|
-
const dummySchemaPath = (0,
|
|
5677
|
-
await
|
|
6036
|
+
const generatedDir = (0, import_path11.join)(workPath, "_prisma_generated");
|
|
6037
|
+
const dummySchemaPath = (0, import_path11.join)(workPath, DUMMY_SCHEMA_NAME);
|
|
6038
|
+
await import_fs9.default.promises.writeFile(
|
|
5678
6039
|
dummySchemaPath,
|
|
5679
6040
|
buildDummySchema(generatedDir)
|
|
5680
6041
|
);
|
|
5681
|
-
(0,
|
|
6042
|
+
(0, import_build_utils11.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
|
|
5682
6043
|
try {
|
|
5683
6044
|
const dummyResult = await (0, import_execa4.default)(
|
|
5684
6045
|
pythonPath,
|
|
@@ -5690,11 +6051,11 @@ var prismaQuirk = {
|
|
|
5690
6051
|
}
|
|
5691
6052
|
);
|
|
5692
6053
|
if (dummyResult.stdout)
|
|
5693
|
-
(0,
|
|
6054
|
+
(0, import_build_utils11.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
|
|
5694
6055
|
if (dummyResult.stderr)
|
|
5695
|
-
(0,
|
|
6056
|
+
(0, import_build_utils11.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
|
|
5696
6057
|
} catch (err) {
|
|
5697
|
-
throw new
|
|
6058
|
+
throw new import_build_utils11.NowBuildError({
|
|
5698
6059
|
code: "PRISMA_GENERATE_FAILED",
|
|
5699
6060
|
message: `Prisma engine download failed during \`prisma generate\`. Check that your prisma version is compatible with this Python version.
|
|
5700
6061
|
` + execErrorMessage(err)
|
|
@@ -5702,47 +6063,47 @@ var prismaQuirk = {
|
|
|
5702
6063
|
}
|
|
5703
6064
|
const srcBinaryPrefix = `query-engine-${getLambdaBinaryTarget()}`;
|
|
5704
6065
|
const runtimeName = `prisma-query-engine-rhel-openssl-${RUNTIME_OPENSSL_VERSION}.x`;
|
|
5705
|
-
const nodeModulesDir = (0,
|
|
6066
|
+
const nodeModulesDir = (0, import_path11.join)(cacheDir, "node_modules", "prisma");
|
|
5706
6067
|
let engineCopied = false;
|
|
5707
6068
|
try {
|
|
5708
|
-
const entries = await
|
|
6069
|
+
const entries = await import_fs9.default.promises.readdir(nodeModulesDir);
|
|
5709
6070
|
for (const entry of entries) {
|
|
5710
6071
|
if (!entry.startsWith(srcBinaryPrefix))
|
|
5711
6072
|
continue;
|
|
5712
|
-
const srcPath = (0,
|
|
5713
|
-
const destPath = (0,
|
|
6073
|
+
const srcPath = (0, import_path11.join)(nodeModulesDir, entry);
|
|
6074
|
+
const destPath = (0, import_path11.join)(cacheDir, runtimeName);
|
|
5714
6075
|
try {
|
|
5715
|
-
await
|
|
5716
|
-
(0,
|
|
6076
|
+
await import_fs9.default.promises.access(destPath);
|
|
6077
|
+
(0, import_build_utils11.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
|
|
5717
6078
|
} catch {
|
|
5718
|
-
(0,
|
|
5719
|
-
await
|
|
6079
|
+
(0, import_build_utils11.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
|
|
6080
|
+
await import_fs9.default.promises.copyFile(srcPath, destPath);
|
|
5720
6081
|
}
|
|
5721
6082
|
engineCopied = true;
|
|
5722
6083
|
}
|
|
5723
6084
|
} catch (err) {
|
|
5724
|
-
throw new
|
|
6085
|
+
throw new import_build_utils11.NowBuildError({
|
|
5725
6086
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
5726
6087
|
message: `could not read Prisma engine directory "${nodeModulesDir}". This may indicate an incompatible prisma version.
|
|
5727
6088
|
` + (err instanceof Error ? err.message : String(err))
|
|
5728
6089
|
});
|
|
5729
6090
|
}
|
|
5730
6091
|
if (!engineCopied) {
|
|
5731
|
-
throw new
|
|
6092
|
+
throw new import_build_utils11.NowBuildError({
|
|
5732
6093
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
5733
6094
|
message: `could not find engine binary matching "${srcBinaryPrefix}*" in "${nodeModulesDir}". This may indicate an incompatible prisma version or an unsupported platform (${process.arch}).`
|
|
5734
6095
|
});
|
|
5735
6096
|
}
|
|
5736
|
-
const shimPath = (0,
|
|
5737
|
-
await
|
|
6097
|
+
const shimPath = (0, import_path11.join)(cacheDir, "openssl");
|
|
6098
|
+
await import_fs9.default.promises.writeFile(
|
|
5738
6099
|
shimPath,
|
|
5739
6100
|
`#!/bin/sh
|
|
5740
6101
|
echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIME_OPENSSL_VERSION}.0)"
|
|
5741
6102
|
`
|
|
5742
6103
|
);
|
|
5743
|
-
await
|
|
6104
|
+
await import_fs9.default.promises.chmod(shimPath, 493);
|
|
5744
6105
|
for (const p of [generatedDir, dummySchemaPath]) {
|
|
5745
|
-
await
|
|
6106
|
+
await import_fs9.default.promises.rm(p, { recursive: true, force: true });
|
|
5746
6107
|
}
|
|
5747
6108
|
await cleanCacheArtifacts(cacheDir);
|
|
5748
6109
|
const generateMode = (process.env.VERCEL_PRISMA_GENERATE_CLIENT ?? "auto").toLowerCase();
|
|
@@ -5755,14 +6116,14 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5755
6116
|
pythonEnv
|
|
5756
6117
|
);
|
|
5757
6118
|
if (clientAlreadyGenerated) {
|
|
5758
|
-
(0,
|
|
6119
|
+
(0, import_build_utils11.debug)(
|
|
5759
6120
|
"Prisma quirk: client already generated, skipping user schema generate"
|
|
5760
6121
|
);
|
|
5761
6122
|
shouldGenerate = false;
|
|
5762
6123
|
}
|
|
5763
6124
|
}
|
|
5764
6125
|
if (shouldGenerate) {
|
|
5765
|
-
(0,
|
|
6126
|
+
(0, import_build_utils11.debug)(`Running prisma generate with user schema: ${userSchema}`);
|
|
5766
6127
|
try {
|
|
5767
6128
|
const userResult = await (0, import_execa4.default)(
|
|
5768
6129
|
pythonPath,
|
|
@@ -5774,11 +6135,11 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5774
6135
|
}
|
|
5775
6136
|
);
|
|
5776
6137
|
if (userResult.stdout)
|
|
5777
|
-
(0,
|
|
6138
|
+
(0, import_build_utils11.debug)(`prisma generate stdout: ${userResult.stdout}`);
|
|
5778
6139
|
if (userResult.stderr)
|
|
5779
|
-
(0,
|
|
6140
|
+
(0, import_build_utils11.debug)(`prisma generate stderr: ${userResult.stderr}`);
|
|
5780
6141
|
} catch (err) {
|
|
5781
|
-
throw new
|
|
6142
|
+
throw new import_build_utils11.NowBuildError({
|
|
5782
6143
|
code: "PRISMA_GENERATE_FAILED",
|
|
5783
6144
|
message: `\`prisma generate\` failed for schema "${userSchema}".
|
|
5784
6145
|
` + execErrorMessage(err)
|
|
@@ -5789,12 +6150,12 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
5789
6150
|
}
|
|
5790
6151
|
try {
|
|
5791
6152
|
const allFiles = await collectFiles(
|
|
5792
|
-
(0,
|
|
6153
|
+
(0, import_path11.join)(sitePackages, "prisma"),
|
|
5793
6154
|
sitePackages
|
|
5794
6155
|
);
|
|
5795
|
-
const count = await (0,
|
|
6156
|
+
const count = await (0, import_python_analysis6.extendDistRecord)(sitePackages, "prisma", allFiles);
|
|
5796
6157
|
if (count > 0) {
|
|
5797
|
-
(0,
|
|
6158
|
+
(0, import_build_utils11.debug)(`Appended ${count} entries to prisma RECORD`);
|
|
5798
6159
|
}
|
|
5799
6160
|
} catch (err) {
|
|
5800
6161
|
console.warn(
|
|
@@ -5817,7 +6178,7 @@ var quirks = [litellmQuirk, prismaQuirk, matplotlibQuirk];
|
|
|
5817
6178
|
function toposortQuirks(activated) {
|
|
5818
6179
|
const nameToQuirk = /* @__PURE__ */ new Map();
|
|
5819
6180
|
for (const q of activated) {
|
|
5820
|
-
nameToQuirk.set((0,
|
|
6181
|
+
nameToQuirk.set((0, import_python_analysis7.normalizePackageName)(q.dependency), q);
|
|
5821
6182
|
}
|
|
5822
6183
|
const adj = /* @__PURE__ */ new Map();
|
|
5823
6184
|
const inDegree = /* @__PURE__ */ new Map();
|
|
@@ -5828,7 +6189,7 @@ function toposortQuirks(activated) {
|
|
|
5828
6189
|
for (const q of activated) {
|
|
5829
6190
|
if (q.runsBefore) {
|
|
5830
6191
|
for (const dep of q.runsBefore) {
|
|
5831
|
-
const target = nameToQuirk.get((0,
|
|
6192
|
+
const target = nameToQuirk.get((0, import_python_analysis7.normalizePackageName)(dep));
|
|
5832
6193
|
if (target) {
|
|
5833
6194
|
adj.get(q).add(target);
|
|
5834
6195
|
inDegree.set(target, inDegree.get(target) + 1);
|
|
@@ -5837,7 +6198,7 @@ function toposortQuirks(activated) {
|
|
|
5837
6198
|
}
|
|
5838
6199
|
if (q.runsAfter) {
|
|
5839
6200
|
for (const dep of q.runsAfter) {
|
|
5840
|
-
const source = nameToQuirk.get((0,
|
|
6201
|
+
const source = nameToQuirk.get((0, import_python_analysis7.normalizePackageName)(dep));
|
|
5841
6202
|
if (source) {
|
|
5842
6203
|
adj.get(source).add(q);
|
|
5843
6204
|
inDegree.set(q, inDegree.get(q) + 1);
|
|
@@ -5878,23 +6239,23 @@ async function runQuirks(ctx) {
|
|
|
5878
6239
|
const installedNames = /* @__PURE__ */ new Set();
|
|
5879
6240
|
const sitePackageDirs = await getVenvSitePackagesDirs(ctx.venvPath);
|
|
5880
6241
|
for (const dir of sitePackageDirs) {
|
|
5881
|
-
const distributions = await (0,
|
|
6242
|
+
const distributions = await (0, import_python_analysis7.scanDistributions)(dir);
|
|
5882
6243
|
for (const name of distributions.keys()) {
|
|
5883
|
-
installedNames.add((0,
|
|
6244
|
+
installedNames.add((0, import_python_analysis7.normalizePackageName)(name));
|
|
5884
6245
|
}
|
|
5885
6246
|
}
|
|
5886
6247
|
const activated = quirks.filter((quirk) => {
|
|
5887
6248
|
const installed = installedNames.has(
|
|
5888
|
-
(0,
|
|
6249
|
+
(0, import_python_analysis7.normalizePackageName)(quirk.dependency)
|
|
5889
6250
|
);
|
|
5890
6251
|
if (!installed) {
|
|
5891
|
-
(0,
|
|
6252
|
+
(0, import_build_utils12.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
|
|
5892
6253
|
}
|
|
5893
6254
|
return installed;
|
|
5894
6255
|
});
|
|
5895
6256
|
const sorted = toposortQuirks(activated);
|
|
5896
6257
|
for (const quirk of sorted) {
|
|
5897
|
-
(0,
|
|
6258
|
+
(0, import_build_utils12.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
|
|
5898
6259
|
const result = await quirk.run(ctx);
|
|
5899
6260
|
if (result.env) {
|
|
5900
6261
|
Object.assign(mergedEnv, result.env);
|
|
@@ -5915,12 +6276,12 @@ async function runQuirks(ctx) {
|
|
|
5915
6276
|
}
|
|
5916
6277
|
|
|
5917
6278
|
// src/django.ts
|
|
5918
|
-
var
|
|
5919
|
-
var
|
|
6279
|
+
var import_fs10 = __toESM(require("fs"));
|
|
6280
|
+
var import_path12 = require("path");
|
|
5920
6281
|
var import_execa5 = __toESM(require_execa());
|
|
5921
|
-
var
|
|
5922
|
-
var scriptPath = (0,
|
|
5923
|
-
var script =
|
|
6282
|
+
var import_build_utils13 = require("@vercel/build-utils");
|
|
6283
|
+
var scriptPath = (0, import_path12.join)(__dirname, "..", "templates", "vc_django_settings.py");
|
|
6284
|
+
var script = import_fs10.default.readFileSync(scriptPath, "utf-8");
|
|
5924
6285
|
async function getDjangoSettings(projectDir, env) {
|
|
5925
6286
|
try {
|
|
5926
6287
|
const { stdout } = await (0, import_execa5.default)("python", ["-c", script], {
|
|
@@ -5935,7 +6296,7 @@ async function getDjangoSettings(projectDir, env) {
|
|
|
5935
6296
|
djangoSettings: parsed.django_settings
|
|
5936
6297
|
};
|
|
5937
6298
|
} catch (err) {
|
|
5938
|
-
(0,
|
|
6299
|
+
(0, import_build_utils13.debug)(`Django hook: failed to discover settings from manage.py: ${err}`);
|
|
5939
6300
|
return null;
|
|
5940
6301
|
}
|
|
5941
6302
|
}
|
|
@@ -5949,10 +6310,10 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5949
6310
|
const installedApps = djangoSettings["INSTALLED_APPS"] ?? [];
|
|
5950
6311
|
const staticfilesDirs = djangoSettings["STATICFILES_DIRS"] ?? [];
|
|
5951
6312
|
const staticSourceDirs = [
|
|
5952
|
-
...installedApps.map((app) => (0,
|
|
6313
|
+
...installedApps.map((app) => (0, import_path12.join)(workPath, ...app.split("."), "static")),
|
|
5953
6314
|
// TODO: Deal with optional prefixes in STATICFILES_DIRS.
|
|
5954
6315
|
...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
|
|
5955
|
-
].filter((d) =>
|
|
6316
|
+
].filter((d) => import_fs10.default.existsSync(d));
|
|
5956
6317
|
if (storageBackend.startsWith("storages.backends.")) {
|
|
5957
6318
|
console.log(
|
|
5958
6319
|
"django-storages detected \u2014 running collectstatic with original settings"
|
|
@@ -5963,7 +6324,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5963
6324
|
});
|
|
5964
6325
|
return {
|
|
5965
6326
|
staticSourceDirs,
|
|
5966
|
-
staticRoot: staticRoot ? (0,
|
|
6327
|
+
staticRoot: staticRoot ? (0, import_path12.resolve)(workPath, staticRoot) : null,
|
|
5967
6328
|
manifestRelPath: null
|
|
5968
6329
|
};
|
|
5969
6330
|
}
|
|
@@ -5974,9 +6335,9 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5974
6335
|
return null;
|
|
5975
6336
|
}
|
|
5976
6337
|
const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
|
|
5977
|
-
const staticOutputDir = (0,
|
|
5978
|
-
await
|
|
5979
|
-
const shimPath = (0,
|
|
6338
|
+
const staticOutputDir = (0, import_path12.join)(outputStaticDir, staticUrlPath);
|
|
6339
|
+
await import_fs10.default.promises.mkdir(staticOutputDir, { recursive: true });
|
|
6340
|
+
const shimPath = (0, import_path12.join)(workPath, "_vercel_collectstatic_settings.py");
|
|
5980
6341
|
const shimLines = [
|
|
5981
6342
|
`from ${settingsModule} import *`,
|
|
5982
6343
|
`STATIC_ROOT = ${JSON.stringify(staticOutputDir)}`
|
|
@@ -5984,7 +6345,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5984
6345
|
if (whitenoiseUseFinders) {
|
|
5985
6346
|
shimLines.push(`WHITENOISE_USE_FINDERS = False`);
|
|
5986
6347
|
}
|
|
5987
|
-
await
|
|
6348
|
+
await import_fs10.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
|
|
5988
6349
|
try {
|
|
5989
6350
|
console.log("Running collectstatic...");
|
|
5990
6351
|
await (0, import_execa5.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
|
|
@@ -5995,7 +6356,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
5995
6356
|
cwd: workPath
|
|
5996
6357
|
});
|
|
5997
6358
|
} finally {
|
|
5998
|
-
await
|
|
6359
|
+
await import_fs10.default.promises.unlink(shimPath).catch(() => {
|
|
5999
6360
|
});
|
|
6000
6361
|
}
|
|
6001
6362
|
const MANIFEST_STORAGE_BACKENDS = [
|
|
@@ -6004,24 +6365,24 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
6004
6365
|
];
|
|
6005
6366
|
let manifestRelPath = null;
|
|
6006
6367
|
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,
|
|
6368
|
+
const manifestSrc = (0, import_path12.join)(staticOutputDir, "staticfiles.json");
|
|
6369
|
+
const resolvedStaticRoot = (0, import_path12.resolve)(workPath, staticRoot);
|
|
6370
|
+
const manifestDest = (0, import_path12.join)(resolvedStaticRoot, "staticfiles.json");
|
|
6371
|
+
await import_fs10.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
|
|
6372
|
+
await import_fs10.default.promises.copyFile(manifestSrc, manifestDest);
|
|
6373
|
+
manifestRelPath = (0, import_path12.relative)(workPath, manifestDest);
|
|
6374
|
+
(0, import_build_utils13.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
|
|
6014
6375
|
}
|
|
6015
6376
|
return {
|
|
6016
6377
|
staticSourceDirs,
|
|
6017
|
-
staticRoot: staticRoot ? (0,
|
|
6378
|
+
staticRoot: staticRoot ? (0, import_path12.resolve)(workPath, staticRoot) : null,
|
|
6018
6379
|
manifestRelPath
|
|
6019
6380
|
};
|
|
6020
6381
|
}
|
|
6021
6382
|
|
|
6022
6383
|
// src/index.ts
|
|
6023
|
-
var
|
|
6024
|
-
var writeFile =
|
|
6384
|
+
var import_python_analysis8 = require("@vercel/python-analysis");
|
|
6385
|
+
var writeFile = import_fs11.default.promises.writeFile;
|
|
6025
6386
|
var version = 3;
|
|
6026
6387
|
async function runFrameworkHook(framework, ctx) {
|
|
6027
6388
|
const hook = framework ? frameworkHooks[framework] : void 0;
|
|
@@ -6036,32 +6397,41 @@ var frameworkHooks = {
|
|
|
6036
6397
|
detected
|
|
6037
6398
|
}) => {
|
|
6038
6399
|
if (detected?.baseDir === void 0) {
|
|
6039
|
-
(0,
|
|
6400
|
+
(0, import_build_utils14.debug)("Django hook: no manage.py detected, skipping");
|
|
6040
6401
|
return;
|
|
6041
6402
|
}
|
|
6042
6403
|
const settingsResult = await getDjangoSettings(projectDir, pythonEnv);
|
|
6043
|
-
(0,
|
|
6404
|
+
(0, import_build_utils14.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
6044
6405
|
if (!settingsResult)
|
|
6045
6406
|
return;
|
|
6046
6407
|
const { djangoSettings, settingsModule } = settingsResult;
|
|
6047
6408
|
let entrypoint;
|
|
6409
|
+
let variableName;
|
|
6048
6410
|
const baseDir = detected?.baseDir ?? "";
|
|
6049
6411
|
const asgiApp = djangoSettings["ASGI_APPLICATION"];
|
|
6050
6412
|
if (typeof asgiApp === "string") {
|
|
6051
|
-
const
|
|
6413
|
+
const parts = asgiApp.split(".");
|
|
6414
|
+
variableName = parts.at(-1);
|
|
6415
|
+
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
6052
6416
|
entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
|
|
6053
|
-
(0,
|
|
6417
|
+
(0, import_build_utils14.debug)(
|
|
6418
|
+
`Django hook: ASGI entrypoint: ${entrypoint} (variable: ${variableName})`
|
|
6419
|
+
);
|
|
6054
6420
|
} else {
|
|
6055
6421
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
6056
6422
|
if (typeof wsgiApp === "string") {
|
|
6057
|
-
const
|
|
6423
|
+
const parts = wsgiApp.split(".");
|
|
6424
|
+
variableName = parts.at(-1);
|
|
6425
|
+
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
6058
6426
|
entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
|
|
6059
|
-
(0,
|
|
6427
|
+
(0, import_build_utils14.debug)(
|
|
6428
|
+
`Django hook: WSGI entrypoint: ${entrypoint} (variable: ${variableName})`
|
|
6429
|
+
);
|
|
6060
6430
|
}
|
|
6061
6431
|
}
|
|
6062
6432
|
let djangoStatic = null;
|
|
6063
|
-
if (venvPath) {
|
|
6064
|
-
const outputStaticDir = (0,
|
|
6433
|
+
if (workPath && venvPath) {
|
|
6434
|
+
const outputStaticDir = (0, import_path13.join)(workPath, ".vercel", "output", "static");
|
|
6065
6435
|
djangoStatic = await runDjangoCollectStatic(
|
|
6066
6436
|
venvPath,
|
|
6067
6437
|
workPath,
|
|
@@ -6071,7 +6441,7 @@ var frameworkHooks = {
|
|
|
6071
6441
|
djangoSettings
|
|
6072
6442
|
);
|
|
6073
6443
|
}
|
|
6074
|
-
return { entrypoint, djangoStatic };
|
|
6444
|
+
return { entrypoint, variableName, djangoStatic };
|
|
6075
6445
|
}
|
|
6076
6446
|
};
|
|
6077
6447
|
async function downloadFilesInWorkPath({
|
|
@@ -6080,13 +6450,13 @@ async function downloadFilesInWorkPath({
|
|
|
6080
6450
|
files,
|
|
6081
6451
|
meta = {}
|
|
6082
6452
|
}) {
|
|
6083
|
-
(0,
|
|
6084
|
-
let downloadedFiles = await (0,
|
|
6453
|
+
(0, import_build_utils14.debug)("Downloading user files...");
|
|
6454
|
+
let downloadedFiles = await (0, import_build_utils14.download)(files, workPath, meta);
|
|
6085
6455
|
if (meta.isDev) {
|
|
6086
|
-
const { devCacheDir = (0,
|
|
6087
|
-
const destCache = (0,
|
|
6088
|
-
await (0,
|
|
6089
|
-
downloadedFiles = await (0,
|
|
6456
|
+
const { devCacheDir = (0, import_path13.join)(workPath, ".now", "cache") } = meta;
|
|
6457
|
+
const destCache = (0, import_path13.join)(devCacheDir, (0, import_path13.basename)(entrypoint, ".py"));
|
|
6458
|
+
await (0, import_build_utils14.download)(downloadedFiles, destCache);
|
|
6459
|
+
downloadedFiles = await (0, import_build_utils14.glob)("**", destCache);
|
|
6090
6460
|
workPath = destCache;
|
|
6091
6461
|
}
|
|
6092
6462
|
return workPath;
|
|
@@ -6098,15 +6468,16 @@ var build = async ({
|
|
|
6098
6468
|
entrypoint,
|
|
6099
6469
|
meta = {},
|
|
6100
6470
|
config,
|
|
6101
|
-
span: parentSpan
|
|
6471
|
+
span: parentSpan,
|
|
6472
|
+
service
|
|
6102
6473
|
}) => {
|
|
6103
|
-
const builderSpan = parentSpan ?? new
|
|
6474
|
+
const builderSpan = parentSpan ?? new import_build_utils14.Span({ name: "vc.builder" });
|
|
6104
6475
|
const framework = config?.framework;
|
|
6105
6476
|
const shouldInstallVercelWorkers = config?.hasWorkerServices === true;
|
|
6106
6477
|
let spawnEnv;
|
|
6107
6478
|
let projectInstallCommand;
|
|
6108
6479
|
let hasCustomCommand = false;
|
|
6109
|
-
(0,
|
|
6480
|
+
(0, import_build_utils14.debug)(`workPath: ${workPath}`);
|
|
6110
6481
|
workPath = await downloadFilesInWorkPath({
|
|
6111
6482
|
workPath,
|
|
6112
6483
|
files: originalFiles,
|
|
@@ -6115,17 +6486,17 @@ var build = async ({
|
|
|
6115
6486
|
});
|
|
6116
6487
|
try {
|
|
6117
6488
|
if (meta.isDev) {
|
|
6118
|
-
const setupCfg = (0,
|
|
6489
|
+
const setupCfg = (0, import_path13.join)(workPath, "setup.cfg");
|
|
6119
6490
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
6120
6491
|
}
|
|
6121
6492
|
} catch (err) {
|
|
6122
6493
|
console.log('Failed to create "setup.cfg" file');
|
|
6123
6494
|
throw err;
|
|
6124
6495
|
}
|
|
6125
|
-
let fsFiles = await (0,
|
|
6496
|
+
let fsFiles = await (0, import_build_utils14.glob)("**", workPath);
|
|
6126
6497
|
let detected;
|
|
6127
6498
|
let entrypointNotFound;
|
|
6128
|
-
if ((0,
|
|
6499
|
+
if ((0, import_build_utils14.isPythonFramework)(framework) && // XXX: we might want to detect anyway for django!
|
|
6129
6500
|
(!fsFiles[entrypoint] || !entrypoint.endsWith(".py"))) {
|
|
6130
6501
|
detected = await detectPythonEntrypoint(
|
|
6131
6502
|
config.framework,
|
|
@@ -6133,13 +6504,13 @@ var build = async ({
|
|
|
6133
6504
|
entrypoint
|
|
6134
6505
|
) ?? void 0;
|
|
6135
6506
|
if (detected?.entrypoint) {
|
|
6136
|
-
(0,
|
|
6507
|
+
(0, import_build_utils14.debug)(
|
|
6137
6508
|
`Resolved Python entrypoint to "${detected.entrypoint}" (configured "${entrypoint}" not found).`
|
|
6138
6509
|
);
|
|
6139
6510
|
entrypoint = detected.entrypoint;
|
|
6140
6511
|
} else {
|
|
6141
6512
|
const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
6142
|
-
entrypointNotFound = new
|
|
6513
|
+
entrypointNotFound = new import_build_utils14.NowBuildError({
|
|
6143
6514
|
code: `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`,
|
|
6144
6515
|
message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searchedList}.`,
|
|
6145
6516
|
link: `https://vercel.com/docs/frameworks/backend/${framework}#exporting-the-${framework}-application`,
|
|
@@ -6150,8 +6521,8 @@ var build = async ({
|
|
|
6150
6521
|
if (entrypointNotFound && detected?.baseDir === void 0) {
|
|
6151
6522
|
throw entrypointNotFound;
|
|
6152
6523
|
}
|
|
6153
|
-
const entryDirectory = detected?.baseDir ?? (0,
|
|
6154
|
-
const entrypointAbsDir = (0,
|
|
6524
|
+
const entryDirectory = detected?.baseDir ?? (0, import_path13.dirname)(entrypoint);
|
|
6525
|
+
const entrypointAbsDir = (0, import_path13.join)(workPath, entryDirectory);
|
|
6155
6526
|
const rootDir = repoRootPath ?? workPath;
|
|
6156
6527
|
const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
|
|
6157
6528
|
() => discoverPackage({
|
|
@@ -6181,22 +6552,22 @@ var build = async ({
|
|
|
6181
6552
|
`
|
|
6182
6553
|
);
|
|
6183
6554
|
}
|
|
6184
|
-
fsFiles = await (0,
|
|
6185
|
-
const venvPath = (0,
|
|
6555
|
+
fsFiles = await (0, import_build_utils14.glob)("**", workPath);
|
|
6556
|
+
const venvPath = service?.name ? (0, import_path13.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path13.join)(workPath, ".vercel", "python", ".venv");
|
|
6186
6557
|
await builderSpan.child("vc.builder.python.venv").trace(async () => {
|
|
6187
6558
|
await ensureVenv({
|
|
6188
6559
|
pythonPath: pythonVersion.pythonPath,
|
|
6189
6560
|
venvPath
|
|
6190
6561
|
});
|
|
6191
6562
|
});
|
|
6192
|
-
if ((0,
|
|
6563
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6193
6564
|
const {
|
|
6194
6565
|
cliType,
|
|
6195
6566
|
lockfileVersion,
|
|
6196
6567
|
packageJsonPackageManager,
|
|
6197
6568
|
turboSupportsCorepackHome
|
|
6198
|
-
} = await (0,
|
|
6199
|
-
spawnEnv = (0,
|
|
6569
|
+
} = await (0, import_build_utils14.scanParentDirs)(workPath, true);
|
|
6570
|
+
spawnEnv = (0, import_build_utils14.getEnvForPackageManager)({
|
|
6200
6571
|
cliType,
|
|
6201
6572
|
lockfileVersion,
|
|
6202
6573
|
packageJsonPackageManager,
|
|
@@ -6232,14 +6603,14 @@ var build = async ({
|
|
|
6232
6603
|
let uvLockPath = null;
|
|
6233
6604
|
let uvProjectDir = null;
|
|
6234
6605
|
let projectName;
|
|
6235
|
-
await builderSpan.child(
|
|
6606
|
+
await builderSpan.child(import_build_utils14.BUILDER_INSTALLER_STEP, {
|
|
6236
6607
|
installCommand: projectInstallCommand || void 0
|
|
6237
6608
|
}).trace(async () => {
|
|
6238
6609
|
if (projectInstallCommand) {
|
|
6239
6610
|
console.log(
|
|
6240
6611
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
6241
6612
|
);
|
|
6242
|
-
await (0,
|
|
6613
|
+
await (0, import_build_utils14.execCommand)(projectInstallCommand, {
|
|
6243
6614
|
env: pythonEnv,
|
|
6244
6615
|
cwd: workPath
|
|
6245
6616
|
});
|
|
@@ -6261,6 +6632,7 @@ var build = async ({
|
|
|
6261
6632
|
const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
|
|
6262
6633
|
workPath,
|
|
6263
6634
|
rootDir,
|
|
6635
|
+
venvPath,
|
|
6264
6636
|
pythonPackage,
|
|
6265
6637
|
pythonVersion: pythonVersionString(pythonVersion),
|
|
6266
6638
|
uv,
|
|
@@ -6278,15 +6650,15 @@ var build = async ({
|
|
|
6278
6650
|
});
|
|
6279
6651
|
}
|
|
6280
6652
|
});
|
|
6281
|
-
if ((0,
|
|
6653
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6282
6654
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
6283
6655
|
config?.buildCommand;
|
|
6284
|
-
await builderSpan.child(
|
|
6656
|
+
await builderSpan.child(import_build_utils14.BUILDER_COMPILE_STEP, {
|
|
6285
6657
|
buildCommand: projectBuildCommand || void 0
|
|
6286
6658
|
}).trace(async () => {
|
|
6287
6659
|
if (projectBuildCommand) {
|
|
6288
6660
|
console.log(`Running "${projectBuildCommand}"`);
|
|
6289
|
-
await (0,
|
|
6661
|
+
await (0, import_build_utils14.execCommand)(projectBuildCommand, {
|
|
6290
6662
|
env: pythonEnv,
|
|
6291
6663
|
cwd: workPath
|
|
6292
6664
|
});
|
|
@@ -6301,7 +6673,7 @@ var build = async ({
|
|
|
6301
6673
|
}
|
|
6302
6674
|
const hookResult = await runFrameworkHook(framework, {
|
|
6303
6675
|
pythonEnv,
|
|
6304
|
-
projectDir: (0,
|
|
6676
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6305
6677
|
workPath,
|
|
6306
6678
|
venvPath,
|
|
6307
6679
|
entrypoint,
|
|
@@ -6316,18 +6688,18 @@ var build = async ({
|
|
|
6316
6688
|
}
|
|
6317
6689
|
const djangoStatic = hookResult?.djangoStatic ?? null;
|
|
6318
6690
|
const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
|
|
6319
|
-
(0,
|
|
6691
|
+
(0, import_build_utils14.debug)(`Installing ${runtimeDep}`);
|
|
6320
6692
|
await uv.pip({
|
|
6321
6693
|
venvPath,
|
|
6322
|
-
projectDir: (0,
|
|
6694
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6323
6695
|
args: ["install", runtimeDep]
|
|
6324
6696
|
});
|
|
6325
6697
|
if (shouldInstallVercelWorkers) {
|
|
6326
6698
|
const workersDep = baseEnv.VERCEL_WORKERS_PYTHON || `vercel-workers==${VERCEL_WORKERS_VERSION}`;
|
|
6327
|
-
(0,
|
|
6699
|
+
(0, import_build_utils14.debug)(`Installing ${workersDep}`);
|
|
6328
6700
|
await uv.pip({
|
|
6329
6701
|
venvPath,
|
|
6330
|
-
projectDir: (0,
|
|
6702
|
+
projectDir: (0, import_path13.join)(workPath, entryDirectory),
|
|
6331
6703
|
args: ["install", workersDep]
|
|
6332
6704
|
});
|
|
6333
6705
|
}
|
|
@@ -6335,15 +6707,15 @@ var build = async ({
|
|
|
6335
6707
|
if (quirksResult.buildEnv) {
|
|
6336
6708
|
Object.assign(pythonEnv, quirksResult.buildEnv);
|
|
6337
6709
|
}
|
|
6338
|
-
(0,
|
|
6710
|
+
(0, import_build_utils14.debug)("Entrypoint is", entrypoint);
|
|
6339
6711
|
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
|
|
6340
6712
|
const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
|
|
6341
6713
|
if (handlerFunction) {
|
|
6342
|
-
const entrypointPath = (0,
|
|
6343
|
-
const source = await
|
|
6344
|
-
const found = await (0,
|
|
6714
|
+
const entrypointPath = (0, import_path13.join)(workPath, entrypoint);
|
|
6715
|
+
const source = await import_fs11.default.promises.readFile(entrypointPath, "utf-8");
|
|
6716
|
+
const found = await (0, import_python_analysis8.containsTopLevelCallable)(source, handlerFunction);
|
|
6345
6717
|
if (!found) {
|
|
6346
|
-
throw new
|
|
6718
|
+
throw new import_build_utils14.NowBuildError({
|
|
6347
6719
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
6348
6720
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
6349
6721
|
});
|
|
@@ -6352,9 +6724,10 @@ var build = async ({
|
|
|
6352
6724
|
const vendorDir = resolveVendorDir();
|
|
6353
6725
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
6354
6726
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
6355
|
-
(0,
|
|
6727
|
+
(0, import_build_utils14.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
6356
6728
|
const handlerFuncEnvLine = handlerFunction ? `
|
|
6357
6729
|
"__VC_HANDLER_FUNC_NAME": "${handlerFunction}",` : "";
|
|
6730
|
+
const variableName = hookResult?.variableName ?? detected?.variableName ?? "";
|
|
6358
6731
|
const runtimeTrampoline = `
|
|
6359
6732
|
import importlib
|
|
6360
6733
|
import os
|
|
@@ -6368,7 +6741,8 @@ os.environ.update({
|
|
|
6368
6741
|
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
6369
6742
|
"__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
|
|
6370
6743
|
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
|
|
6371
|
-
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}"
|
|
6744
|
+
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
6745
|
+
"__VC_HANDLER_VARIABLE_NAME": "${variableName}",${handlerFuncEnvLine}
|
|
6372
6746
|
})
|
|
6373
6747
|
|
|
6374
6748
|
_vendor_rel = '${vendorDir}'
|
|
@@ -6417,7 +6791,7 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6417
6791
|
...djangoStatic.staticRoot ? [djangoStatic.staticRoot] : []
|
|
6418
6792
|
];
|
|
6419
6793
|
for (const absDir of dirsToExclude) {
|
|
6420
|
-
const rel = (0,
|
|
6794
|
+
const rel = (0, import_path13.relative)(workPath, absDir);
|
|
6421
6795
|
if (!rel.startsWith("..")) {
|
|
6422
6796
|
predefinedExcludes.push(`${rel}/**`);
|
|
6423
6797
|
}
|
|
@@ -6426,14 +6800,17 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6426
6800
|
const lambdaEnv = {};
|
|
6427
6801
|
lambdaEnv.PYTHONPATH = vendorDir;
|
|
6428
6802
|
Object.assign(lambdaEnv, quirksResult.env);
|
|
6803
|
+
if (shouldInstallVercelWorkers) {
|
|
6804
|
+
lambdaEnv.VERCEL_HAS_WORKER_SERVICES = "1";
|
|
6805
|
+
}
|
|
6429
6806
|
const globOptions = {
|
|
6430
6807
|
cwd: workPath,
|
|
6431
6808
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
6432
6809
|
};
|
|
6433
|
-
const files = await (0,
|
|
6810
|
+
const files = await (0, import_build_utils14.glob)("**", globOptions);
|
|
6434
6811
|
if (djangoStatic?.manifestRelPath) {
|
|
6435
|
-
files[djangoStatic.manifestRelPath] = new
|
|
6436
|
-
fsPath: (0,
|
|
6812
|
+
files[djangoStatic.manifestRelPath] = new import_build_utils14.FileFsRef({
|
|
6813
|
+
fsPath: (0, import_path13.join)(workPath, djangoStatic.manifestRelPath)
|
|
6437
6814
|
});
|
|
6438
6815
|
}
|
|
6439
6816
|
const depExternalizer = new PythonDependencyExternalizer({
|
|
@@ -6469,23 +6846,37 @@ from vercel_runtime.vc_init import vc_handler
|
|
|
6469
6846
|
}
|
|
6470
6847
|
});
|
|
6471
6848
|
const handlerPyFilename = "vc__handler__python";
|
|
6472
|
-
files[`${handlerPyFilename}.py`] = new
|
|
6849
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils14.FileBlob({ data: runtimeTrampoline });
|
|
6473
6850
|
if (config.framework === "fasthtml") {
|
|
6474
6851
|
const { SESSKEY = "" } = process.env;
|
|
6475
|
-
files[".sesskey"] = new
|
|
6852
|
+
files[".sesskey"] = new import_build_utils14.FileBlob({ data: `"${SESSKEY}"` });
|
|
6476
6853
|
}
|
|
6477
|
-
const output = new
|
|
6854
|
+
const output = new import_build_utils14.Lambda({
|
|
6478
6855
|
files,
|
|
6479
6856
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
6480
6857
|
runtime: pythonVersion.runtime,
|
|
6481
6858
|
environment: lambdaEnv,
|
|
6482
6859
|
supportsResponseStreaming: true
|
|
6483
6860
|
});
|
|
6861
|
+
if (uvLockPath) {
|
|
6862
|
+
try {
|
|
6863
|
+
await generateProjectManifest({
|
|
6864
|
+
workPath,
|
|
6865
|
+
pythonPackage,
|
|
6866
|
+
pythonVersion,
|
|
6867
|
+
uvLockPath
|
|
6868
|
+
});
|
|
6869
|
+
} catch (err) {
|
|
6870
|
+
(0, import_build_utils14.debug)(
|
|
6871
|
+
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
6872
|
+
);
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6484
6875
|
return { output };
|
|
6485
6876
|
};
|
|
6486
6877
|
var shouldServe = (opts) => {
|
|
6487
6878
|
const framework = opts.config.framework;
|
|
6488
|
-
if ((0,
|
|
6879
|
+
if ((0, import_build_utils14.isPythonFramework)(framework)) {
|
|
6489
6880
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
6490
6881
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
6491
6882
|
return false;
|
|
@@ -6504,7 +6895,7 @@ var defaultShouldServe = ({
|
|
|
6504
6895
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
6505
6896
|
return true;
|
|
6506
6897
|
}
|
|
6507
|
-
const { dir, name } = (0,
|
|
6898
|
+
const { dir, name } = (0, import_path13.parse)(entrypoint);
|
|
6508
6899
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
6509
6900
|
return true;
|
|
6510
6901
|
}
|
|
@@ -6517,6 +6908,7 @@ function hasProp(obj, key) {
|
|
|
6517
6908
|
0 && (module.exports = {
|
|
6518
6909
|
build,
|
|
6519
6910
|
defaultShouldServe,
|
|
6911
|
+
diagnostics,
|
|
6520
6912
|
downloadFilesInWorkPath,
|
|
6521
6913
|
installRequirement,
|
|
6522
6914
|
installRequirementsFile,
|