@vercel/python 5.0.4 → 5.0.6
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 +892 -224
- package/package.json +3 -2
- package/vc_init.py +89 -35
- package/vc_init_dev_asgi.py +58 -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 fs5 = 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
|
+
fs5.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(fs5.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 fs5 = require("fs");
|
|
92
92
|
function isexe(path, options, cb) {
|
|
93
|
-
|
|
93
|
+
fs5.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(fs5.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 fs5 = require("fs");
|
|
123
123
|
var core;
|
|
124
124
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
125
125
|
core = require_windows();
|
|
@@ -174,8 +174,8 @@ var require_isexe = __commonJS({
|
|
|
174
174
|
// ../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js
|
|
175
175
|
var require_which = __commonJS({
|
|
176
176
|
"../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js"(exports, module2) {
|
|
177
|
-
module2.exports =
|
|
178
|
-
|
|
177
|
+
module2.exports = which3;
|
|
178
|
+
which3.sync = whichSync;
|
|
179
179
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
180
180
|
var path = require("path");
|
|
181
181
|
var COLON = isWindows ? ";" : ":";
|
|
@@ -206,7 +206,7 @@ var require_which = __commonJS({
|
|
|
206
206
|
extExe: pathExtExe
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function which3(cmd, opt, cb) {
|
|
210
210
|
if (typeof opt === "function") {
|
|
211
211
|
cb = opt;
|
|
212
212
|
opt = {};
|
|
@@ -307,7 +307,7 @@ var require_resolveCommand = __commonJS({
|
|
|
307
307
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
|
|
308
308
|
"use strict";
|
|
309
309
|
var path = require("path");
|
|
310
|
-
var
|
|
310
|
+
var which3 = require_which();
|
|
311
311
|
var pathKey = require_path_key()();
|
|
312
312
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
313
313
|
const cwd = process.cwd();
|
|
@@ -320,7 +320,7 @@ var require_resolveCommand = __commonJS({
|
|
|
320
320
|
}
|
|
321
321
|
let resolved;
|
|
322
322
|
try {
|
|
323
|
-
resolved =
|
|
323
|
+
resolved = which3.sync(parsed.command, {
|
|
324
324
|
path: (parsed.options.env || process.env)[pathKey],
|
|
325
325
|
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
326
326
|
});
|
|
@@ -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 fs5 = 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 = fs5.openSync(command, "r");
|
|
412
|
+
fs5.readSync(fd, buffer, 0, size, 0);
|
|
413
|
+
fs5.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 debug5;
|
|
427
427
|
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
428
|
-
|
|
428
|
+
debug5 = 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
|
+
debug5 = function() {
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
437
|
exports.SEMVER_SPEC_VERSION = "2.0.0";
|
|
@@ -540,15 +540,15 @@ var require_semver = __commonJS({
|
|
|
540
540
|
var STAR = R++;
|
|
541
541
|
src[STAR] = "(<|>)?=?\\s*\\*";
|
|
542
542
|
for (i = 0; i < R; i++) {
|
|
543
|
-
|
|
543
|
+
debug5(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]));
|
|
547
547
|
}
|
|
548
548
|
}
|
|
549
549
|
var i;
|
|
550
|
-
exports.parse =
|
|
551
|
-
function
|
|
550
|
+
exports.parse = parse2;
|
|
551
|
+
function parse2(version2, options) {
|
|
552
552
|
if (!options || typeof options !== "object") {
|
|
553
553
|
options = {
|
|
554
554
|
loose: !!options,
|
|
@@ -576,12 +576,12 @@ var require_semver = __commonJS({
|
|
|
576
576
|
}
|
|
577
577
|
exports.valid = valid;
|
|
578
578
|
function valid(version2, options) {
|
|
579
|
-
var v =
|
|
579
|
+
var v = parse2(version2, options);
|
|
580
580
|
return v ? v.version : null;
|
|
581
581
|
}
|
|
582
582
|
exports.clean = clean;
|
|
583
583
|
function clean(version2, options) {
|
|
584
|
-
var s =
|
|
584
|
+
var s = parse2(version2.trim().replace(/^[=v]+/, ""), options);
|
|
585
585
|
return s ? s.version : null;
|
|
586
586
|
}
|
|
587
587
|
exports.SemVer = SemVer;
|
|
@@ -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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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) {
|
|
@@ -791,8 +791,8 @@ var require_semver = __commonJS({
|
|
|
791
791
|
if (eq(version1, version2)) {
|
|
792
792
|
return null;
|
|
793
793
|
} else {
|
|
794
|
-
var v1 =
|
|
795
|
-
var v2 =
|
|
794
|
+
var v1 = parse2(version1);
|
|
795
|
+
var v2 = parse2(version2);
|
|
796
796
|
var prefix = "";
|
|
797
797
|
if (v1.prerelease.length || v2.prerelease.length) {
|
|
798
798
|
prefix = "pre";
|
|
@@ -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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("hyphen replace", range);
|
|
1054
1054
|
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
|
|
1055
|
-
|
|
1055
|
+
debug5("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
|
+
debug5("comp", comp, options);
|
|
1096
1096
|
comp = replaceCarets(comp, options);
|
|
1097
|
-
|
|
1097
|
+
debug5("caret", comp);
|
|
1098
1098
|
comp = replaceTildes(comp, options);
|
|
1099
|
-
|
|
1099
|
+
debug5("tildes", comp);
|
|
1100
1100
|
comp = replaceXRanges(comp, options);
|
|
1101
|
-
|
|
1101
|
+
debug5("xrange", comp);
|
|
1102
1102
|
comp = replaceStars(comp, options);
|
|
1103
|
-
|
|
1103
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("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
|
+
debug5("caret return", ret);
|
|
1180
1180
|
return ret;
|
|
1181
1181
|
});
|
|
1182
1182
|
}
|
|
1183
1183
|
function replaceXRanges(comp, options) {
|
|
1184
|
-
|
|
1184
|
+
debug5("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
|
+
debug5("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
|
+
debug5("xRange return", ret);
|
|
1237
1237
|
return ret;
|
|
1238
1238
|
});
|
|
1239
1239
|
}
|
|
1240
1240
|
function replaceStars(comp, options) {
|
|
1241
|
-
|
|
1241
|
+
debug5("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
|
+
debug5(set[i2].semver);
|
|
1290
1290
|
if (set[i2].semver === ANY) {
|
|
1291
1291
|
continue;
|
|
1292
1292
|
}
|
|
@@ -1462,7 +1462,7 @@ var require_semver = __commonJS({
|
|
|
1462
1462
|
}
|
|
1463
1463
|
exports.prerelease = prerelease;
|
|
1464
1464
|
function prerelease(version2, options) {
|
|
1465
|
-
var parsed =
|
|
1465
|
+
var parsed = parse2(version2, options);
|
|
1466
1466
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1467
1467
|
}
|
|
1468
1468
|
exports.intersects = intersects;
|
|
@@ -1483,7 +1483,7 @@ var require_semver = __commonJS({
|
|
|
1483
1483
|
if (match == null) {
|
|
1484
1484
|
return null;
|
|
1485
1485
|
}
|
|
1486
|
-
return
|
|
1486
|
+
return parse2(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"));
|
|
1487
1487
|
}
|
|
1488
1488
|
}
|
|
1489
1489
|
});
|
|
@@ -1498,7 +1498,7 @@ var require_parse = __commonJS({
|
|
|
1498
1498
|
var escape = require_escape();
|
|
1499
1499
|
var readShebang = require_readShebang();
|
|
1500
1500
|
var semver = require_semver();
|
|
1501
|
-
var
|
|
1501
|
+
var isWin2 = process.platform === "win32";
|
|
1502
1502
|
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
1503
1503
|
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
1504
1504
|
var supportsShellOption = niceTry(() => semver.satisfies(process.version, "^4.8.0 || ^5.7.0 || >= 6.0.0", true)) || false;
|
|
@@ -1513,7 +1513,7 @@ var require_parse = __commonJS({
|
|
|
1513
1513
|
return parsed.file;
|
|
1514
1514
|
}
|
|
1515
1515
|
function parseNonShell(parsed) {
|
|
1516
|
-
if (!
|
|
1516
|
+
if (!isWin2) {
|
|
1517
1517
|
return parsed;
|
|
1518
1518
|
}
|
|
1519
1519
|
const commandFile = detectShebang(parsed);
|
|
@@ -1535,7 +1535,7 @@ var require_parse = __commonJS({
|
|
|
1535
1535
|
return parsed;
|
|
1536
1536
|
}
|
|
1537
1537
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
1538
|
-
if (
|
|
1538
|
+
if (isWin2) {
|
|
1539
1539
|
parsed.command = typeof parsed.options.shell === "string" ? parsed.options.shell : process.env.comspec || "cmd.exe";
|
|
1540
1540
|
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
1541
1541
|
parsed.options.windowsVerbatimArguments = true;
|
|
@@ -1551,7 +1551,7 @@ var require_parse = __commonJS({
|
|
|
1551
1551
|
}
|
|
1552
1552
|
return parsed;
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function parse2(command, args, options) {
|
|
1555
1555
|
if (args && !Array.isArray(args)) {
|
|
1556
1556
|
options = args;
|
|
1557
1557
|
args = null;
|
|
@@ -1570,7 +1570,7 @@ var require_parse = __commonJS({
|
|
|
1570
1570
|
};
|
|
1571
1571
|
return options.shell ? parseShell(parsed) : parseNonShell(parsed);
|
|
1572
1572
|
}
|
|
1573
|
-
module2.exports =
|
|
1573
|
+
module2.exports = parse2;
|
|
1574
1574
|
}
|
|
1575
1575
|
});
|
|
1576
1576
|
|
|
@@ -1578,7 +1578,7 @@ var require_parse = __commonJS({
|
|
|
1578
1578
|
var require_enoent = __commonJS({
|
|
1579
1579
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
|
|
1580
1580
|
"use strict";
|
|
1581
|
-
var
|
|
1581
|
+
var isWin2 = process.platform === "win32";
|
|
1582
1582
|
function notFoundError(original, syscall) {
|
|
1583
1583
|
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
1584
1584
|
code: "ENOENT",
|
|
@@ -1589,7 +1589,7 @@ var require_enoent = __commonJS({
|
|
|
1589
1589
|
});
|
|
1590
1590
|
}
|
|
1591
1591
|
function hookChildProcess(cp, parsed) {
|
|
1592
|
-
if (!
|
|
1592
|
+
if (!isWin2) {
|
|
1593
1593
|
return;
|
|
1594
1594
|
}
|
|
1595
1595
|
const originalEmit = cp.emit;
|
|
@@ -1604,13 +1604,13 @@ var require_enoent = __commonJS({
|
|
|
1604
1604
|
};
|
|
1605
1605
|
}
|
|
1606
1606
|
function verifyENOENT(status, parsed) {
|
|
1607
|
-
if (
|
|
1607
|
+
if (isWin2 && status === 1 && !parsed.file) {
|
|
1608
1608
|
return notFoundError(parsed.original, "spawn");
|
|
1609
1609
|
}
|
|
1610
1610
|
return null;
|
|
1611
1611
|
}
|
|
1612
1612
|
function verifyENOENTSync(status, parsed) {
|
|
1613
|
-
if (
|
|
1613
|
+
if (isWin2 && status === 1 && !parsed.file) {
|
|
1614
1614
|
return notFoundError(parsed.original, "spawnSync");
|
|
1615
1615
|
}
|
|
1616
1616
|
return null;
|
|
@@ -1629,24 +1629,24 @@ var require_cross_spawn = __commonJS({
|
|
|
1629
1629
|
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/index.js"(exports, module2) {
|
|
1630
1630
|
"use strict";
|
|
1631
1631
|
var cp = require("child_process");
|
|
1632
|
-
var
|
|
1632
|
+
var parse2 = require_parse();
|
|
1633
1633
|
var enoent = require_enoent();
|
|
1634
|
-
function
|
|
1635
|
-
const parsed =
|
|
1634
|
+
function spawn3(command, args, options) {
|
|
1635
|
+
const parsed = parse2(command, args, options);
|
|
1636
1636
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
1637
1637
|
enoent.hookChildProcess(spawned, parsed);
|
|
1638
1638
|
return spawned;
|
|
1639
1639
|
}
|
|
1640
1640
|
function spawnSync(command, args, options) {
|
|
1641
|
-
const parsed =
|
|
1641
|
+
const parsed = parse2(command, args, options);
|
|
1642
1642
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
1643
1643
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
1644
1644
|
return result;
|
|
1645
1645
|
}
|
|
1646
|
-
module2.exports =
|
|
1647
|
-
module2.exports.spawn =
|
|
1646
|
+
module2.exports = spawn3;
|
|
1647
|
+
module2.exports.spawn = spawn3;
|
|
1648
1648
|
module2.exports.sync = spawnSync;
|
|
1649
|
-
module2.exports._parse =
|
|
1649
|
+
module2.exports._parse = parse2;
|
|
1650
1650
|
module2.exports._enoent = enoent;
|
|
1651
1651
|
}
|
|
1652
1652
|
});
|
|
@@ -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 fs5;
|
|
1899
1899
|
try {
|
|
1900
|
-
|
|
1900
|
+
fs5 = 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 (!fs5)
|
|
1913
1913
|
return false;
|
|
1914
|
-
return (stream instanceof (
|
|
1914
|
+
return (stream instanceof (fs5.ReadStream || noop) || stream instanceof (fs5.WriteStream || noop)) && isFn(stream.close);
|
|
1915
1915
|
};
|
|
1916
1916
|
var isRequest = function(stream) {
|
|
1917
1917
|
return stream.setHeader && isFn(stream.abort);
|
|
@@ -2143,7 +2143,7 @@ var require_signal_exit = __commonJS({
|
|
|
2143
2143
|
} else {
|
|
2144
2144
|
assert = require("assert");
|
|
2145
2145
|
signals = require_signals();
|
|
2146
|
-
|
|
2146
|
+
isWin2 = /^win/i.test(process2.platform);
|
|
2147
2147
|
EE = require("events");
|
|
2148
2148
|
if (typeof EE !== "function") {
|
|
2149
2149
|
EE = EE.EventEmitter;
|
|
@@ -2215,7 +2215,7 @@ var require_signal_exit = __commonJS({
|
|
|
2215
2215
|
unload();
|
|
2216
2216
|
emit("exit", null, sig);
|
|
2217
2217
|
emit("afterexit", null, sig);
|
|
2218
|
-
if (
|
|
2218
|
+
if (isWin2 && sig === "SIGHUP") {
|
|
2219
2219
|
sig = "SIGINT";
|
|
2220
2220
|
}
|
|
2221
2221
|
process2.kill(process2.pid, sig);
|
|
@@ -2272,7 +2272,7 @@ var require_signal_exit = __commonJS({
|
|
|
2272
2272
|
}
|
|
2273
2273
|
var assert;
|
|
2274
2274
|
var signals;
|
|
2275
|
-
var
|
|
2275
|
+
var isWin2;
|
|
2276
2276
|
var EE;
|
|
2277
2277
|
var emitter;
|
|
2278
2278
|
var unload;
|
|
@@ -2651,7 +2651,7 @@ ${stderr}${stdout}`;
|
|
|
2651
2651
|
var require_lib = __commonJS({
|
|
2652
2652
|
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
|
|
2653
2653
|
var isexe = require_isexe();
|
|
2654
|
-
var { join:
|
|
2654
|
+
var { join: join5, delimiter, sep, posix } = require("path");
|
|
2655
2655
|
var isWindows = process.platform === "win32";
|
|
2656
2656
|
var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
|
|
2657
2657
|
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
@@ -2680,9 +2680,9 @@ var require_lib = __commonJS({
|
|
|
2680
2680
|
var getPathPart = (raw, cmd) => {
|
|
2681
2681
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2682
2682
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2683
|
-
return prefix +
|
|
2683
|
+
return prefix + join5(pathPart, cmd);
|
|
2684
2684
|
};
|
|
2685
|
-
var
|
|
2685
|
+
var which3 = async (cmd, opt = {}) => {
|
|
2686
2686
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
2687
2687
|
const found = [];
|
|
2688
2688
|
for (const envPart of pathEnv) {
|
|
@@ -2730,8 +2730,8 @@ var require_lib = __commonJS({
|
|
|
2730
2730
|
}
|
|
2731
2731
|
throw getNotFoundError(cmd);
|
|
2732
2732
|
};
|
|
2733
|
-
module2.exports =
|
|
2734
|
-
|
|
2733
|
+
module2.exports = which3;
|
|
2734
|
+
which3.sync = whichSync;
|
|
2735
2735
|
}
|
|
2736
2736
|
});
|
|
2737
2737
|
|
|
@@ -2739,23 +2739,29 @@ var require_lib = __commonJS({
|
|
|
2739
2739
|
var src_exports = {};
|
|
2740
2740
|
__export(src_exports, {
|
|
2741
2741
|
build: () => build,
|
|
2742
|
+
defaultShouldServe: () => defaultShouldServe,
|
|
2742
2743
|
downloadFilesInWorkPath: () => downloadFilesInWorkPath,
|
|
2743
2744
|
installRequirement: () => installRequirement,
|
|
2744
2745
|
installRequirementsFile: () => installRequirementsFile,
|
|
2745
|
-
shouldServe: () =>
|
|
2746
|
+
shouldServe: () => shouldServe,
|
|
2747
|
+
startDevServer: () => startDevServer,
|
|
2746
2748
|
version: () => version
|
|
2747
2749
|
});
|
|
2748
2750
|
module.exports = __toCommonJS(src_exports);
|
|
2749
|
-
var
|
|
2750
|
-
var import_execa2 = __toESM(require_execa());
|
|
2751
|
+
var import_fs5 = __toESM(require("fs"));
|
|
2751
2752
|
var import_util = require("util");
|
|
2752
|
-
var
|
|
2753
|
-
var
|
|
2753
|
+
var import_path5 = require("path");
|
|
2754
|
+
var import_build_utils5 = require("@vercel/build-utils");
|
|
2754
2755
|
|
|
2755
2756
|
// src/install.ts
|
|
2756
2757
|
var import_execa = __toESM(require_execa());
|
|
2758
|
+
var import_fs = __toESM(require("fs"));
|
|
2759
|
+
var import_os = __toESM(require("os"));
|
|
2757
2760
|
var import_path = require("path");
|
|
2761
|
+
var import_which = __toESM(require_lib());
|
|
2758
2762
|
var import_build_utils = require("@vercel/build-utils");
|
|
2763
|
+
var isWin = process.platform === "win32";
|
|
2764
|
+
var uvExec = isWin ? "uv.exe" : "uv";
|
|
2759
2765
|
var makeDependencyCheckCode = (dependency) => `
|
|
2760
2766
|
from importlib import util
|
|
2761
2767
|
dep = '${dependency}'.replace('-', '_')
|
|
@@ -2805,9 +2811,62 @@ function resolveVendorDir() {
|
|
|
2805
2811
|
const vendorDir = process.env.VERCEL_PYTHON_VENDOR_DIR || "_vendor";
|
|
2806
2812
|
return vendorDir;
|
|
2807
2813
|
}
|
|
2808
|
-
async function
|
|
2809
|
-
const
|
|
2814
|
+
async function getGlobalScriptsDir(pythonPath) {
|
|
2815
|
+
const code = `import sysconfig; print(sysconfig.get_path('scripts'))`;
|
|
2816
|
+
try {
|
|
2817
|
+
const { stdout } = await (0, import_execa.default)(pythonPath, ["-c", code]);
|
|
2818
|
+
const out = stdout.trim();
|
|
2819
|
+
return out || null;
|
|
2820
|
+
} catch (err) {
|
|
2821
|
+
(0, import_build_utils.debug)("Failed to resolve Python global scripts directory", err);
|
|
2822
|
+
return null;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
async function getUserScriptsDir(pythonPath) {
|
|
2826
|
+
const code = `import sys, sysconfig; print(sysconfig.get_path('scripts', scheme=('nt_user' if sys.platform == 'win32' else 'posix_user')))`.replace(
|
|
2827
|
+
/\n/g,
|
|
2828
|
+
" "
|
|
2829
|
+
);
|
|
2830
|
+
try {
|
|
2831
|
+
const { stdout } = await (0, import_execa.default)(pythonPath, ["-c", code]);
|
|
2832
|
+
const out = stdout.trim();
|
|
2833
|
+
return out || null;
|
|
2834
|
+
} catch (err) {
|
|
2835
|
+
(0, import_build_utils.debug)("Failed to resolve Python user scripts directory", err);
|
|
2836
|
+
return null;
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
async function pipInstall(pipPath, pythonPath, workPath, args, targetDir) {
|
|
2840
|
+
const target = targetDir ? (0, import_path.join)(targetDir, resolveVendorDir()) : resolveVendorDir();
|
|
2810
2841
|
process.env.PIP_USER = "0";
|
|
2842
|
+
let uvBin = null;
|
|
2843
|
+
try {
|
|
2844
|
+
uvBin = await getUvBinaryOrInstall(pythonPath);
|
|
2845
|
+
} catch (err) {
|
|
2846
|
+
console.log("Failed to install uv, falling back to pip");
|
|
2847
|
+
}
|
|
2848
|
+
if (uvBin) {
|
|
2849
|
+
const uvArgs = [
|
|
2850
|
+
"pip",
|
|
2851
|
+
"install",
|
|
2852
|
+
"--no-compile",
|
|
2853
|
+
"--no-cache-dir",
|
|
2854
|
+
"--target",
|
|
2855
|
+
target,
|
|
2856
|
+
...args
|
|
2857
|
+
];
|
|
2858
|
+
const prettyUv = `${uvBin} ${uvArgs.join(" ")}`;
|
|
2859
|
+
(0, import_build_utils.debug)(`Running "${prettyUv}"...`);
|
|
2860
|
+
try {
|
|
2861
|
+
await (0, import_execa.default)(uvBin, uvArgs, {
|
|
2862
|
+
cwd: workPath
|
|
2863
|
+
});
|
|
2864
|
+
return;
|
|
2865
|
+
} catch (err) {
|
|
2866
|
+
console.log(`Failed to run "${prettyUv}", falling back to pip`);
|
|
2867
|
+
(0, import_build_utils.debug)(`error: ${err}`);
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2811
2870
|
const cmdArgs = [
|
|
2812
2871
|
"install",
|
|
2813
2872
|
"--disable-pip-version-check",
|
|
@@ -2825,45 +2884,195 @@ async function pipInstall(pipPath, workPath, args) {
|
|
|
2825
2884
|
});
|
|
2826
2885
|
} catch (err) {
|
|
2827
2886
|
console.log(`Failed to run "${pretty}"`);
|
|
2887
|
+
(0, import_build_utils.debug)(`error: ${err}`);
|
|
2828
2888
|
throw err;
|
|
2829
2889
|
}
|
|
2830
2890
|
}
|
|
2891
|
+
async function maybeFindUvBin(pythonPath) {
|
|
2892
|
+
const found = import_which.default.sync("uv", { nothrow: true });
|
|
2893
|
+
if (found)
|
|
2894
|
+
return found;
|
|
2895
|
+
try {
|
|
2896
|
+
const globalScriptsDir = await getGlobalScriptsDir(pythonPath);
|
|
2897
|
+
if (globalScriptsDir) {
|
|
2898
|
+
const uvPath = (0, import_path.join)(globalScriptsDir, uvExec);
|
|
2899
|
+
if (import_fs.default.existsSync(uvPath))
|
|
2900
|
+
return uvPath;
|
|
2901
|
+
}
|
|
2902
|
+
} catch (err) {
|
|
2903
|
+
(0, import_build_utils.debug)("Failed to resolve Python global scripts directory", err);
|
|
2904
|
+
}
|
|
2905
|
+
try {
|
|
2906
|
+
const userScriptsDir = await getUserScriptsDir(pythonPath);
|
|
2907
|
+
if (userScriptsDir) {
|
|
2908
|
+
const uvPath = (0, import_path.join)(userScriptsDir, uvExec);
|
|
2909
|
+
if (import_fs.default.existsSync(uvPath))
|
|
2910
|
+
return uvPath;
|
|
2911
|
+
}
|
|
2912
|
+
} catch (err) {
|
|
2913
|
+
(0, import_build_utils.debug)("Failed to resolve Python user scripts directory", err);
|
|
2914
|
+
}
|
|
2915
|
+
try {
|
|
2916
|
+
const candidates = [];
|
|
2917
|
+
if (!isWin) {
|
|
2918
|
+
candidates.push((0, import_path.join)(import_os.default.homedir(), ".local", "bin", "uv"));
|
|
2919
|
+
candidates.push("/usr/local/bin/uv");
|
|
2920
|
+
candidates.push("/opt/homebrew/bin/uv");
|
|
2921
|
+
} else {
|
|
2922
|
+
candidates.push("C:\\Users\\Public\\uv\\uv.exe");
|
|
2923
|
+
}
|
|
2924
|
+
for (const p of candidates) {
|
|
2925
|
+
if (import_fs.default.existsSync(p))
|
|
2926
|
+
return p;
|
|
2927
|
+
}
|
|
2928
|
+
} catch (err) {
|
|
2929
|
+
(0, import_build_utils.debug)("Failed to resolve uv fallback paths", err);
|
|
2930
|
+
}
|
|
2931
|
+
return null;
|
|
2932
|
+
}
|
|
2933
|
+
async function getUvBinaryOrInstall(pythonPath) {
|
|
2934
|
+
const uvBin = await maybeFindUvBin(pythonPath);
|
|
2935
|
+
if (uvBin) {
|
|
2936
|
+
console.log(`Using uv at "${uvBin}"`);
|
|
2937
|
+
return uvBin;
|
|
2938
|
+
}
|
|
2939
|
+
try {
|
|
2940
|
+
console.log("Installing uv...");
|
|
2941
|
+
await (0, import_execa.default)(
|
|
2942
|
+
pythonPath,
|
|
2943
|
+
[
|
|
2944
|
+
"-m",
|
|
2945
|
+
"pip",
|
|
2946
|
+
"install",
|
|
2947
|
+
"--disable-pip-version-check",
|
|
2948
|
+
"--no-cache-dir",
|
|
2949
|
+
"--user",
|
|
2950
|
+
"uv==0.8.18"
|
|
2951
|
+
],
|
|
2952
|
+
{ env: { ...process.env, PIP_USER: "1" } }
|
|
2953
|
+
);
|
|
2954
|
+
} catch (err) {
|
|
2955
|
+
throw new Error(
|
|
2956
|
+
`Failed to install uv via pip: ${err instanceof Error ? err.message : String(err)}`
|
|
2957
|
+
);
|
|
2958
|
+
}
|
|
2959
|
+
const resolvedUvBin = await maybeFindUvBin(pythonPath);
|
|
2960
|
+
if (!resolvedUvBin) {
|
|
2961
|
+
throw new Error("Unable to resolve uv binary after pip install");
|
|
2962
|
+
}
|
|
2963
|
+
console.log(`Installed uv at "${resolvedUvBin}"`);
|
|
2964
|
+
return resolvedUvBin;
|
|
2965
|
+
}
|
|
2831
2966
|
async function installRequirement({
|
|
2832
2967
|
pythonPath,
|
|
2833
2968
|
pipPath,
|
|
2834
2969
|
dependency,
|
|
2835
2970
|
version: version2,
|
|
2836
2971
|
workPath,
|
|
2972
|
+
targetDir,
|
|
2837
2973
|
meta,
|
|
2838
2974
|
args = []
|
|
2839
2975
|
}) {
|
|
2840
|
-
|
|
2976
|
+
const actualTargetDir = targetDir || workPath;
|
|
2977
|
+
if (meta.isDev && await isInstalled(pythonPath, dependency, actualTargetDir)) {
|
|
2841
2978
|
(0, import_build_utils.debug)(
|
|
2842
|
-
`Skipping ${dependency} dependency installation, already installed in ${
|
|
2979
|
+
`Skipping ${dependency} dependency installation, already installed in ${actualTargetDir}`
|
|
2843
2980
|
);
|
|
2844
2981
|
return;
|
|
2845
2982
|
}
|
|
2846
2983
|
const exact = `${dependency}==${version2}`;
|
|
2847
|
-
await pipInstall(pipPath, workPath, [exact, ...args]);
|
|
2984
|
+
await pipInstall(pipPath, pythonPath, workPath, [exact, ...args], targetDir);
|
|
2848
2985
|
}
|
|
2849
2986
|
async function installRequirementsFile({
|
|
2850
2987
|
pythonPath,
|
|
2851
2988
|
pipPath,
|
|
2852
2989
|
filePath,
|
|
2853
2990
|
workPath,
|
|
2991
|
+
targetDir,
|
|
2854
2992
|
meta,
|
|
2855
2993
|
args = []
|
|
2856
2994
|
}) {
|
|
2857
|
-
|
|
2995
|
+
const actualTargetDir = targetDir || workPath;
|
|
2996
|
+
if (meta.isDev && await areRequirementsInstalled(pythonPath, filePath, actualTargetDir)) {
|
|
2858
2997
|
(0, import_build_utils.debug)(`Skipping requirements file installation, already installed`);
|
|
2859
2998
|
return;
|
|
2860
2999
|
}
|
|
2861
|
-
await pipInstall(
|
|
3000
|
+
await pipInstall(
|
|
3001
|
+
pipPath,
|
|
3002
|
+
pythonPath,
|
|
3003
|
+
workPath,
|
|
3004
|
+
["--upgrade", "-r", filePath, ...args],
|
|
3005
|
+
targetDir
|
|
3006
|
+
);
|
|
3007
|
+
}
|
|
3008
|
+
async function exportRequirementsFromUv(pythonPath, projectDir, options = {}) {
|
|
3009
|
+
const { locked = false } = options;
|
|
3010
|
+
const uvBin = await getUvBinaryOrInstall(pythonPath);
|
|
3011
|
+
const args = ["export"];
|
|
3012
|
+
if (locked) {
|
|
3013
|
+
args.push("--frozen");
|
|
3014
|
+
}
|
|
3015
|
+
(0, import_build_utils.debug)(`Running "${uvBin} ${args.join(" ")}" in ${projectDir}...`);
|
|
3016
|
+
let stdout;
|
|
3017
|
+
try {
|
|
3018
|
+
const { stdout: out } = await (0, import_execa.default)(uvBin, args, { cwd: projectDir });
|
|
3019
|
+
stdout = out;
|
|
3020
|
+
} catch (err) {
|
|
3021
|
+
throw new Error(
|
|
3022
|
+
`Failed to run "${uvBin} ${args.join(" ")}": ${err instanceof Error ? err.message : String(err)}`
|
|
3023
|
+
);
|
|
3024
|
+
}
|
|
3025
|
+
const tmpDir = await import_fs.default.promises.mkdtemp((0, import_path.join)(import_os.default.tmpdir(), "vercel-uv-"));
|
|
3026
|
+
const outPath = (0, import_path.join)(tmpDir, "requirements.uv.txt");
|
|
3027
|
+
await import_fs.default.promises.writeFile(outPath, stdout);
|
|
3028
|
+
(0, import_build_utils.debug)(`Exported requirements to ${outPath}`);
|
|
3029
|
+
return outPath;
|
|
3030
|
+
}
|
|
3031
|
+
async function exportRequirementsFromPipfile({
|
|
3032
|
+
pythonPath,
|
|
3033
|
+
pipPath,
|
|
3034
|
+
projectDir,
|
|
3035
|
+
meta
|
|
3036
|
+
}) {
|
|
3037
|
+
const tempDir = await import_fs.default.promises.mkdtemp(
|
|
3038
|
+
(0, import_path.join)(import_os.default.tmpdir(), "vercel-pipenv-")
|
|
3039
|
+
);
|
|
3040
|
+
await installRequirement({
|
|
3041
|
+
pythonPath,
|
|
3042
|
+
pipPath,
|
|
3043
|
+
dependency: "pipfile-requirements",
|
|
3044
|
+
version: "0.3.0",
|
|
3045
|
+
workPath: tempDir,
|
|
3046
|
+
meta,
|
|
3047
|
+
args: ["--no-warn-script-location"]
|
|
3048
|
+
});
|
|
3049
|
+
const tempVendorDir = (0, import_path.join)(tempDir, resolveVendorDir());
|
|
3050
|
+
const convertCmd = isWin ? (0, import_path.join)(tempVendorDir, "Scripts", "pipfile2req.exe") : (0, import_path.join)(tempVendorDir, "bin", "pipfile2req");
|
|
3051
|
+
(0, import_build_utils.debug)(`Running "${convertCmd}" in ${projectDir}...`);
|
|
3052
|
+
let stdout;
|
|
3053
|
+
try {
|
|
3054
|
+
const { stdout: out } = await (0, import_execa.default)(convertCmd, [], {
|
|
3055
|
+
cwd: projectDir,
|
|
3056
|
+
env: { ...process.env, PYTHONPATH: tempVendorDir }
|
|
3057
|
+
});
|
|
3058
|
+
stdout = out;
|
|
3059
|
+
} catch (err) {
|
|
3060
|
+
throw new Error(
|
|
3061
|
+
`Failed to run "${convertCmd}": ${err instanceof Error ? err.message : String(err)}`
|
|
3062
|
+
);
|
|
3063
|
+
}
|
|
3064
|
+
const outPath = (0, import_path.join)(tempDir, "requirements.pipenv.txt");
|
|
3065
|
+
await import_fs.default.promises.writeFile(outPath, stdout);
|
|
3066
|
+
(0, import_build_utils.debug)(`Exported pipfile requirements to ${outPath}`);
|
|
3067
|
+
return outPath;
|
|
2862
3068
|
}
|
|
2863
3069
|
|
|
3070
|
+
// src/index.ts
|
|
3071
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
3072
|
+
|
|
2864
3073
|
// src/version.ts
|
|
2865
3074
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
2866
|
-
var
|
|
3075
|
+
var import_which2 = __toESM(require_lib());
|
|
2867
3076
|
var allOptions = [
|
|
2868
3077
|
{
|
|
2869
3078
|
version: "3.12",
|
|
@@ -2923,21 +3132,33 @@ function getLatestPythonVersion({
|
|
|
2923
3132
|
}
|
|
2924
3133
|
function getSupportedPythonVersion({
|
|
2925
3134
|
isDev,
|
|
2926
|
-
|
|
3135
|
+
declaredPythonVersion
|
|
2927
3136
|
}) {
|
|
2928
3137
|
if (isDev) {
|
|
2929
3138
|
return getDevPythonVersion();
|
|
2930
3139
|
}
|
|
2931
3140
|
let selection = getLatestPythonVersion({ isDev: false });
|
|
2932
|
-
if (
|
|
2933
|
-
const
|
|
2934
|
-
|
|
2935
|
-
)
|
|
2936
|
-
|
|
2937
|
-
|
|
3141
|
+
if (declaredPythonVersion) {
|
|
3142
|
+
const { version: version2, source } = declaredPythonVersion;
|
|
3143
|
+
const requested = allOptions.find((o) => o.version === version2);
|
|
3144
|
+
if (requested) {
|
|
3145
|
+
if (isDiscontinued(requested)) {
|
|
3146
|
+
throw new import_build_utils2.NowBuildError({
|
|
3147
|
+
code: "BUILD_UTILS_PYTHON_VERSION_DISCONTINUED",
|
|
3148
|
+
link: "http://vercel.link/python-version",
|
|
3149
|
+
message: `Python version "${requested.version}" detected in ${source} is discontinued and must be upgraded.`
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
if (isInstalled2(requested)) {
|
|
3153
|
+
selection = requested;
|
|
3154
|
+
} else {
|
|
3155
|
+
console.warn(
|
|
3156
|
+
`Warning: Python version "${version2}" detected in ${source} is not installed and will be ignored. http://vercel.link/python-version`
|
|
3157
|
+
);
|
|
3158
|
+
}
|
|
2938
3159
|
} else {
|
|
2939
3160
|
console.warn(
|
|
2940
|
-
`Warning: Python version "${
|
|
3161
|
+
`Warning: Python version "${version2}" detected in ${source} is invalid and will be ignored. http://vercel.link/python-version`
|
|
2941
3162
|
);
|
|
2942
3163
|
}
|
|
2943
3164
|
}
|
|
@@ -2945,13 +3166,14 @@ function getSupportedPythonVersion({
|
|
|
2945
3166
|
throw new import_build_utils2.NowBuildError({
|
|
2946
3167
|
code: "BUILD_UTILS_PYTHON_VERSION_DISCONTINUED",
|
|
2947
3168
|
link: "http://vercel.link/python-version",
|
|
2948
|
-
message: `Python version "${selection.version}"
|
|
3169
|
+
message: `Python version "${selection.version}" declared in project configuration is discontinued and must be upgraded.`
|
|
2949
3170
|
});
|
|
2950
3171
|
}
|
|
2951
3172
|
if (selection.discontinueDate) {
|
|
2952
3173
|
const d = selection.discontinueDate.toISOString().split("T")[0];
|
|
3174
|
+
const srcSuffix = declaredPythonVersion ? `detected in ${declaredPythonVersion.source}` : "selected by runtime";
|
|
2953
3175
|
console.warn(
|
|
2954
|
-
`Error: Python version "${selection.version}"
|
|
3176
|
+
`Error: Python version "${selection.version}" ${srcSuffix} has reached End-of-Life. Deployments created on or after ${d} will fail to build. http://vercel.link/python-version`
|
|
2955
3177
|
);
|
|
2956
3178
|
}
|
|
2957
3179
|
return selection;
|
|
@@ -2961,57 +3183,418 @@ function isDiscontinued({ discontinueDate }) {
|
|
|
2961
3183
|
return discontinueDate !== void 0 && discontinueDate.getTime() <= today;
|
|
2962
3184
|
}
|
|
2963
3185
|
function isInstalled2({ pipPath, pythonPath }) {
|
|
2964
|
-
return Boolean(
|
|
3186
|
+
return Boolean(import_which2.default.sync(pipPath, { nothrow: true })) && Boolean(import_which2.default.sync(pythonPath, { nothrow: true }));
|
|
2965
3187
|
}
|
|
2966
3188
|
|
|
2967
|
-
// src/
|
|
2968
|
-
var
|
|
2969
|
-
var
|
|
2970
|
-
var
|
|
2971
|
-
var
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3189
|
+
// src/start-dev-server.ts
|
|
3190
|
+
var import_child_process2 = require("child_process");
|
|
3191
|
+
var import_fs4 = require("fs");
|
|
3192
|
+
var import_path4 = require("path");
|
|
3193
|
+
var import_build_utils4 = require("@vercel/build-utils");
|
|
3194
|
+
|
|
3195
|
+
// src/entrypoint.ts
|
|
3196
|
+
var import_fs2 = __toESM(require("fs"));
|
|
3197
|
+
var import_path2 = require("path");
|
|
3198
|
+
var import_build_utils3 = require("@vercel/build-utils");
|
|
3199
|
+
var FASTAPI_ENTRYPOINT_FILENAMES = ["app", "index", "server", "main"];
|
|
3200
|
+
var FASTAPI_ENTRYPOINT_DIRS = ["", "src", "app"];
|
|
3201
|
+
var FASTAPI_CONTENT_REGEX = /(from\s+fastapi\s+import\s+FastAPI|import\s+fastapi|FastAPI\s*\()/;
|
|
3202
|
+
var FASTAPI_CANDIDATE_ENTRYPOINTS = FASTAPI_ENTRYPOINT_FILENAMES.flatMap(
|
|
3203
|
+
(filename) => FASTAPI_ENTRYPOINT_DIRS.map(
|
|
3204
|
+
(dir) => import_path2.posix.join(dir, `${filename}.py`)
|
|
3205
|
+
)
|
|
2975
3206
|
);
|
|
2976
3207
|
function isFastapiEntrypoint(file) {
|
|
2977
3208
|
try {
|
|
2978
3209
|
const fsPath = file.fsPath;
|
|
2979
3210
|
if (!fsPath)
|
|
2980
3211
|
return false;
|
|
2981
|
-
const contents =
|
|
2982
|
-
return
|
|
3212
|
+
const contents = import_fs2.default.readFileSync(fsPath, "utf8");
|
|
3213
|
+
return FASTAPI_CONTENT_REGEX.test(contents);
|
|
2983
3214
|
} catch {
|
|
2984
3215
|
return false;
|
|
2985
3216
|
}
|
|
2986
3217
|
}
|
|
2987
|
-
async function
|
|
2988
|
-
|
|
3218
|
+
async function detectFastapiEntrypoint(workPath, configuredEntrypoint) {
|
|
3219
|
+
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
2989
3220
|
try {
|
|
2990
|
-
const
|
|
2991
|
-
|
|
2992
|
-
|
|
3221
|
+
const fsFiles = await (0, import_build_utils3.glob)("**", workPath);
|
|
3222
|
+
if (fsFiles[entry])
|
|
3223
|
+
return entry;
|
|
3224
|
+
const candidates = FASTAPI_CANDIDATE_ENTRYPOINTS.filter(
|
|
3225
|
+
(c) => !!fsFiles[c]
|
|
3226
|
+
);
|
|
3227
|
+
if (candidates.length > 0) {
|
|
3228
|
+
const fastapiEntrypoint = candidates.find(
|
|
3229
|
+
(c) => isFastapiEntrypoint(fsFiles[c])
|
|
3230
|
+
) || candidates[0];
|
|
3231
|
+
(0, import_build_utils3.debug)(`Detected FastAPI entrypoint: ${fastapiEntrypoint}`);
|
|
3232
|
+
return fastapiEntrypoint;
|
|
3233
|
+
}
|
|
3234
|
+
return null;
|
|
3235
|
+
} catch {
|
|
3236
|
+
(0, import_build_utils3.debug)("Failed to discover entrypoint for FastAPI");
|
|
3237
|
+
return null;
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
// src/utils.ts
|
|
3242
|
+
var import_child_process = require("child_process");
|
|
3243
|
+
var import_fs3 = __toESM(require("fs"));
|
|
3244
|
+
var import_path3 = require("path");
|
|
3245
|
+
var tryImport = (pythonPath, mod) => new Promise((res) => {
|
|
3246
|
+
const check = (0, import_child_process.spawn)(pythonPath, ["-c", `import ${mod}`], {
|
|
3247
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
3248
|
+
});
|
|
3249
|
+
check.once("error", () => res(false));
|
|
3250
|
+
check.once("exit", (code) => res(code === 0));
|
|
3251
|
+
});
|
|
3252
|
+
var detectAsgiServer = async (workPath, pythonPath) => new Promise((resolve, reject) => {
|
|
3253
|
+
tryImport(pythonPath, "uvicorn").then((hasUvicorn) => {
|
|
3254
|
+
if (hasUvicorn)
|
|
3255
|
+
return resolve("uvicorn");
|
|
3256
|
+
tryImport(pythonPath, "hypercorn").then((hasHypercorn) => {
|
|
3257
|
+
if (hasHypercorn)
|
|
3258
|
+
return resolve("hypercorn");
|
|
3259
|
+
const { venvRoot } = useVirtualEnv(workPath, {}, pythonPath);
|
|
3260
|
+
const baseErrorMessage = 'No ASGI server found. Please install either "uvicorn" or "hypercorn" (e.g. "pip install uvicorn").';
|
|
3261
|
+
const errorMessage = !venvRoot ? `${baseErrorMessage} If you are using a virtual environment, please activate it and try again.` : baseErrorMessage;
|
|
3262
|
+
reject(new Error(errorMessage));
|
|
2993
3263
|
});
|
|
2994
|
-
|
|
2995
|
-
|
|
3264
|
+
});
|
|
3265
|
+
});
|
|
3266
|
+
var isInVirtualEnv = () => {
|
|
3267
|
+
return process.env.VIRTUAL_ENV;
|
|
3268
|
+
};
|
|
3269
|
+
function useVirtualEnv(workPath, env, systemPython) {
|
|
3270
|
+
const venvDirs = [".venv", "venv"];
|
|
3271
|
+
let pythonCmd = systemPython;
|
|
3272
|
+
for (const venv of venvDirs) {
|
|
3273
|
+
const venvRoot = (0, import_path3.join)(workPath, venv);
|
|
3274
|
+
const binDir = process.platform === "win32" ? (0, import_path3.join)(venvRoot, "Scripts") : (0, import_path3.join)(venvRoot, "bin");
|
|
3275
|
+
const candidates = process.platform === "win32" ? [(0, import_path3.join)(binDir, "python.exe"), (0, import_path3.join)(binDir, "python")] : [(0, import_path3.join)(binDir, "python3"), (0, import_path3.join)(binDir, "python")];
|
|
3276
|
+
const found = candidates.find((p) => import_fs3.default.existsSync(p));
|
|
3277
|
+
if (found) {
|
|
3278
|
+
pythonCmd = found;
|
|
3279
|
+
env.VIRTUAL_ENV = venvRoot;
|
|
3280
|
+
env.PATH = `${binDir}${import_path3.delimiter}${env.PATH || ""}`;
|
|
3281
|
+
return { pythonCmd, venvRoot };
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
return { pythonCmd };
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
// src/start-dev-server.ts
|
|
3288
|
+
function silenceNodeWarnings() {
|
|
3289
|
+
const original = process.emitWarning.bind(
|
|
3290
|
+
process
|
|
3291
|
+
);
|
|
3292
|
+
let active = true;
|
|
3293
|
+
const wrapped = (warning, ...args) => {
|
|
3294
|
+
if (!active) {
|
|
3295
|
+
return original(
|
|
3296
|
+
warning,
|
|
3297
|
+
...args
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3300
|
+
return;
|
|
3301
|
+
};
|
|
3302
|
+
process.emitWarning = wrapped;
|
|
3303
|
+
return () => {
|
|
3304
|
+
if (!active)
|
|
3305
|
+
return;
|
|
3306
|
+
active = false;
|
|
3307
|
+
if (process.emitWarning === wrapped) {
|
|
3308
|
+
process.emitWarning = original;
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
var ANSI_PATTERN = "[\\u001B\\u009B][[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nq-uy=><]";
|
|
3313
|
+
var ANSI_ESCAPE_RE = new RegExp(ANSI_PATTERN, "g");
|
|
3314
|
+
var stripAnsi = (s) => s.replace(ANSI_ESCAPE_RE, "");
|
|
3315
|
+
var ASGI_SHIM_MODULE = "vc_init_dev_asgi";
|
|
3316
|
+
var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
|
|
3317
|
+
var PENDING_STARTS = /* @__PURE__ */ new Map();
|
|
3318
|
+
var restoreWarnings = null;
|
|
3319
|
+
var cleanupHandlersInstalled = false;
|
|
3320
|
+
function installGlobalCleanupHandlers() {
|
|
3321
|
+
if (cleanupHandlersInstalled)
|
|
3322
|
+
return;
|
|
3323
|
+
cleanupHandlersInstalled = true;
|
|
3324
|
+
const killAll = () => {
|
|
3325
|
+
for (const [key, info] of PERSISTENT_SERVERS.entries()) {
|
|
3326
|
+
try {
|
|
3327
|
+
process.kill(info.pid, "SIGTERM");
|
|
3328
|
+
} catch (err) {
|
|
3329
|
+
(0, import_build_utils4.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
3330
|
+
}
|
|
3331
|
+
try {
|
|
3332
|
+
process.kill(info.pid, "SIGKILL");
|
|
3333
|
+
} catch (err) {
|
|
3334
|
+
(0, import_build_utils4.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
3335
|
+
}
|
|
3336
|
+
PERSISTENT_SERVERS.delete(key);
|
|
3337
|
+
}
|
|
3338
|
+
if (restoreWarnings) {
|
|
3339
|
+
try {
|
|
3340
|
+
restoreWarnings();
|
|
3341
|
+
} catch (err) {
|
|
3342
|
+
(0, import_build_utils4.debug)(`Error restoring warnings: ${err}`);
|
|
3343
|
+
}
|
|
3344
|
+
restoreWarnings = null;
|
|
3345
|
+
}
|
|
3346
|
+
};
|
|
3347
|
+
process.on("SIGINT", () => {
|
|
3348
|
+
killAll();
|
|
3349
|
+
process.exit(130);
|
|
3350
|
+
});
|
|
3351
|
+
process.on("SIGTERM", () => {
|
|
3352
|
+
killAll();
|
|
3353
|
+
process.exit(143);
|
|
3354
|
+
});
|
|
3355
|
+
process.on("exit", () => {
|
|
3356
|
+
killAll();
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
function createDevStaticShim(workPath, modulePath) {
|
|
3360
|
+
try {
|
|
3361
|
+
const vercelPythonDir = (0, import_path4.join)(workPath, ".vercel", "python");
|
|
3362
|
+
(0, import_fs4.mkdirSync)(vercelPythonDir, { recursive: true });
|
|
3363
|
+
const shimPath = (0, import_path4.join)(vercelPythonDir, `${ASGI_SHIM_MODULE}.py`);
|
|
3364
|
+
const templatePath = (0, import_path4.join)(__dirname, "..", `${ASGI_SHIM_MODULE}.py`);
|
|
3365
|
+
const template = (0, import_fs4.readFileSync)(templatePath, "utf8");
|
|
3366
|
+
const shimSource = template.replace(/__VC_DEV_MODULE_PATH__/g, modulePath);
|
|
3367
|
+
(0, import_fs4.writeFileSync)(shimPath, shimSource, "utf8");
|
|
3368
|
+
(0, import_build_utils4.debug)(`Prepared Python dev static shim at ${shimPath}`);
|
|
3369
|
+
return ASGI_SHIM_MODULE;
|
|
2996
3370
|
} catch (err) {
|
|
2997
|
-
|
|
2998
|
-
|
|
3371
|
+
(0, import_build_utils4.debug)(`Failed to prepare dev static shim: ${err?.message || err}`);
|
|
3372
|
+
return null;
|
|
2999
3373
|
}
|
|
3000
3374
|
}
|
|
3375
|
+
var startDevServer = async (opts) => {
|
|
3376
|
+
const { entrypoint: rawEntrypoint, workPath, meta = {}, config } = opts;
|
|
3377
|
+
if (config?.framework !== "fastapi") {
|
|
3378
|
+
return null;
|
|
3379
|
+
}
|
|
3380
|
+
if (!restoreWarnings)
|
|
3381
|
+
restoreWarnings = silenceNodeWarnings();
|
|
3382
|
+
installGlobalCleanupHandlers();
|
|
3383
|
+
const detected = await detectFastapiEntrypoint(workPath, rawEntrypoint);
|
|
3384
|
+
if (!detected) {
|
|
3385
|
+
throw new Error(
|
|
3386
|
+
`No FastAPI entrypoint found. Searched for: ${FASTAPI_CANDIDATE_ENTRYPOINTS.join(", ")}`
|
|
3387
|
+
);
|
|
3388
|
+
}
|
|
3389
|
+
const entry = detected;
|
|
3390
|
+
const modulePath = entry.replace(/\.py$/i, "").replace(/[\\/]/g, ".");
|
|
3391
|
+
const env = { ...process.env, ...meta.env || {} };
|
|
3392
|
+
const serverKey = `${workPath}::${entry}`;
|
|
3393
|
+
const existing = PERSISTENT_SERVERS.get(serverKey);
|
|
3394
|
+
if (existing) {
|
|
3395
|
+
return {
|
|
3396
|
+
port: existing.port,
|
|
3397
|
+
pid: existing.pid,
|
|
3398
|
+
shutdown: async () => {
|
|
3399
|
+
}
|
|
3400
|
+
};
|
|
3401
|
+
}
|
|
3402
|
+
{
|
|
3403
|
+
const pending = PENDING_STARTS.get(serverKey);
|
|
3404
|
+
if (pending) {
|
|
3405
|
+
const { port, pid } = await pending;
|
|
3406
|
+
return {
|
|
3407
|
+
port,
|
|
3408
|
+
pid,
|
|
3409
|
+
shutdown: async () => {
|
|
3410
|
+
}
|
|
3411
|
+
};
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
let childProcess = null;
|
|
3415
|
+
let stdoutLogListener = null;
|
|
3416
|
+
let stderrLogListener = null;
|
|
3417
|
+
let resolveChildReady;
|
|
3418
|
+
let rejectChildReady;
|
|
3419
|
+
const childReady = new Promise(
|
|
3420
|
+
(resolve, reject) => {
|
|
3421
|
+
resolveChildReady = resolve;
|
|
3422
|
+
rejectChildReady = reject;
|
|
3423
|
+
}
|
|
3424
|
+
);
|
|
3425
|
+
PENDING_STARTS.set(serverKey, childReady);
|
|
3426
|
+
try {
|
|
3427
|
+
await new Promise((resolve, reject) => {
|
|
3428
|
+
let resolved = false;
|
|
3429
|
+
const { pythonPath: systemPython } = getLatestPythonVersion(meta);
|
|
3430
|
+
let pythonCmd = systemPython;
|
|
3431
|
+
const venv = isInVirtualEnv();
|
|
3432
|
+
if (venv) {
|
|
3433
|
+
(0, import_build_utils4.debug)(`Running in virtualenv at ${venv}`);
|
|
3434
|
+
} else {
|
|
3435
|
+
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
3436
|
+
workPath,
|
|
3437
|
+
env,
|
|
3438
|
+
systemPython
|
|
3439
|
+
);
|
|
3440
|
+
pythonCmd = venvPythonCmd;
|
|
3441
|
+
if (venvRoot) {
|
|
3442
|
+
(0, import_build_utils4.debug)(`Using virtualenv at ${venvRoot}`);
|
|
3443
|
+
} else {
|
|
3444
|
+
(0, import_build_utils4.debug)("No virtualenv found");
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
const devShimModule = createDevStaticShim(workPath, modulePath);
|
|
3448
|
+
if (devShimModule) {
|
|
3449
|
+
const vercelPythonDir = (0, import_path4.join)(workPath, ".vercel", "python");
|
|
3450
|
+
const existingPythonPath = env.PYTHONPATH || "";
|
|
3451
|
+
env.PYTHONPATH = existingPythonPath ? `${vercelPythonDir}:${existingPythonPath}` : vercelPythonDir;
|
|
3452
|
+
}
|
|
3453
|
+
detectAsgiServer(workPath, pythonCmd).then(async (serverKind) => {
|
|
3454
|
+
if (resolved)
|
|
3455
|
+
return;
|
|
3456
|
+
const host = "127.0.0.1";
|
|
3457
|
+
const argv = serverKind === "uvicorn" ? [
|
|
3458
|
+
"-u",
|
|
3459
|
+
"-m",
|
|
3460
|
+
"uvicorn",
|
|
3461
|
+
`${devShimModule || modulePath}:app`,
|
|
3462
|
+
"--host",
|
|
3463
|
+
host,
|
|
3464
|
+
"--port",
|
|
3465
|
+
"0",
|
|
3466
|
+
"--use-colors"
|
|
3467
|
+
] : [
|
|
3468
|
+
"-u",
|
|
3469
|
+
"-m",
|
|
3470
|
+
"hypercorn",
|
|
3471
|
+
`${devShimModule || modulePath}:app`,
|
|
3472
|
+
"-b",
|
|
3473
|
+
`${host}:0`
|
|
3474
|
+
];
|
|
3475
|
+
(0, import_build_utils4.debug)(
|
|
3476
|
+
`Starting dev server (${serverKind}): ${pythonCmd} ${argv.join(" ")}`
|
|
3477
|
+
);
|
|
3478
|
+
const child = (0, import_child_process2.spawn)(pythonCmd, argv, {
|
|
3479
|
+
cwd: workPath,
|
|
3480
|
+
env,
|
|
3481
|
+
stdio: ["inherit", "pipe", "pipe"]
|
|
3482
|
+
});
|
|
3483
|
+
childProcess = child;
|
|
3484
|
+
stdoutLogListener = (buf) => {
|
|
3485
|
+
const s = buf.toString();
|
|
3486
|
+
for (const line of s.split(/\r?\n/)) {
|
|
3487
|
+
if (line) {
|
|
3488
|
+
process.stdout.write(line.endsWith("\n") ? line : line + "\n");
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
};
|
|
3492
|
+
stderrLogListener = (buf) => {
|
|
3493
|
+
const s = buf.toString();
|
|
3494
|
+
for (const line of s.split(/\r?\n/)) {
|
|
3495
|
+
if (line) {
|
|
3496
|
+
process.stderr.write(line.endsWith("\n") ? line : line + "\n");
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
};
|
|
3500
|
+
child.stdout?.on("data", stdoutLogListener);
|
|
3501
|
+
child.stderr?.on("data", stderrLogListener);
|
|
3502
|
+
const readinessRegexes = [
|
|
3503
|
+
/Uvicorn running on https?:\/\/(?:\[[^\]]+\]|[^:]+):(\d+)/i,
|
|
3504
|
+
/Hypercorn running on https?:\/\/(?:\[[^\]]+\]|[^:]+):(\d+)/i,
|
|
3505
|
+
/(?:Running|Serving) on https?:\/\/(?:\[[^\]]+\]|[^:\s]+):(\d+)/i
|
|
3506
|
+
];
|
|
3507
|
+
const onDetect = (chunk) => {
|
|
3508
|
+
const text = chunk.toString();
|
|
3509
|
+
const clean = stripAnsi(text);
|
|
3510
|
+
let portMatch = null;
|
|
3511
|
+
for (const rx of readinessRegexes) {
|
|
3512
|
+
const m = clean.match(rx);
|
|
3513
|
+
if (m) {
|
|
3514
|
+
portMatch = m;
|
|
3515
|
+
break;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
if (portMatch && child.pid) {
|
|
3519
|
+
if (!resolved) {
|
|
3520
|
+
resolved = true;
|
|
3521
|
+
child.stdout?.removeListener("data", onDetect);
|
|
3522
|
+
child.stderr?.removeListener("data", onDetect);
|
|
3523
|
+
const port2 = Number(portMatch[1]);
|
|
3524
|
+
resolveChildReady({ port: port2, pid: child.pid });
|
|
3525
|
+
resolve();
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
};
|
|
3529
|
+
child.stdout?.on("data", onDetect);
|
|
3530
|
+
child.stderr?.on("data", onDetect);
|
|
3531
|
+
child.once("error", (err) => {
|
|
3532
|
+
if (!resolved) {
|
|
3533
|
+
rejectChildReady(err);
|
|
3534
|
+
reject(err);
|
|
3535
|
+
}
|
|
3536
|
+
});
|
|
3537
|
+
child.once("exit", (code, signal) => {
|
|
3538
|
+
if (!resolved) {
|
|
3539
|
+
const err = new Error(
|
|
3540
|
+
`${serverKind} server exited before binding (code=${code}, signal=${signal})`
|
|
3541
|
+
);
|
|
3542
|
+
rejectChildReady(err);
|
|
3543
|
+
reject(err);
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
}).catch((err) => {
|
|
3547
|
+
rejectChildReady(err);
|
|
3548
|
+
reject(err);
|
|
3549
|
+
});
|
|
3550
|
+
});
|
|
3551
|
+
const { port, pid } = await childReady;
|
|
3552
|
+
PERSISTENT_SERVERS.set(serverKey, {
|
|
3553
|
+
port,
|
|
3554
|
+
pid,
|
|
3555
|
+
child: childProcess,
|
|
3556
|
+
stdoutLogListener,
|
|
3557
|
+
stderrLogListener
|
|
3558
|
+
});
|
|
3559
|
+
const shutdown = async () => {
|
|
3560
|
+
};
|
|
3561
|
+
return { port, pid, shutdown };
|
|
3562
|
+
} finally {
|
|
3563
|
+
PENDING_STARTS.delete(serverKey);
|
|
3564
|
+
}
|
|
3565
|
+
};
|
|
3566
|
+
|
|
3567
|
+
// src/index.ts
|
|
3568
|
+
var readFile = (0, import_util.promisify)(import_fs5.default.readFile);
|
|
3569
|
+
var writeFile = (0, import_util.promisify)(import_fs5.default.writeFile);
|
|
3001
3570
|
var version = 3;
|
|
3571
|
+
function findDir({
|
|
3572
|
+
file,
|
|
3573
|
+
entryDirectory,
|
|
3574
|
+
workPath,
|
|
3575
|
+
fsFiles
|
|
3576
|
+
}) {
|
|
3577
|
+
if (fsFiles[(0, import_path5.join)(entryDirectory, file)]) {
|
|
3578
|
+
return (0, import_path5.join)(workPath, entryDirectory);
|
|
3579
|
+
}
|
|
3580
|
+
if (fsFiles[file]) {
|
|
3581
|
+
return workPath;
|
|
3582
|
+
}
|
|
3583
|
+
return null;
|
|
3584
|
+
}
|
|
3002
3585
|
async function downloadFilesInWorkPath({
|
|
3003
3586
|
entrypoint,
|
|
3004
3587
|
workPath,
|
|
3005
3588
|
files,
|
|
3006
3589
|
meta = {}
|
|
3007
3590
|
}) {
|
|
3008
|
-
(0,
|
|
3009
|
-
let downloadedFiles = await (0,
|
|
3591
|
+
(0, import_build_utils5.debug)("Downloading user files...");
|
|
3592
|
+
let downloadedFiles = await (0, import_build_utils5.download)(files, workPath, meta);
|
|
3010
3593
|
if (meta.isDev) {
|
|
3011
|
-
const { devCacheDir = (0,
|
|
3012
|
-
const destCache = (0,
|
|
3013
|
-
await (0,
|
|
3014
|
-
downloadedFiles = await (0,
|
|
3594
|
+
const { devCacheDir = (0, import_path5.join)(workPath, ".now", "cache") } = meta;
|
|
3595
|
+
const destCache = (0, import_path5.join)(devCacheDir, (0, import_path5.basename)(entrypoint, ".py"));
|
|
3596
|
+
await (0, import_build_utils5.download)(downloadedFiles, destCache);
|
|
3597
|
+
downloadedFiles = await (0, import_build_utils5.glob)("**", destCache);
|
|
3015
3598
|
workPath = destCache;
|
|
3016
3599
|
}
|
|
3017
3600
|
return workPath;
|
|
@@ -3032,98 +3615,83 @@ var build = async ({
|
|
|
3032
3615
|
});
|
|
3033
3616
|
try {
|
|
3034
3617
|
if (meta.isDev) {
|
|
3035
|
-
const setupCfg = (0,
|
|
3618
|
+
const setupCfg = (0, import_path5.join)(workPath, "setup.cfg");
|
|
3036
3619
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
3037
3620
|
}
|
|
3038
3621
|
} catch (err) {
|
|
3039
3622
|
console.log('Failed to create "setup.cfg" file');
|
|
3040
3623
|
throw err;
|
|
3041
3624
|
}
|
|
3042
|
-
let fsFiles = await (0,
|
|
3043
|
-
if (!fsFiles[entrypoint]) {
|
|
3044
|
-
|
|
3045
|
-
if (
|
|
3046
|
-
|
|
3047
|
-
(
|
|
3625
|
+
let fsFiles = await (0, import_build_utils5.glob)("**", workPath);
|
|
3626
|
+
if (!fsFiles[entrypoint] && config?.framework === "fastapi") {
|
|
3627
|
+
const detected = await detectFastapiEntrypoint(workPath, entrypoint);
|
|
3628
|
+
if (detected) {
|
|
3629
|
+
(0, import_build_utils5.debug)(
|
|
3630
|
+
`Resolved Python entrypoint to "${detected}" (configured "${entrypoint}" not found).`
|
|
3048
3631
|
);
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
discovered = fastapiEntrypoint || entrypointCandidates[0];
|
|
3054
|
-
}
|
|
3055
|
-
}
|
|
3056
|
-
if (discovered) {
|
|
3057
|
-
(0, import_build_utils3.debug)(
|
|
3058
|
-
`Resolved Python entrypoint to "${discovered}" (configured "${entrypoint}" not found).`
|
|
3059
|
-
);
|
|
3060
|
-
entrypoint = discovered;
|
|
3061
|
-
} else if (config?.framework === "fastapi") {
|
|
3062
|
-
const searchedList = fastapiCandidateEntrypoints.join(", ");
|
|
3063
|
-
throw new import_build_utils3.NowBuildError({
|
|
3632
|
+
entrypoint = detected;
|
|
3633
|
+
} else {
|
|
3634
|
+
const searchedList = FASTAPI_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
3635
|
+
throw new import_build_utils5.NowBuildError({
|
|
3064
3636
|
code: "FASTAPI_ENTRYPOINT_NOT_FOUND",
|
|
3065
3637
|
message: `No FastAPI entrypoint found. Searched for: ${searchedList}`
|
|
3066
3638
|
});
|
|
3067
3639
|
}
|
|
3068
3640
|
}
|
|
3069
|
-
const entryDirectory = (0,
|
|
3070
|
-
const hasReqLocal = !!fsFiles[(0,
|
|
3641
|
+
const entryDirectory = (0, import_path5.dirname)(entrypoint);
|
|
3642
|
+
const hasReqLocal = !!fsFiles[(0, import_path5.join)(entryDirectory, "requirements.txt")];
|
|
3071
3643
|
const hasReqGlobal = !!fsFiles["requirements.txt"];
|
|
3072
|
-
const
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3644
|
+
const uvLockDir = findDir({
|
|
3645
|
+
file: "uv.lock",
|
|
3646
|
+
entryDirectory,
|
|
3647
|
+
workPath,
|
|
3648
|
+
fsFiles
|
|
3649
|
+
});
|
|
3650
|
+
const pyprojectDir = findDir({
|
|
3651
|
+
file: "pyproject.toml",
|
|
3652
|
+
entryDirectory,
|
|
3653
|
+
workPath,
|
|
3654
|
+
fsFiles
|
|
3655
|
+
});
|
|
3656
|
+
const pipfileLockDir = fsFiles[(0, import_path5.join)(entryDirectory, "Pipfile.lock")] ? (0, import_path5.join)(workPath, entryDirectory) : fsFiles["Pipfile.lock"] ? workPath : null;
|
|
3657
|
+
const pipfileDir = fsFiles[(0, import_path5.join)(entryDirectory, "Pipfile")] ? (0, import_path5.join)(workPath, entryDirectory) : fsFiles["Pipfile"] ? workPath : null;
|
|
3658
|
+
if (pyprojectDir) {
|
|
3659
|
+
let requiresPython;
|
|
3660
|
+
try {
|
|
3661
|
+
const pyproject = await (0, import_build_utils6.readConfigFile)((0, import_path5.join)(pyprojectDir, "pyproject.toml"));
|
|
3662
|
+
requiresPython = pyproject?.project?.["requires-python"];
|
|
3663
|
+
} catch {
|
|
3664
|
+
(0, import_build_utils5.debug)("Failed to parse pyproject.toml");
|
|
3665
|
+
}
|
|
3666
|
+
const VERSION_REGEX = /\b\d+\.\d+\b/;
|
|
3667
|
+
const exact = requiresPython?.trim().match(VERSION_REGEX)?.[0];
|
|
3668
|
+
if (exact) {
|
|
3669
|
+
const selected = getSupportedPythonVersion({
|
|
3095
3670
|
isDev: meta.isDev,
|
|
3096
|
-
|
|
3671
|
+
declaredPythonVersion: { version: exact, source: "pyproject.toml" }
|
|
3097
3672
|
});
|
|
3673
|
+
pythonVersion = selected;
|
|
3098
3674
|
}
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
args: ["--no-warn-script-location"]
|
|
3675
|
+
} else if (pipfileLockDir) {
|
|
3676
|
+
let lock = {};
|
|
3677
|
+
try {
|
|
3678
|
+
const json = await readFile((0, import_path5.join)(pipfileLockDir, "Pipfile.lock"), "utf8");
|
|
3679
|
+
lock = JSON.parse(json);
|
|
3680
|
+
} catch (err) {
|
|
3681
|
+
throw new import_build_utils5.NowBuildError({
|
|
3682
|
+
code: "INVALID_PIPFILE_LOCK",
|
|
3683
|
+
message: "Unable to parse Pipfile.lock"
|
|
3109
3684
|
});
|
|
3110
|
-
const tempVendorDir = (0, import_path2.join)(tempDir, resolveVendorDir());
|
|
3111
|
-
const envForConvert = { ...process.env, PYTHONPATH: tempVendorDir };
|
|
3112
|
-
const convertCmd = process.platform === "win32" ? (0, import_path2.join)(tempVendorDir, "Scripts", "pipfile2req.exe") : (0, import_path2.join)(tempVendorDir, "bin", "pipfile2req");
|
|
3113
|
-
await pipenvConvert(
|
|
3114
|
-
convertCmd,
|
|
3115
|
-
pipfileLockDir || pipfileDir,
|
|
3116
|
-
envForConvert
|
|
3117
|
-
);
|
|
3118
|
-
} else {
|
|
3119
|
-
(0, import_build_utils3.debug)(
|
|
3120
|
-
'Skipping Pipfile.lock conversion because "requirements.txt" exists'
|
|
3121
|
-
);
|
|
3122
3685
|
}
|
|
3686
|
+
const pyFromLock = lock?._meta?.requires?.python_version;
|
|
3687
|
+
pythonVersion = getSupportedPythonVersion({
|
|
3688
|
+
isDev: meta.isDev,
|
|
3689
|
+
declaredPythonVersion: pyFromLock ? { version: pyFromLock, source: "Pipfile.lock" } : void 0
|
|
3690
|
+
});
|
|
3123
3691
|
}
|
|
3124
|
-
fsFiles = await (0,
|
|
3125
|
-
const requirementsTxt = (0,
|
|
3126
|
-
const vendorBaseDir = (0,
|
|
3692
|
+
fsFiles = await (0, import_build_utils5.glob)("**", workPath);
|
|
3693
|
+
const requirementsTxt = (0, import_path5.join)(entryDirectory, "requirements.txt");
|
|
3694
|
+
const vendorBaseDir = (0, import_path5.join)(
|
|
3127
3695
|
workPath,
|
|
3128
3696
|
".vercel",
|
|
3129
3697
|
"python",
|
|
@@ -3131,7 +3699,7 @@ var build = async ({
|
|
|
3131
3699
|
entryDirectory
|
|
3132
3700
|
);
|
|
3133
3701
|
try {
|
|
3134
|
-
await
|
|
3702
|
+
await import_fs5.default.promises.mkdir(vendorBaseDir, { recursive: true });
|
|
3135
3703
|
} catch (err) {
|
|
3136
3704
|
console.log("Failed to create vendor cache directory");
|
|
3137
3705
|
throw err;
|
|
@@ -3142,38 +3710,105 @@ var build = async ({
|
|
|
3142
3710
|
pipPath: pythonVersion.pipPath,
|
|
3143
3711
|
dependency: "werkzeug",
|
|
3144
3712
|
version: "1.0.1",
|
|
3145
|
-
workPath
|
|
3713
|
+
workPath,
|
|
3714
|
+
targetDir: vendorBaseDir,
|
|
3146
3715
|
meta
|
|
3147
3716
|
});
|
|
3148
|
-
|
|
3149
|
-
|
|
3717
|
+
let installedFromProjectFiles = false;
|
|
3718
|
+
if (uvLockDir) {
|
|
3719
|
+
(0, import_build_utils5.debug)('Found "uv.lock"');
|
|
3720
|
+
if (pyprojectDir) {
|
|
3721
|
+
const exportedReq = await exportRequirementsFromUv(
|
|
3722
|
+
pythonVersion.pythonPath,
|
|
3723
|
+
pyprojectDir,
|
|
3724
|
+
{ locked: true }
|
|
3725
|
+
);
|
|
3726
|
+
await installRequirementsFile({
|
|
3727
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3728
|
+
pipPath: pythonVersion.pipPath,
|
|
3729
|
+
filePath: exportedReq,
|
|
3730
|
+
workPath,
|
|
3731
|
+
targetDir: vendorBaseDir,
|
|
3732
|
+
meta
|
|
3733
|
+
});
|
|
3734
|
+
installedFromProjectFiles = true;
|
|
3735
|
+
} else {
|
|
3736
|
+
(0, import_build_utils5.debug)('Skipping uv export because "pyproject.toml" was not found');
|
|
3737
|
+
}
|
|
3738
|
+
} else if (pyprojectDir) {
|
|
3739
|
+
(0, import_build_utils5.debug)('Found "pyproject.toml"');
|
|
3740
|
+
if (hasReqLocal || hasReqGlobal) {
|
|
3741
|
+
console.log(
|
|
3742
|
+
"Detected both pyproject.toml and requirements.txt but no lockfile; using pyproject.toml"
|
|
3743
|
+
);
|
|
3744
|
+
}
|
|
3745
|
+
const exportedReq = await exportRequirementsFromUv(
|
|
3746
|
+
pythonVersion.pythonPath,
|
|
3747
|
+
pyprojectDir,
|
|
3748
|
+
{ locked: false }
|
|
3749
|
+
);
|
|
3750
|
+
await installRequirementsFile({
|
|
3751
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3752
|
+
pipPath: pythonVersion.pipPath,
|
|
3753
|
+
filePath: exportedReq,
|
|
3754
|
+
workPath,
|
|
3755
|
+
targetDir: vendorBaseDir,
|
|
3756
|
+
meta
|
|
3757
|
+
});
|
|
3758
|
+
installedFromProjectFiles = true;
|
|
3759
|
+
} else if (pipfileLockDir || pipfileDir) {
|
|
3760
|
+
(0, import_build_utils5.debug)(`Found ${pipfileLockDir ? '"Pipfile.lock"' : '"Pipfile"'}`);
|
|
3761
|
+
if (hasReqLocal || hasReqGlobal) {
|
|
3762
|
+
(0, import_build_utils5.debug)('Skipping Pipfile export because "requirements.txt" exists');
|
|
3763
|
+
} else {
|
|
3764
|
+
const exportedReq = await exportRequirementsFromPipfile({
|
|
3765
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3766
|
+
pipPath: pythonVersion.pipPath,
|
|
3767
|
+
projectDir: pipfileLockDir || pipfileDir,
|
|
3768
|
+
meta
|
|
3769
|
+
});
|
|
3770
|
+
await installRequirementsFile({
|
|
3771
|
+
pythonPath: pythonVersion.pythonPath,
|
|
3772
|
+
pipPath: pythonVersion.pipPath,
|
|
3773
|
+
filePath: exportedReq,
|
|
3774
|
+
workPath,
|
|
3775
|
+
targetDir: vendorBaseDir,
|
|
3776
|
+
meta
|
|
3777
|
+
});
|
|
3778
|
+
installedFromProjectFiles = true;
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
if (!installedFromProjectFiles && fsFiles[requirementsTxt]) {
|
|
3782
|
+
(0, import_build_utils5.debug)('Found local "requirements.txt"');
|
|
3150
3783
|
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
|
|
3151
3784
|
await installRequirementsFile({
|
|
3152
3785
|
pythonPath: pythonVersion.pythonPath,
|
|
3153
3786
|
pipPath: pythonVersion.pipPath,
|
|
3154
3787
|
filePath: requirementsTxtPath,
|
|
3155
|
-
workPath
|
|
3788
|
+
workPath,
|
|
3789
|
+
targetDir: vendorBaseDir,
|
|
3156
3790
|
meta
|
|
3157
3791
|
});
|
|
3158
|
-
} else if (fsFiles["requirements.txt"]) {
|
|
3159
|
-
(0,
|
|
3792
|
+
} else if (!installedFromProjectFiles && fsFiles["requirements.txt"]) {
|
|
3793
|
+
(0, import_build_utils5.debug)('Found global "requirements.txt"');
|
|
3160
3794
|
const requirementsTxtPath = fsFiles["requirements.txt"].fsPath;
|
|
3161
3795
|
await installRequirementsFile({
|
|
3162
3796
|
pythonPath: pythonVersion.pythonPath,
|
|
3163
3797
|
pipPath: pythonVersion.pipPath,
|
|
3164
3798
|
filePath: requirementsTxtPath,
|
|
3165
|
-
workPath
|
|
3799
|
+
workPath,
|
|
3800
|
+
targetDir: vendorBaseDir,
|
|
3166
3801
|
meta
|
|
3167
3802
|
});
|
|
3168
3803
|
}
|
|
3169
|
-
const originalPyPath = (0,
|
|
3804
|
+
const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
|
|
3170
3805
|
const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
|
|
3171
|
-
(0,
|
|
3172
|
-
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py
|
|
3806
|
+
(0, import_build_utils5.debug)("Entrypoint is", entrypoint);
|
|
3807
|
+
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
|
|
3173
3808
|
const vendorDir = resolveVendorDir();
|
|
3174
3809
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
3175
3810
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
3176
|
-
(0,
|
|
3811
|
+
(0, import_build_utils5.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
3177
3812
|
const handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix).replace(/__VC_HANDLER_VENDOR_DIR/g, vendorDir);
|
|
3178
3813
|
const predefinedExcludes = [
|
|
3179
3814
|
".git/**",
|
|
@@ -3185,7 +3820,8 @@ var build = async ({
|
|
|
3185
3820
|
"**/.nuxt/**",
|
|
3186
3821
|
"**/.venv/**",
|
|
3187
3822
|
"**/venv/**",
|
|
3188
|
-
"**/__pycache__/**"
|
|
3823
|
+
"**/__pycache__/**",
|
|
3824
|
+
"**/public/**"
|
|
3189
3825
|
];
|
|
3190
3826
|
const lambdaEnv = {};
|
|
3191
3827
|
lambdaEnv.PYTHONPATH = vendorDir;
|
|
@@ -3193,11 +3829,11 @@ var build = async ({
|
|
|
3193
3829
|
cwd: workPath,
|
|
3194
3830
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
3195
3831
|
};
|
|
3196
|
-
const files = await (0,
|
|
3832
|
+
const files = await (0, import_build_utils5.glob)("**", globOptions);
|
|
3197
3833
|
try {
|
|
3198
|
-
const cachedVendorAbs = (0,
|
|
3199
|
-
if (
|
|
3200
|
-
const vendorFiles = await (0,
|
|
3834
|
+
const cachedVendorAbs = (0, import_path5.join)(vendorBaseDir, resolveVendorDir());
|
|
3835
|
+
if (import_fs5.default.existsSync(cachedVendorAbs)) {
|
|
3836
|
+
const vendorFiles = await (0, import_build_utils5.glob)("**", cachedVendorAbs, resolveVendorDir());
|
|
3201
3837
|
for (const [p, f] of Object.entries(vendorFiles)) {
|
|
3202
3838
|
files[p] = f;
|
|
3203
3839
|
}
|
|
@@ -3207,12 +3843,12 @@ var build = async ({
|
|
|
3207
3843
|
throw err;
|
|
3208
3844
|
}
|
|
3209
3845
|
const handlerPyFilename = "vc__handler__python";
|
|
3210
|
-
files[`${handlerPyFilename}.py`] = new
|
|
3846
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils5.FileBlob({ data: handlerPyContents });
|
|
3211
3847
|
if (config.framework === "fasthtml") {
|
|
3212
3848
|
const { SESSKEY = "" } = process.env;
|
|
3213
|
-
files[".sesskey"] = new
|
|
3849
|
+
files[".sesskey"] = new import_build_utils5.FileBlob({ data: `"${SESSKEY}"` });
|
|
3214
3850
|
}
|
|
3215
|
-
const output = new
|
|
3851
|
+
const output = new import_build_utils5.Lambda({
|
|
3216
3852
|
files,
|
|
3217
3853
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
3218
3854
|
runtime: pythonVersion.runtime,
|
|
@@ -3221,12 +3857,44 @@ var build = async ({
|
|
|
3221
3857
|
});
|
|
3222
3858
|
return { output };
|
|
3223
3859
|
};
|
|
3860
|
+
var shouldServe = (opts) => {
|
|
3861
|
+
const framework = opts.config.framework;
|
|
3862
|
+
if (framework === "fastapi") {
|
|
3863
|
+
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
3864
|
+
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
3865
|
+
return false;
|
|
3866
|
+
}
|
|
3867
|
+
return true;
|
|
3868
|
+
}
|
|
3869
|
+
return defaultShouldServe(opts);
|
|
3870
|
+
};
|
|
3871
|
+
var defaultShouldServe = ({
|
|
3872
|
+
entrypoint,
|
|
3873
|
+
files,
|
|
3874
|
+
requestPath
|
|
3875
|
+
}) => {
|
|
3876
|
+
requestPath = requestPath.replace(/\/$/, "");
|
|
3877
|
+
entrypoint = entrypoint.replace(/\\/g, "/");
|
|
3878
|
+
if (entrypoint === requestPath && hasProp(files, entrypoint)) {
|
|
3879
|
+
return true;
|
|
3880
|
+
}
|
|
3881
|
+
const { dir, name } = (0, import_path5.parse)(entrypoint);
|
|
3882
|
+
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
|
|
3883
|
+
return true;
|
|
3884
|
+
}
|
|
3885
|
+
return false;
|
|
3886
|
+
};
|
|
3887
|
+
function hasProp(obj, key) {
|
|
3888
|
+
return Object.hasOwnProperty.call(obj, key);
|
|
3889
|
+
}
|
|
3224
3890
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3225
3891
|
0 && (module.exports = {
|
|
3226
3892
|
build,
|
|
3893
|
+
defaultShouldServe,
|
|
3227
3894
|
downloadFilesInWorkPath,
|
|
3228
3895
|
installRequirement,
|
|
3229
3896
|
installRequirementsFile,
|
|
3230
3897
|
shouldServe,
|
|
3898
|
+
startDevServer,
|
|
3231
3899
|
version
|
|
3232
3900
|
});
|