@vercel/python 5.0.5 → 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 +742 -217
- 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();
|
|
@@ -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
|
});
|
|
@@ -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
|
|
|
@@ -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);
|
|
@@ -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,7 +2680,7 @@ var require_lib = __commonJS({
|
|
|
2680
2680
|
var getPathPart = (raw, cmd) => {
|
|
2681
2681
|
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2682
2682
|
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2683
|
-
return prefix +
|
|
2683
|
+
return prefix + join5(pathPart, cmd);
|
|
2684
2684
|
};
|
|
2685
2685
|
var which3 = async (cmd, opt = {}) => {
|
|
2686
2686
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
@@ -2739,18 +2739,19 @@ 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());
|
|
@@ -2835,8 +2836,8 @@ async function getUserScriptsDir(pythonPath) {
|
|
|
2835
2836
|
return null;
|
|
2836
2837
|
}
|
|
2837
2838
|
}
|
|
2838
|
-
async function pipInstall(pipPath, pythonPath, workPath, args) {
|
|
2839
|
-
const target = resolveVendorDir();
|
|
2839
|
+
async function pipInstall(pipPath, pythonPath, workPath, args, targetDir) {
|
|
2840
|
+
const target = targetDir ? (0, import_path.join)(targetDir, resolveVendorDir()) : resolveVendorDir();
|
|
2840
2841
|
process.env.PIP_USER = "0";
|
|
2841
2842
|
let uvBin = null;
|
|
2842
2843
|
try {
|
|
@@ -2863,6 +2864,7 @@ async function pipInstall(pipPath, pythonPath, workPath, args) {
|
|
|
2863
2864
|
return;
|
|
2864
2865
|
} catch (err) {
|
|
2865
2866
|
console.log(`Failed to run "${prettyUv}", falling back to pip`);
|
|
2867
|
+
(0, import_build_utils.debug)(`error: ${err}`);
|
|
2866
2868
|
}
|
|
2867
2869
|
}
|
|
2868
2870
|
const cmdArgs = [
|
|
@@ -2882,11 +2884,12 @@ async function pipInstall(pipPath, pythonPath, workPath, args) {
|
|
|
2882
2884
|
});
|
|
2883
2885
|
} catch (err) {
|
|
2884
2886
|
console.log(`Failed to run "${pretty}"`);
|
|
2887
|
+
(0, import_build_utils.debug)(`error: ${err}`);
|
|
2885
2888
|
throw err;
|
|
2886
2889
|
}
|
|
2887
2890
|
}
|
|
2888
2891
|
async function maybeFindUvBin(pythonPath) {
|
|
2889
|
-
const found = import_which.default.sync(
|
|
2892
|
+
const found = import_which.default.sync("uv", { nothrow: true });
|
|
2890
2893
|
if (found)
|
|
2891
2894
|
return found;
|
|
2892
2895
|
try {
|
|
@@ -2897,10 +2900,7 @@ async function maybeFindUvBin(pythonPath) {
|
|
|
2897
2900
|
return uvPath;
|
|
2898
2901
|
}
|
|
2899
2902
|
} catch (err) {
|
|
2900
|
-
(0, import_build_utils.debug)(
|
|
2901
|
-
"Failed to resolve uv from interpreter's global scripts directory",
|
|
2902
|
-
err
|
|
2903
|
-
);
|
|
2903
|
+
(0, import_build_utils.debug)("Failed to resolve Python global scripts directory", err);
|
|
2904
2904
|
}
|
|
2905
2905
|
try {
|
|
2906
2906
|
const userScriptsDir = await getUserScriptsDir(pythonPath);
|
|
@@ -2910,10 +2910,7 @@ async function maybeFindUvBin(pythonPath) {
|
|
|
2910
2910
|
return uvPath;
|
|
2911
2911
|
}
|
|
2912
2912
|
} catch (err) {
|
|
2913
|
-
(0, import_build_utils.debug)(
|
|
2914
|
-
"Failed to resolve uv from interpreter's user scripts directory",
|
|
2915
|
-
err
|
|
2916
|
-
);
|
|
2913
|
+
(0, import_build_utils.debug)("Failed to resolve Python user scripts directory", err);
|
|
2917
2914
|
}
|
|
2918
2915
|
try {
|
|
2919
2916
|
const candidates = [];
|
|
@@ -2972,38 +2969,107 @@ async function installRequirement({
|
|
|
2972
2969
|
dependency,
|
|
2973
2970
|
version: version2,
|
|
2974
2971
|
workPath,
|
|
2972
|
+
targetDir,
|
|
2975
2973
|
meta,
|
|
2976
2974
|
args = []
|
|
2977
2975
|
}) {
|
|
2978
|
-
|
|
2976
|
+
const actualTargetDir = targetDir || workPath;
|
|
2977
|
+
if (meta.isDev && await isInstalled(pythonPath, dependency, actualTargetDir)) {
|
|
2979
2978
|
(0, import_build_utils.debug)(
|
|
2980
|
-
`Skipping ${dependency} dependency installation, already installed in ${
|
|
2979
|
+
`Skipping ${dependency} dependency installation, already installed in ${actualTargetDir}`
|
|
2981
2980
|
);
|
|
2982
2981
|
return;
|
|
2983
2982
|
}
|
|
2984
2983
|
const exact = `${dependency}==${version2}`;
|
|
2985
|
-
await pipInstall(pipPath, pythonPath, workPath, [exact, ...args]);
|
|
2984
|
+
await pipInstall(pipPath, pythonPath, workPath, [exact, ...args], targetDir);
|
|
2986
2985
|
}
|
|
2987
2986
|
async function installRequirementsFile({
|
|
2988
2987
|
pythonPath,
|
|
2989
2988
|
pipPath,
|
|
2990
2989
|
filePath,
|
|
2991
2990
|
workPath,
|
|
2991
|
+
targetDir,
|
|
2992
2992
|
meta,
|
|
2993
2993
|
args = []
|
|
2994
2994
|
}) {
|
|
2995
|
-
|
|
2995
|
+
const actualTargetDir = targetDir || workPath;
|
|
2996
|
+
if (meta.isDev && await areRequirementsInstalled(pythonPath, filePath, actualTargetDir)) {
|
|
2996
2997
|
(0, import_build_utils.debug)(`Skipping requirements file installation, already installed`);
|
|
2997
2998
|
return;
|
|
2998
2999
|
}
|
|
2999
|
-
await pipInstall(
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
...args
|
|
3004
|
-
|
|
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;
|
|
3005
3068
|
}
|
|
3006
3069
|
|
|
3070
|
+
// src/index.ts
|
|
3071
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
3072
|
+
|
|
3007
3073
|
// src/version.ts
|
|
3008
3074
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
3009
3075
|
var import_which2 = __toESM(require_lib());
|
|
@@ -3066,21 +3132,33 @@ function getLatestPythonVersion({
|
|
|
3066
3132
|
}
|
|
3067
3133
|
function getSupportedPythonVersion({
|
|
3068
3134
|
isDev,
|
|
3069
|
-
|
|
3135
|
+
declaredPythonVersion
|
|
3070
3136
|
}) {
|
|
3071
3137
|
if (isDev) {
|
|
3072
3138
|
return getDevPythonVersion();
|
|
3073
3139
|
}
|
|
3074
3140
|
let selection = getLatestPythonVersion({ isDev: false });
|
|
3075
|
-
if (
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3078
|
-
)
|
|
3079
|
-
|
|
3080
|
-
|
|
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
|
+
}
|
|
3081
3159
|
} else {
|
|
3082
3160
|
console.warn(
|
|
3083
|
-
`Warning: Python version "${
|
|
3161
|
+
`Warning: Python version "${version2}" detected in ${source} is invalid and will be ignored. http://vercel.link/python-version`
|
|
3084
3162
|
);
|
|
3085
3163
|
}
|
|
3086
3164
|
}
|
|
@@ -3088,13 +3166,14 @@ function getSupportedPythonVersion({
|
|
|
3088
3166
|
throw new import_build_utils2.NowBuildError({
|
|
3089
3167
|
code: "BUILD_UTILS_PYTHON_VERSION_DISCONTINUED",
|
|
3090
3168
|
link: "http://vercel.link/python-version",
|
|
3091
|
-
message: `Python version "${selection.version}"
|
|
3169
|
+
message: `Python version "${selection.version}" declared in project configuration is discontinued and must be upgraded.`
|
|
3092
3170
|
});
|
|
3093
3171
|
}
|
|
3094
3172
|
if (selection.discontinueDate) {
|
|
3095
3173
|
const d = selection.discontinueDate.toISOString().split("T")[0];
|
|
3174
|
+
const srcSuffix = declaredPythonVersion ? `detected in ${declaredPythonVersion.source}` : "selected by runtime";
|
|
3096
3175
|
console.warn(
|
|
3097
|
-
`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`
|
|
3098
3177
|
);
|
|
3099
3178
|
}
|
|
3100
3179
|
return selection;
|
|
@@ -3107,14 +3186,23 @@ function isInstalled2({ pipPath, pythonPath }) {
|
|
|
3107
3186
|
return Boolean(import_which2.default.sync(pipPath, { nothrow: true })) && Boolean(import_which2.default.sync(pythonPath, { nothrow: true }));
|
|
3108
3187
|
}
|
|
3109
3188
|
|
|
3110
|
-
// src/
|
|
3111
|
-
var
|
|
3112
|
-
var
|
|
3113
|
-
var
|
|
3114
|
-
var
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
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
|
+
)
|
|
3118
3206
|
);
|
|
3119
3207
|
function isFastapiEntrypoint(file) {
|
|
3120
3208
|
try {
|
|
@@ -3122,39 +3210,391 @@ function isFastapiEntrypoint(file) {
|
|
|
3122
3210
|
if (!fsPath)
|
|
3123
3211
|
return false;
|
|
3124
3212
|
const contents = import_fs2.default.readFileSync(fsPath, "utf8");
|
|
3125
|
-
return
|
|
3213
|
+
return FASTAPI_CONTENT_REGEX.test(contents);
|
|
3126
3214
|
} catch {
|
|
3127
3215
|
return false;
|
|
3128
3216
|
}
|
|
3129
3217
|
}
|
|
3130
|
-
async function
|
|
3131
|
-
|
|
3218
|
+
async function detectFastapiEntrypoint(workPath, configuredEntrypoint) {
|
|
3219
|
+
const entry = configuredEntrypoint.endsWith(".py") ? configuredEntrypoint : `${configuredEntrypoint}.py`;
|
|
3132
3220
|
try {
|
|
3133
|
-
const
|
|
3134
|
-
|
|
3135
|
-
|
|
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));
|
|
3136
3263
|
});
|
|
3137
|
-
|
|
3138
|
-
|
|
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;
|
|
3139
3370
|
} catch (err) {
|
|
3140
|
-
|
|
3141
|
-
|
|
3371
|
+
(0, import_build_utils4.debug)(`Failed to prepare dev static shim: ${err?.message || err}`);
|
|
3372
|
+
return null;
|
|
3142
3373
|
}
|
|
3143
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);
|
|
3144
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
|
+
}
|
|
3145
3585
|
async function downloadFilesInWorkPath({
|
|
3146
3586
|
entrypoint,
|
|
3147
3587
|
workPath,
|
|
3148
3588
|
files,
|
|
3149
3589
|
meta = {}
|
|
3150
3590
|
}) {
|
|
3151
|
-
(0,
|
|
3152
|
-
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);
|
|
3153
3593
|
if (meta.isDev) {
|
|
3154
|
-
const { devCacheDir = (0,
|
|
3155
|
-
const destCache = (0,
|
|
3156
|
-
await (0,
|
|
3157
|
-
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);
|
|
3158
3598
|
workPath = destCache;
|
|
3159
3599
|
}
|
|
3160
3600
|
return workPath;
|
|
@@ -3175,98 +3615,83 @@ var build = async ({
|
|
|
3175
3615
|
});
|
|
3176
3616
|
try {
|
|
3177
3617
|
if (meta.isDev) {
|
|
3178
|
-
const setupCfg = (0,
|
|
3618
|
+
const setupCfg = (0, import_path5.join)(workPath, "setup.cfg");
|
|
3179
3619
|
await writeFile(setupCfg, "[install]\nprefix=\n");
|
|
3180
3620
|
}
|
|
3181
3621
|
} catch (err) {
|
|
3182
3622
|
console.log('Failed to create "setup.cfg" file');
|
|
3183
3623
|
throw err;
|
|
3184
3624
|
}
|
|
3185
|
-
let fsFiles = await (0,
|
|
3186
|
-
if (!fsFiles[entrypoint]) {
|
|
3187
|
-
|
|
3188
|
-
if (
|
|
3189
|
-
|
|
3190
|
-
(
|
|
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).`
|
|
3191
3631
|
);
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
discovered = fastapiEntrypoint || entrypointCandidates[0];
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
if (discovered) {
|
|
3200
|
-
(0, import_build_utils3.debug)(
|
|
3201
|
-
`Resolved Python entrypoint to "${discovered}" (configured "${entrypoint}" not found).`
|
|
3202
|
-
);
|
|
3203
|
-
entrypoint = discovered;
|
|
3204
|
-
} else if (config?.framework === "fastapi") {
|
|
3205
|
-
const searchedList = fastapiCandidateEntrypoints.join(", ");
|
|
3206
|
-
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({
|
|
3207
3636
|
code: "FASTAPI_ENTRYPOINT_NOT_FOUND",
|
|
3208
3637
|
message: `No FastAPI entrypoint found. Searched for: ${searchedList}`
|
|
3209
3638
|
});
|
|
3210
3639
|
}
|
|
3211
3640
|
}
|
|
3212
|
-
const entryDirectory = (0,
|
|
3213
|
-
const hasReqLocal = !!fsFiles[(0,
|
|
3641
|
+
const entryDirectory = (0, import_path5.dirname)(entrypoint);
|
|
3642
|
+
const hasReqLocal = !!fsFiles[(0, import_path5.join)(entryDirectory, "requirements.txt")];
|
|
3214
3643
|
const hasReqGlobal = !!fsFiles["requirements.txt"];
|
|
3215
|
-
const
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
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({
|
|
3238
3670
|
isDev: meta.isDev,
|
|
3239
|
-
|
|
3671
|
+
declaredPythonVersion: { version: exact, source: "pyproject.toml" }
|
|
3240
3672
|
});
|
|
3673
|
+
pythonVersion = selected;
|
|
3241
3674
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
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"
|
|
3252
3684
|
});
|
|
3253
|
-
const tempVendorDir = (0, import_path2.join)(tempDir, resolveVendorDir());
|
|
3254
|
-
const envForConvert = { ...process.env, PYTHONPATH: tempVendorDir };
|
|
3255
|
-
const convertCmd = process.platform === "win32" ? (0, import_path2.join)(tempVendorDir, "Scripts", "pipfile2req.exe") : (0, import_path2.join)(tempVendorDir, "bin", "pipfile2req");
|
|
3256
|
-
await pipenvConvert(
|
|
3257
|
-
convertCmd,
|
|
3258
|
-
pipfileLockDir || pipfileDir,
|
|
3259
|
-
envForConvert
|
|
3260
|
-
);
|
|
3261
|
-
} else {
|
|
3262
|
-
(0, import_build_utils3.debug)(
|
|
3263
|
-
'Skipping Pipfile.lock conversion because "requirements.txt" exists'
|
|
3264
|
-
);
|
|
3265
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
|
+
});
|
|
3266
3691
|
}
|
|
3267
|
-
fsFiles = await (0,
|
|
3268
|
-
const requirementsTxt = (0,
|
|
3269
|
-
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)(
|
|
3270
3695
|
workPath,
|
|
3271
3696
|
".vercel",
|
|
3272
3697
|
"python",
|
|
@@ -3274,7 +3699,7 @@ var build = async ({
|
|
|
3274
3699
|
entryDirectory
|
|
3275
3700
|
);
|
|
3276
3701
|
try {
|
|
3277
|
-
await
|
|
3702
|
+
await import_fs5.default.promises.mkdir(vendorBaseDir, { recursive: true });
|
|
3278
3703
|
} catch (err) {
|
|
3279
3704
|
console.log("Failed to create vendor cache directory");
|
|
3280
3705
|
throw err;
|
|
@@ -3285,38 +3710,105 @@ var build = async ({
|
|
|
3285
3710
|
pipPath: pythonVersion.pipPath,
|
|
3286
3711
|
dependency: "werkzeug",
|
|
3287
3712
|
version: "1.0.1",
|
|
3288
|
-
workPath
|
|
3713
|
+
workPath,
|
|
3714
|
+
targetDir: vendorBaseDir,
|
|
3289
3715
|
meta
|
|
3290
3716
|
});
|
|
3291
|
-
|
|
3292
|
-
|
|
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"');
|
|
3293
3783
|
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
|
|
3294
3784
|
await installRequirementsFile({
|
|
3295
3785
|
pythonPath: pythonVersion.pythonPath,
|
|
3296
3786
|
pipPath: pythonVersion.pipPath,
|
|
3297
3787
|
filePath: requirementsTxtPath,
|
|
3298
|
-
workPath
|
|
3788
|
+
workPath,
|
|
3789
|
+
targetDir: vendorBaseDir,
|
|
3299
3790
|
meta
|
|
3300
3791
|
});
|
|
3301
|
-
} else if (fsFiles["requirements.txt"]) {
|
|
3302
|
-
(0,
|
|
3792
|
+
} else if (!installedFromProjectFiles && fsFiles["requirements.txt"]) {
|
|
3793
|
+
(0, import_build_utils5.debug)('Found global "requirements.txt"');
|
|
3303
3794
|
const requirementsTxtPath = fsFiles["requirements.txt"].fsPath;
|
|
3304
3795
|
await installRequirementsFile({
|
|
3305
3796
|
pythonPath: pythonVersion.pythonPath,
|
|
3306
3797
|
pipPath: pythonVersion.pipPath,
|
|
3307
3798
|
filePath: requirementsTxtPath,
|
|
3308
|
-
workPath
|
|
3799
|
+
workPath,
|
|
3800
|
+
targetDir: vendorBaseDir,
|
|
3309
3801
|
meta
|
|
3310
3802
|
});
|
|
3311
3803
|
}
|
|
3312
|
-
const originalPyPath = (0,
|
|
3804
|
+
const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
|
|
3313
3805
|
const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
|
|
3314
|
-
(0,
|
|
3315
|
-
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, "");
|
|
3316
3808
|
const vendorDir = resolveVendorDir();
|
|
3317
3809
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
3318
3810
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
3319
|
-
(0,
|
|
3811
|
+
(0, import_build_utils5.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
3320
3812
|
const handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix).replace(/__VC_HANDLER_VENDOR_DIR/g, vendorDir);
|
|
3321
3813
|
const predefinedExcludes = [
|
|
3322
3814
|
".git/**",
|
|
@@ -3328,7 +3820,8 @@ var build = async ({
|
|
|
3328
3820
|
"**/.nuxt/**",
|
|
3329
3821
|
"**/.venv/**",
|
|
3330
3822
|
"**/venv/**",
|
|
3331
|
-
"**/__pycache__/**"
|
|
3823
|
+
"**/__pycache__/**",
|
|
3824
|
+
"**/public/**"
|
|
3332
3825
|
];
|
|
3333
3826
|
const lambdaEnv = {};
|
|
3334
3827
|
lambdaEnv.PYTHONPATH = vendorDir;
|
|
@@ -3336,11 +3829,11 @@ var build = async ({
|
|
|
3336
3829
|
cwd: workPath,
|
|
3337
3830
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
3338
3831
|
};
|
|
3339
|
-
const files = await (0,
|
|
3832
|
+
const files = await (0, import_build_utils5.glob)("**", globOptions);
|
|
3340
3833
|
try {
|
|
3341
|
-
const cachedVendorAbs = (0,
|
|
3342
|
-
if (
|
|
3343
|
-
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());
|
|
3344
3837
|
for (const [p, f] of Object.entries(vendorFiles)) {
|
|
3345
3838
|
files[p] = f;
|
|
3346
3839
|
}
|
|
@@ -3350,12 +3843,12 @@ var build = async ({
|
|
|
3350
3843
|
throw err;
|
|
3351
3844
|
}
|
|
3352
3845
|
const handlerPyFilename = "vc__handler__python";
|
|
3353
|
-
files[`${handlerPyFilename}.py`] = new
|
|
3846
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils5.FileBlob({ data: handlerPyContents });
|
|
3354
3847
|
if (config.framework === "fasthtml") {
|
|
3355
3848
|
const { SESSKEY = "" } = process.env;
|
|
3356
|
-
files[".sesskey"] = new
|
|
3849
|
+
files[".sesskey"] = new import_build_utils5.FileBlob({ data: `"${SESSKEY}"` });
|
|
3357
3850
|
}
|
|
3358
|
-
const output = new
|
|
3851
|
+
const output = new import_build_utils5.Lambda({
|
|
3359
3852
|
files,
|
|
3360
3853
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
3361
3854
|
runtime: pythonVersion.runtime,
|
|
@@ -3364,12 +3857,44 @@ var build = async ({
|
|
|
3364
3857
|
});
|
|
3365
3858
|
return { output };
|
|
3366
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
|
+
}
|
|
3367
3890
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3368
3891
|
0 && (module.exports = {
|
|
3369
3892
|
build,
|
|
3893
|
+
defaultShouldServe,
|
|
3370
3894
|
downloadFilesInWorkPath,
|
|
3371
3895
|
installRequirement,
|
|
3372
3896
|
installRequirementsFile,
|
|
3373
3897
|
shouldServe,
|
|
3898
|
+
startDevServer,
|
|
3374
3899
|
version
|
|
3375
3900
|
});
|