@vercel/python 6.45.1 → 6.47.1

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.
Files changed (2) hide show
  1. package/dist/index.js +1758 -285
  2. package/package.json +6 -4
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 fs13 = require("fs");
51
+ var fs14 = 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
- fs13.stat(path, function(er, stat) {
76
+ fs14.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(fs13.statSync(path), path, options);
81
+ return checkStat(fs14.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 fs13 = require("fs");
91
+ var fs14 = require("fs");
92
92
  function isexe(path, options, cb) {
93
- fs13.stat(path, function(er, stat) {
93
+ fs14.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(fs13.statSync(path), options);
98
+ return checkStat(fs14.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 fs13 = require("fs");
122
+ var fs14 = 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 fs13 = require("fs");
398
+ var fs14 = 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 = fs13.openSync(command, "r");
412
- fs13.readSync(fd, buffer, 0, size, 0);
413
- fs13.closeSync(fd);
411
+ fd = fs14.openSync(command, "r");
412
+ fs14.readSync(fd, buffer, 0, size, 0);
413
+ fs14.closeSync(fd);
414
414
  } catch (e) {
415
415
  }
416
416
  return shebangCommand(buffer.toString());
@@ -1497,11 +1497,11 @@ var require_parse = __commonJS({
1497
1497
  var resolveCommand = require_resolveCommand();
1498
1498
  var escape = require_escape();
1499
1499
  var readShebang = require_readShebang();
1500
- var semver = require_semver();
1500
+ var semver2 = require_semver();
1501
1501
  var isWin3 = process.platform === "win32";
1502
1502
  var isExecutableRegExp = /\.(?:com|exe)$/i;
1503
1503
  var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
1504
- var supportsShellOption = niceTry(() => semver.satisfies(process.version, "^4.8.0 || ^5.7.0 || >= 6.0.0", true)) || false;
1504
+ var supportsShellOption = niceTry(() => semver2.satisfies(process.version, "^4.8.0 || ^5.7.0 || >= 6.0.0", true)) || false;
1505
1505
  function detectShebang(parsed) {
1506
1506
  parsed.file = resolveCommand(parsed);
1507
1507
  const shebang = parsed.file && readShebang(parsed.file);
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
1895
1895
  "../../node_modules/.pnpm/pump@3.0.4/node_modules/pump/index.js"(exports, module2) {
1896
1896
  var once = require_once();
1897
1897
  var eos = require_end_of_stream();
1898
- var fs13;
1898
+ var fs14;
1899
1899
  try {
1900
- fs13 = require("fs");
1900
+ fs14 = 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 (!fs13)
1912
+ if (!fs14)
1913
1913
  return false;
1914
- return (stream instanceof (fs13.ReadStream || noop) || stream instanceof (fs13.WriteStream || noop)) && isFn(stream.close);
1914
+ return (stream instanceof (fs14.ReadStream || noop) || stream instanceof (fs14.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: join14, delimiter: delimiter2, sep: sep3, posix } = require("path");
2654
+ var { join: join15, delimiter: delimiter2, sep: sep3, posix } = require("path");
2655
2655
  var isWindows = process.platform === "win32";
2656
2656
  var rSlash = new RegExp(`[${posix.sep}${sep3 === posix.sep ? "" : sep3}]`.replace(/(\\)/g, "\\$1"));
2657
2657
  var rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -2680,7 +2680,7 @@ var require_lib = __commonJS({
2680
2680
  var getPathPart = (raw, cmd) => {
2681
2681
  const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
2682
2682
  const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
2683
- return prefix + join14(pathPart, cmd);
2683
+ return prefix + join15(pathPart, cmd);
2684
2684
  };
2685
2685
  var which2 = async (cmd, opt = {}) => {
2686
2686
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
@@ -2735,6 +2735,1156 @@ var require_lib = __commonJS({
2735
2735
  }
2736
2736
  });
2737
2737
 
2738
+ // ../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js
2739
+ var require_semver2 = __commonJS({
2740
+ "../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
2741
+ exports = module2.exports = SemVer;
2742
+ var debug13;
2743
+ if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
2744
+ debug13 = function() {
2745
+ var args = Array.prototype.slice.call(arguments, 0);
2746
+ args.unshift("SEMVER");
2747
+ console.log.apply(console, args);
2748
+ };
2749
+ } else {
2750
+ debug13 = function() {
2751
+ };
2752
+ }
2753
+ exports.SEMVER_SPEC_VERSION = "2.0.0";
2754
+ var MAX_LENGTH = 256;
2755
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
2756
+ 9007199254740991;
2757
+ var MAX_SAFE_COMPONENT_LENGTH = 16;
2758
+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
2759
+ var re = exports.re = [];
2760
+ var safeRe = exports.safeRe = [];
2761
+ var src = exports.src = [];
2762
+ var t = exports.tokens = {};
2763
+ var R = 0;
2764
+ function tok(n) {
2765
+ t[n] = R++;
2766
+ }
2767
+ var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
2768
+ var safeRegexReplacements = [
2769
+ ["\\s", 1],
2770
+ ["\\d", MAX_LENGTH],
2771
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
2772
+ ];
2773
+ function makeSafeRe(value) {
2774
+ for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) {
2775
+ var token = safeRegexReplacements[i2][0];
2776
+ var max = safeRegexReplacements[i2][1];
2777
+ value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}");
2778
+ }
2779
+ return value;
2780
+ }
2781
+ tok("NUMERICIDENTIFIER");
2782
+ src[t.NUMERICIDENTIFIER] = "0|[1-9]\\d*";
2783
+ tok("NUMERICIDENTIFIERLOOSE");
2784
+ src[t.NUMERICIDENTIFIERLOOSE] = "\\d+";
2785
+ tok("NONNUMERICIDENTIFIER");
2786
+ src[t.NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*";
2787
+ tok("MAINVERSION");
2788
+ src[t.MAINVERSION] = "(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")";
2789
+ tok("MAINVERSIONLOOSE");
2790
+ src[t.MAINVERSIONLOOSE] = "(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")";
2791
+ tok("PRERELEASEIDENTIFIER");
2792
+ src[t.PRERELEASEIDENTIFIER] = "(?:" + src[t.NUMERICIDENTIFIER] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
2793
+ tok("PRERELEASEIDENTIFIERLOOSE");
2794
+ src[t.PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[t.NUMERICIDENTIFIERLOOSE] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
2795
+ tok("PRERELEASE");
2796
+ src[t.PRERELEASE] = "(?:-(" + src[t.PRERELEASEIDENTIFIER] + "(?:\\." + src[t.PRERELEASEIDENTIFIER] + ")*))";
2797
+ tok("PRERELEASELOOSE");
2798
+ src[t.PRERELEASELOOSE] = "(?:-?(" + src[t.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[t.PRERELEASEIDENTIFIERLOOSE] + ")*))";
2799
+ tok("BUILDIDENTIFIER");
2800
+ src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + "+";
2801
+ tok("BUILD");
2802
+ src[t.BUILD] = "(?:\\+(" + src[t.BUILDIDENTIFIER] + "(?:\\." + src[t.BUILDIDENTIFIER] + ")*))";
2803
+ tok("FULL");
2804
+ tok("FULLPLAIN");
2805
+ src[t.FULLPLAIN] = "v?" + src[t.MAINVERSION] + src[t.PRERELEASE] + "?" + src[t.BUILD] + "?";
2806
+ src[t.FULL] = "^" + src[t.FULLPLAIN] + "$";
2807
+ tok("LOOSEPLAIN");
2808
+ src[t.LOOSEPLAIN] = "[v=\\s]*" + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + "?" + src[t.BUILD] + "?";
2809
+ tok("LOOSE");
2810
+ src[t.LOOSE] = "^" + src[t.LOOSEPLAIN] + "$";
2811
+ tok("GTLT");
2812
+ src[t.GTLT] = "((?:<|>)?=?)";
2813
+ tok("XRANGEIDENTIFIERLOOSE");
2814
+ src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
2815
+ tok("XRANGEIDENTIFIER");
2816
+ src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + "|x|X|\\*";
2817
+ tok("XRANGEPLAIN");
2818
+ src[t.XRANGEPLAIN] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:" + src[t.PRERELEASE] + ")?" + src[t.BUILD] + "?)?)?";
2819
+ tok("XRANGEPLAINLOOSE");
2820
+ src[t.XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:" + src[t.PRERELEASELOOSE] + ")?" + src[t.BUILD] + "?)?)?";
2821
+ tok("XRANGE");
2822
+ src[t.XRANGE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAIN] + "$";
2823
+ tok("XRANGELOOSE");
2824
+ src[t.XRANGELOOSE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAINLOOSE] + "$";
2825
+ tok("COERCE");
2826
+ src[t.COERCE] = "(^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
2827
+ tok("COERCERTL");
2828
+ re[t.COERCERTL] = new RegExp(src[t.COERCE], "g");
2829
+ safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), "g");
2830
+ tok("LONETILDE");
2831
+ src[t.LONETILDE] = "(?:~>?)";
2832
+ tok("TILDETRIM");
2833
+ src[t.TILDETRIM] = "(\\s*)" + src[t.LONETILDE] + "\\s+";
2834
+ re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], "g");
2835
+ safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), "g");
2836
+ var tildeTrimReplace = "$1~";
2837
+ tok("TILDE");
2838
+ src[t.TILDE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAIN] + "$";
2839
+ tok("TILDELOOSE");
2840
+ src[t.TILDELOOSE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + "$";
2841
+ tok("LONECARET");
2842
+ src[t.LONECARET] = "(?:\\^)";
2843
+ tok("CARETTRIM");
2844
+ src[t.CARETTRIM] = "(\\s*)" + src[t.LONECARET] + "\\s+";
2845
+ re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], "g");
2846
+ safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), "g");
2847
+ var caretTrimReplace = "$1^";
2848
+ tok("CARET");
2849
+ src[t.CARET] = "^" + src[t.LONECARET] + src[t.XRANGEPLAIN] + "$";
2850
+ tok("CARETLOOSE");
2851
+ src[t.CARETLOOSE] = "^" + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + "$";
2852
+ tok("COMPARATORLOOSE");
2853
+ src[t.COMPARATORLOOSE] = "^" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + ")$|^$";
2854
+ tok("COMPARATOR");
2855
+ src[t.COMPARATOR] = "^" + src[t.GTLT] + "\\s*(" + src[t.FULLPLAIN] + ")$|^$";
2856
+ tok("COMPARATORTRIM");
2857
+ src[t.COMPARATORTRIM] = "(\\s*)" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + "|" + src[t.XRANGEPLAIN] + ")";
2858
+ re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], "g");
2859
+ safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), "g");
2860
+ var comparatorTrimReplace = "$1$2$3";
2861
+ tok("HYPHENRANGE");
2862
+ src[t.HYPHENRANGE] = "^\\s*(" + src[t.XRANGEPLAIN] + ")\\s+-\\s+(" + src[t.XRANGEPLAIN] + ")\\s*$";
2863
+ tok("HYPHENRANGELOOSE");
2864
+ src[t.HYPHENRANGELOOSE] = "^\\s*(" + src[t.XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[t.XRANGEPLAINLOOSE] + ")\\s*$";
2865
+ tok("STAR");
2866
+ src[t.STAR] = "(<|>)?=?\\s*\\*";
2867
+ for (i = 0; i < R; i++) {
2868
+ debug13(i, src[i]);
2869
+ if (!re[i]) {
2870
+ re[i] = new RegExp(src[i]);
2871
+ safeRe[i] = new RegExp(makeSafeRe(src[i]));
2872
+ }
2873
+ }
2874
+ var i;
2875
+ exports.parse = parse2;
2876
+ function parse2(version2, options) {
2877
+ if (!options || typeof options !== "object") {
2878
+ options = {
2879
+ loose: !!options,
2880
+ includePrerelease: false
2881
+ };
2882
+ }
2883
+ if (version2 instanceof SemVer) {
2884
+ return version2;
2885
+ }
2886
+ if (typeof version2 !== "string") {
2887
+ return null;
2888
+ }
2889
+ if (version2.length > MAX_LENGTH) {
2890
+ return null;
2891
+ }
2892
+ var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL];
2893
+ if (!r.test(version2)) {
2894
+ return null;
2895
+ }
2896
+ try {
2897
+ return new SemVer(version2, options);
2898
+ } catch (er) {
2899
+ return null;
2900
+ }
2901
+ }
2902
+ exports.valid = valid;
2903
+ function valid(version2, options) {
2904
+ var v = parse2(version2, options);
2905
+ return v ? v.version : null;
2906
+ }
2907
+ exports.clean = clean;
2908
+ function clean(version2, options) {
2909
+ var s = parse2(version2.trim().replace(/^[=v]+/, ""), options);
2910
+ return s ? s.version : null;
2911
+ }
2912
+ exports.SemVer = SemVer;
2913
+ function SemVer(version2, options) {
2914
+ if (!options || typeof options !== "object") {
2915
+ options = {
2916
+ loose: !!options,
2917
+ includePrerelease: false
2918
+ };
2919
+ }
2920
+ if (version2 instanceof SemVer) {
2921
+ if (version2.loose === options.loose) {
2922
+ return version2;
2923
+ } else {
2924
+ version2 = version2.version;
2925
+ }
2926
+ } else if (typeof version2 !== "string") {
2927
+ throw new TypeError("Invalid Version: " + version2);
2928
+ }
2929
+ if (version2.length > MAX_LENGTH) {
2930
+ throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
2931
+ }
2932
+ if (!(this instanceof SemVer)) {
2933
+ return new SemVer(version2, options);
2934
+ }
2935
+ debug13("SemVer", version2, options);
2936
+ this.options = options;
2937
+ this.loose = !!options.loose;
2938
+ var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
2939
+ if (!m) {
2940
+ throw new TypeError("Invalid Version: " + version2);
2941
+ }
2942
+ this.raw = version2;
2943
+ this.major = +m[1];
2944
+ this.minor = +m[2];
2945
+ this.patch = +m[3];
2946
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
2947
+ throw new TypeError("Invalid major version");
2948
+ }
2949
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
2950
+ throw new TypeError("Invalid minor version");
2951
+ }
2952
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
2953
+ throw new TypeError("Invalid patch version");
2954
+ }
2955
+ if (!m[4]) {
2956
+ this.prerelease = [];
2957
+ } else {
2958
+ this.prerelease = m[4].split(".").map(function(id) {
2959
+ if (/^[0-9]+$/.test(id)) {
2960
+ var num = +id;
2961
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
2962
+ return num;
2963
+ }
2964
+ }
2965
+ return id;
2966
+ });
2967
+ }
2968
+ this.build = m[5] ? m[5].split(".") : [];
2969
+ this.format();
2970
+ }
2971
+ SemVer.prototype.format = function() {
2972
+ this.version = this.major + "." + this.minor + "." + this.patch;
2973
+ if (this.prerelease.length) {
2974
+ this.version += "-" + this.prerelease.join(".");
2975
+ }
2976
+ return this.version;
2977
+ };
2978
+ SemVer.prototype.toString = function() {
2979
+ return this.version;
2980
+ };
2981
+ SemVer.prototype.compare = function(other) {
2982
+ debug13("SemVer.compare", this.version, this.options, other);
2983
+ if (!(other instanceof SemVer)) {
2984
+ other = new SemVer(other, this.options);
2985
+ }
2986
+ return this.compareMain(other) || this.comparePre(other);
2987
+ };
2988
+ SemVer.prototype.compareMain = function(other) {
2989
+ if (!(other instanceof SemVer)) {
2990
+ other = new SemVer(other, this.options);
2991
+ }
2992
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
2993
+ };
2994
+ SemVer.prototype.comparePre = function(other) {
2995
+ if (!(other instanceof SemVer)) {
2996
+ other = new SemVer(other, this.options);
2997
+ }
2998
+ if (this.prerelease.length && !other.prerelease.length) {
2999
+ return -1;
3000
+ } else if (!this.prerelease.length && other.prerelease.length) {
3001
+ return 1;
3002
+ } else if (!this.prerelease.length && !other.prerelease.length) {
3003
+ return 0;
3004
+ }
3005
+ var i2 = 0;
3006
+ do {
3007
+ var a = this.prerelease[i2];
3008
+ var b = other.prerelease[i2];
3009
+ debug13("prerelease compare", i2, a, b);
3010
+ if (a === void 0 && b === void 0) {
3011
+ return 0;
3012
+ } else if (b === void 0) {
3013
+ return 1;
3014
+ } else if (a === void 0) {
3015
+ return -1;
3016
+ } else if (a === b) {
3017
+ continue;
3018
+ } else {
3019
+ return compareIdentifiers(a, b);
3020
+ }
3021
+ } while (++i2);
3022
+ };
3023
+ SemVer.prototype.compareBuild = function(other) {
3024
+ if (!(other instanceof SemVer)) {
3025
+ other = new SemVer(other, this.options);
3026
+ }
3027
+ var i2 = 0;
3028
+ do {
3029
+ var a = this.build[i2];
3030
+ var b = other.build[i2];
3031
+ debug13("prerelease compare", i2, a, b);
3032
+ if (a === void 0 && b === void 0) {
3033
+ return 0;
3034
+ } else if (b === void 0) {
3035
+ return 1;
3036
+ } else if (a === void 0) {
3037
+ return -1;
3038
+ } else if (a === b) {
3039
+ continue;
3040
+ } else {
3041
+ return compareIdentifiers(a, b);
3042
+ }
3043
+ } while (++i2);
3044
+ };
3045
+ SemVer.prototype.inc = function(release, identifier) {
3046
+ switch (release) {
3047
+ case "premajor":
3048
+ this.prerelease.length = 0;
3049
+ this.patch = 0;
3050
+ this.minor = 0;
3051
+ this.major++;
3052
+ this.inc("pre", identifier);
3053
+ break;
3054
+ case "preminor":
3055
+ this.prerelease.length = 0;
3056
+ this.patch = 0;
3057
+ this.minor++;
3058
+ this.inc("pre", identifier);
3059
+ break;
3060
+ case "prepatch":
3061
+ this.prerelease.length = 0;
3062
+ this.inc("patch", identifier);
3063
+ this.inc("pre", identifier);
3064
+ break;
3065
+ case "prerelease":
3066
+ if (this.prerelease.length === 0) {
3067
+ this.inc("patch", identifier);
3068
+ }
3069
+ this.inc("pre", identifier);
3070
+ break;
3071
+ case "major":
3072
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
3073
+ this.major++;
3074
+ }
3075
+ this.minor = 0;
3076
+ this.patch = 0;
3077
+ this.prerelease = [];
3078
+ break;
3079
+ case "minor":
3080
+ if (this.patch !== 0 || this.prerelease.length === 0) {
3081
+ this.minor++;
3082
+ }
3083
+ this.patch = 0;
3084
+ this.prerelease = [];
3085
+ break;
3086
+ case "patch":
3087
+ if (this.prerelease.length === 0) {
3088
+ this.patch++;
3089
+ }
3090
+ this.prerelease = [];
3091
+ break;
3092
+ case "pre":
3093
+ if (this.prerelease.length === 0) {
3094
+ this.prerelease = [0];
3095
+ } else {
3096
+ var i2 = this.prerelease.length;
3097
+ while (--i2 >= 0) {
3098
+ if (typeof this.prerelease[i2] === "number") {
3099
+ this.prerelease[i2]++;
3100
+ i2 = -2;
3101
+ }
3102
+ }
3103
+ if (i2 === -1) {
3104
+ this.prerelease.push(0);
3105
+ }
3106
+ }
3107
+ if (identifier) {
3108
+ if (this.prerelease[0] === identifier) {
3109
+ if (isNaN(this.prerelease[1])) {
3110
+ this.prerelease = [identifier, 0];
3111
+ }
3112
+ } else {
3113
+ this.prerelease = [identifier, 0];
3114
+ }
3115
+ }
3116
+ break;
3117
+ default:
3118
+ throw new Error("invalid increment argument: " + release);
3119
+ }
3120
+ this.format();
3121
+ this.raw = this.version;
3122
+ return this;
3123
+ };
3124
+ exports.inc = inc;
3125
+ function inc(version2, release, loose, identifier) {
3126
+ if (typeof loose === "string") {
3127
+ identifier = loose;
3128
+ loose = void 0;
3129
+ }
3130
+ try {
3131
+ return new SemVer(version2, loose).inc(release, identifier).version;
3132
+ } catch (er) {
3133
+ return null;
3134
+ }
3135
+ }
3136
+ exports.diff = diff;
3137
+ function diff(version1, version2) {
3138
+ if (eq(version1, version2)) {
3139
+ return null;
3140
+ } else {
3141
+ var v1 = parse2(version1);
3142
+ var v2 = parse2(version2);
3143
+ var prefix = "";
3144
+ if (v1.prerelease.length || v2.prerelease.length) {
3145
+ prefix = "pre";
3146
+ var defaultResult = "prerelease";
3147
+ }
3148
+ for (var key in v1) {
3149
+ if (key === "major" || key === "minor" || key === "patch") {
3150
+ if (v1[key] !== v2[key]) {
3151
+ return prefix + key;
3152
+ }
3153
+ }
3154
+ }
3155
+ return defaultResult;
3156
+ }
3157
+ }
3158
+ exports.compareIdentifiers = compareIdentifiers;
3159
+ var numeric = /^[0-9]+$/;
3160
+ function compareIdentifiers(a, b) {
3161
+ var anum = numeric.test(a);
3162
+ var bnum = numeric.test(b);
3163
+ if (anum && bnum) {
3164
+ a = +a;
3165
+ b = +b;
3166
+ }
3167
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
3168
+ }
3169
+ exports.rcompareIdentifiers = rcompareIdentifiers;
3170
+ function rcompareIdentifiers(a, b) {
3171
+ return compareIdentifiers(b, a);
3172
+ }
3173
+ exports.major = major;
3174
+ function major(a, loose) {
3175
+ return new SemVer(a, loose).major;
3176
+ }
3177
+ exports.minor = minor;
3178
+ function minor(a, loose) {
3179
+ return new SemVer(a, loose).minor;
3180
+ }
3181
+ exports.patch = patch;
3182
+ function patch(a, loose) {
3183
+ return new SemVer(a, loose).patch;
3184
+ }
3185
+ exports.compare = compare;
3186
+ function compare(a, b, loose) {
3187
+ return new SemVer(a, loose).compare(new SemVer(b, loose));
3188
+ }
3189
+ exports.compareLoose = compareLoose;
3190
+ function compareLoose(a, b) {
3191
+ return compare(a, b, true);
3192
+ }
3193
+ exports.compareBuild = compareBuild;
3194
+ function compareBuild(a, b, loose) {
3195
+ var versionA = new SemVer(a, loose);
3196
+ var versionB = new SemVer(b, loose);
3197
+ return versionA.compare(versionB) || versionA.compareBuild(versionB);
3198
+ }
3199
+ exports.rcompare = rcompare;
3200
+ function rcompare(a, b, loose) {
3201
+ return compare(b, a, loose);
3202
+ }
3203
+ exports.sort = sort;
3204
+ function sort(list, loose) {
3205
+ return list.sort(function(a, b) {
3206
+ return exports.compareBuild(a, b, loose);
3207
+ });
3208
+ }
3209
+ exports.rsort = rsort;
3210
+ function rsort(list, loose) {
3211
+ return list.sort(function(a, b) {
3212
+ return exports.compareBuild(b, a, loose);
3213
+ });
3214
+ }
3215
+ exports.gt = gt;
3216
+ function gt(a, b, loose) {
3217
+ return compare(a, b, loose) > 0;
3218
+ }
3219
+ exports.lt = lt;
3220
+ function lt(a, b, loose) {
3221
+ return compare(a, b, loose) < 0;
3222
+ }
3223
+ exports.eq = eq;
3224
+ function eq(a, b, loose) {
3225
+ return compare(a, b, loose) === 0;
3226
+ }
3227
+ exports.neq = neq;
3228
+ function neq(a, b, loose) {
3229
+ return compare(a, b, loose) !== 0;
3230
+ }
3231
+ exports.gte = gte;
3232
+ function gte(a, b, loose) {
3233
+ return compare(a, b, loose) >= 0;
3234
+ }
3235
+ exports.lte = lte;
3236
+ function lte(a, b, loose) {
3237
+ return compare(a, b, loose) <= 0;
3238
+ }
3239
+ exports.cmp = cmp;
3240
+ function cmp(a, op, b, loose) {
3241
+ switch (op) {
3242
+ case "===":
3243
+ if (typeof a === "object")
3244
+ a = a.version;
3245
+ if (typeof b === "object")
3246
+ b = b.version;
3247
+ return a === b;
3248
+ case "!==":
3249
+ if (typeof a === "object")
3250
+ a = a.version;
3251
+ if (typeof b === "object")
3252
+ b = b.version;
3253
+ return a !== b;
3254
+ case "":
3255
+ case "=":
3256
+ case "==":
3257
+ return eq(a, b, loose);
3258
+ case "!=":
3259
+ return neq(a, b, loose);
3260
+ case ">":
3261
+ return gt(a, b, loose);
3262
+ case ">=":
3263
+ return gte(a, b, loose);
3264
+ case "<":
3265
+ return lt(a, b, loose);
3266
+ case "<=":
3267
+ return lte(a, b, loose);
3268
+ default:
3269
+ throw new TypeError("Invalid operator: " + op);
3270
+ }
3271
+ }
3272
+ exports.Comparator = Comparator;
3273
+ function Comparator(comp, options) {
3274
+ if (!options || typeof options !== "object") {
3275
+ options = {
3276
+ loose: !!options,
3277
+ includePrerelease: false
3278
+ };
3279
+ }
3280
+ if (comp instanceof Comparator) {
3281
+ if (comp.loose === !!options.loose) {
3282
+ return comp;
3283
+ } else {
3284
+ comp = comp.value;
3285
+ }
3286
+ }
3287
+ if (!(this instanceof Comparator)) {
3288
+ return new Comparator(comp, options);
3289
+ }
3290
+ comp = comp.trim().split(/\s+/).join(" ");
3291
+ debug13("comparator", comp, options);
3292
+ this.options = options;
3293
+ this.loose = !!options.loose;
3294
+ this.parse(comp);
3295
+ if (this.semver === ANY) {
3296
+ this.value = "";
3297
+ } else {
3298
+ this.value = this.operator + this.semver.version;
3299
+ }
3300
+ debug13("comp", this);
3301
+ }
3302
+ var ANY = {};
3303
+ Comparator.prototype.parse = function(comp) {
3304
+ var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
3305
+ var m = comp.match(r);
3306
+ if (!m) {
3307
+ throw new TypeError("Invalid comparator: " + comp);
3308
+ }
3309
+ this.operator = m[1] !== void 0 ? m[1] : "";
3310
+ if (this.operator === "=") {
3311
+ this.operator = "";
3312
+ }
3313
+ if (!m[2]) {
3314
+ this.semver = ANY;
3315
+ } else {
3316
+ this.semver = new SemVer(m[2], this.options.loose);
3317
+ }
3318
+ };
3319
+ Comparator.prototype.toString = function() {
3320
+ return this.value;
3321
+ };
3322
+ Comparator.prototype.test = function(version2) {
3323
+ debug13("Comparator.test", version2, this.options.loose);
3324
+ if (this.semver === ANY || version2 === ANY) {
3325
+ return true;
3326
+ }
3327
+ if (typeof version2 === "string") {
3328
+ try {
3329
+ version2 = new SemVer(version2, this.options);
3330
+ } catch (er) {
3331
+ return false;
3332
+ }
3333
+ }
3334
+ return cmp(version2, this.operator, this.semver, this.options);
3335
+ };
3336
+ Comparator.prototype.intersects = function(comp, options) {
3337
+ if (!(comp instanceof Comparator)) {
3338
+ throw new TypeError("a Comparator is required");
3339
+ }
3340
+ if (!options || typeof options !== "object") {
3341
+ options = {
3342
+ loose: !!options,
3343
+ includePrerelease: false
3344
+ };
3345
+ }
3346
+ var rangeTmp;
3347
+ if (this.operator === "") {
3348
+ if (this.value === "") {
3349
+ return true;
3350
+ }
3351
+ rangeTmp = new Range(comp.value, options);
3352
+ return satisfies(this.value, rangeTmp, options);
3353
+ } else if (comp.operator === "") {
3354
+ if (comp.value === "") {
3355
+ return true;
3356
+ }
3357
+ rangeTmp = new Range(this.value, options);
3358
+ return satisfies(comp.semver, rangeTmp, options);
3359
+ }
3360
+ var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
3361
+ var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
3362
+ var sameSemVer = this.semver.version === comp.semver.version;
3363
+ var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
3364
+ var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<"));
3365
+ var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">"));
3366
+ return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
3367
+ };
3368
+ exports.Range = Range;
3369
+ function Range(range, options) {
3370
+ if (!options || typeof options !== "object") {
3371
+ options = {
3372
+ loose: !!options,
3373
+ includePrerelease: false
3374
+ };
3375
+ }
3376
+ if (range instanceof Range) {
3377
+ if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
3378
+ return range;
3379
+ } else {
3380
+ return new Range(range.raw, options);
3381
+ }
3382
+ }
3383
+ if (range instanceof Comparator) {
3384
+ return new Range(range.value, options);
3385
+ }
3386
+ if (!(this instanceof Range)) {
3387
+ return new Range(range, options);
3388
+ }
3389
+ this.options = options;
3390
+ this.loose = !!options.loose;
3391
+ this.includePrerelease = !!options.includePrerelease;
3392
+ this.raw = range.trim().split(/\s+/).join(" ");
3393
+ this.set = this.raw.split("||").map(function(range2) {
3394
+ return this.parseRange(range2.trim());
3395
+ }, this).filter(function(c) {
3396
+ return c.length;
3397
+ });
3398
+ if (!this.set.length) {
3399
+ throw new TypeError("Invalid SemVer Range: " + this.raw);
3400
+ }
3401
+ this.format();
3402
+ }
3403
+ Range.prototype.format = function() {
3404
+ this.range = this.set.map(function(comps) {
3405
+ return comps.join(" ").trim();
3406
+ }).join("||").trim();
3407
+ return this.range;
3408
+ };
3409
+ Range.prototype.toString = function() {
3410
+ return this.range;
3411
+ };
3412
+ Range.prototype.parseRange = function(range) {
3413
+ var loose = this.options.loose;
3414
+ var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
3415
+ range = range.replace(hr, hyphenReplace);
3416
+ debug13("hyphen replace", range);
3417
+ range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
3418
+ debug13("comparator trim", range, safeRe[t.COMPARATORTRIM]);
3419
+ range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
3420
+ range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
3421
+ range = range.split(/\s+/).join(" ");
3422
+ var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
3423
+ var set = range.split(" ").map(function(comp) {
3424
+ return parseComparator(comp, this.options);
3425
+ }, this).join(" ").split(/\s+/);
3426
+ if (this.options.loose) {
3427
+ set = set.filter(function(comp) {
3428
+ return !!comp.match(compRe);
3429
+ });
3430
+ }
3431
+ set = set.map(function(comp) {
3432
+ return new Comparator(comp, this.options);
3433
+ }, this);
3434
+ return set;
3435
+ };
3436
+ Range.prototype.intersects = function(range, options) {
3437
+ if (!(range instanceof Range)) {
3438
+ throw new TypeError("a Range is required");
3439
+ }
3440
+ return this.set.some(function(thisComparators) {
3441
+ return isSatisfiable(thisComparators, options) && range.set.some(function(rangeComparators) {
3442
+ return isSatisfiable(rangeComparators, options) && thisComparators.every(function(thisComparator) {
3443
+ return rangeComparators.every(function(rangeComparator) {
3444
+ return thisComparator.intersects(rangeComparator, options);
3445
+ });
3446
+ });
3447
+ });
3448
+ });
3449
+ };
3450
+ function isSatisfiable(comparators, options) {
3451
+ var result = true;
3452
+ var remainingComparators = comparators.slice();
3453
+ var testComparator = remainingComparators.pop();
3454
+ while (result && remainingComparators.length) {
3455
+ result = remainingComparators.every(function(otherComparator) {
3456
+ return testComparator.intersects(otherComparator, options);
3457
+ });
3458
+ testComparator = remainingComparators.pop();
3459
+ }
3460
+ return result;
3461
+ }
3462
+ exports.toComparators = toComparators;
3463
+ function toComparators(range, options) {
3464
+ return new Range(range, options).set.map(function(comp) {
3465
+ return comp.map(function(c) {
3466
+ return c.value;
3467
+ }).join(" ").trim().split(" ");
3468
+ });
3469
+ }
3470
+ function parseComparator(comp, options) {
3471
+ debug13("comp", comp, options);
3472
+ comp = replaceCarets(comp, options);
3473
+ debug13("caret", comp);
3474
+ comp = replaceTildes(comp, options);
3475
+ debug13("tildes", comp);
3476
+ comp = replaceXRanges(comp, options);
3477
+ debug13("xrange", comp);
3478
+ comp = replaceStars(comp, options);
3479
+ debug13("stars", comp);
3480
+ return comp;
3481
+ }
3482
+ function isX(id) {
3483
+ return !id || id.toLowerCase() === "x" || id === "*";
3484
+ }
3485
+ function replaceTildes(comp, options) {
3486
+ return comp.trim().split(/\s+/).map(function(comp2) {
3487
+ return replaceTilde(comp2, options);
3488
+ }).join(" ");
3489
+ }
3490
+ function replaceTilde(comp, options) {
3491
+ var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
3492
+ return comp.replace(r, function(_, M, m, p, pr) {
3493
+ debug13("tilde", comp, _, M, m, p, pr);
3494
+ var ret;
3495
+ if (isX(M)) {
3496
+ ret = "";
3497
+ } else if (isX(m)) {
3498
+ ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
3499
+ } else if (isX(p)) {
3500
+ ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
3501
+ } else if (pr) {
3502
+ debug13("replaceTilde pr", pr);
3503
+ ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
3504
+ } else {
3505
+ ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
3506
+ }
3507
+ debug13("tilde return", ret);
3508
+ return ret;
3509
+ });
3510
+ }
3511
+ function replaceCarets(comp, options) {
3512
+ return comp.trim().split(/\s+/).map(function(comp2) {
3513
+ return replaceCaret(comp2, options);
3514
+ }).join(" ");
3515
+ }
3516
+ function replaceCaret(comp, options) {
3517
+ debug13("caret", comp, options);
3518
+ var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
3519
+ return comp.replace(r, function(_, M, m, p, pr) {
3520
+ debug13("caret", comp, _, M, m, p, pr);
3521
+ var ret;
3522
+ if (isX(M)) {
3523
+ ret = "";
3524
+ } else if (isX(m)) {
3525
+ ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
3526
+ } else if (isX(p)) {
3527
+ if (M === "0") {
3528
+ ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
3529
+ } else {
3530
+ ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
3531
+ }
3532
+ } else if (pr) {
3533
+ debug13("replaceCaret pr", pr);
3534
+ if (M === "0") {
3535
+ if (m === "0") {
3536
+ ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
3537
+ } else {
3538
+ ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
3539
+ }
3540
+ } else {
3541
+ ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
3542
+ }
3543
+ } else {
3544
+ debug13("no pr");
3545
+ if (M === "0") {
3546
+ if (m === "0") {
3547
+ ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
3548
+ } else {
3549
+ ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
3550
+ }
3551
+ } else {
3552
+ ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
3553
+ }
3554
+ }
3555
+ debug13("caret return", ret);
3556
+ return ret;
3557
+ });
3558
+ }
3559
+ function replaceXRanges(comp, options) {
3560
+ debug13("replaceXRanges", comp, options);
3561
+ return comp.split(/\s+/).map(function(comp2) {
3562
+ return replaceXRange(comp2, options);
3563
+ }).join(" ");
3564
+ }
3565
+ function replaceXRange(comp, options) {
3566
+ comp = comp.trim();
3567
+ var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
3568
+ return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
3569
+ debug13("xRange", comp, ret, gtlt, M, m, p, pr);
3570
+ var xM = isX(M);
3571
+ var xm = xM || isX(m);
3572
+ var xp = xm || isX(p);
3573
+ var anyX = xp;
3574
+ if (gtlt === "=" && anyX) {
3575
+ gtlt = "";
3576
+ }
3577
+ pr = options.includePrerelease ? "-0" : "";
3578
+ if (xM) {
3579
+ if (gtlt === ">" || gtlt === "<") {
3580
+ ret = "<0.0.0-0";
3581
+ } else {
3582
+ ret = "*";
3583
+ }
3584
+ } else if (gtlt && anyX) {
3585
+ if (xm) {
3586
+ m = 0;
3587
+ }
3588
+ p = 0;
3589
+ if (gtlt === ">") {
3590
+ gtlt = ">=";
3591
+ if (xm) {
3592
+ M = +M + 1;
3593
+ m = 0;
3594
+ p = 0;
3595
+ } else {
3596
+ m = +m + 1;
3597
+ p = 0;
3598
+ }
3599
+ } else if (gtlt === "<=") {
3600
+ gtlt = "<";
3601
+ if (xm) {
3602
+ M = +M + 1;
3603
+ } else {
3604
+ m = +m + 1;
3605
+ }
3606
+ }
3607
+ ret = gtlt + M + "." + m + "." + p + pr;
3608
+ } else if (xm) {
3609
+ ret = ">=" + M + ".0.0" + pr + " <" + (+M + 1) + ".0.0" + pr;
3610
+ } else if (xp) {
3611
+ ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
3612
+ }
3613
+ debug13("xRange return", ret);
3614
+ return ret;
3615
+ });
3616
+ }
3617
+ function replaceStars(comp, options) {
3618
+ debug13("replaceStars", comp, options);
3619
+ return comp.trim().replace(safeRe[t.STAR], "");
3620
+ }
3621
+ function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
3622
+ if (isX(fM)) {
3623
+ from = "";
3624
+ } else if (isX(fm)) {
3625
+ from = ">=" + fM + ".0.0";
3626
+ } else if (isX(fp)) {
3627
+ from = ">=" + fM + "." + fm + ".0";
3628
+ } else {
3629
+ from = ">=" + from;
3630
+ }
3631
+ if (isX(tM)) {
3632
+ to = "";
3633
+ } else if (isX(tm)) {
3634
+ to = "<" + (+tM + 1) + ".0.0";
3635
+ } else if (isX(tp)) {
3636
+ to = "<" + tM + "." + (+tm + 1) + ".0";
3637
+ } else if (tpr) {
3638
+ to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
3639
+ } else {
3640
+ to = "<=" + to;
3641
+ }
3642
+ return (from + " " + to).trim();
3643
+ }
3644
+ Range.prototype.test = function(version2) {
3645
+ if (!version2) {
3646
+ return false;
3647
+ }
3648
+ if (typeof version2 === "string") {
3649
+ try {
3650
+ version2 = new SemVer(version2, this.options);
3651
+ } catch (er) {
3652
+ return false;
3653
+ }
3654
+ }
3655
+ for (var i2 = 0; i2 < this.set.length; i2++) {
3656
+ if (testSet(this.set[i2], version2, this.options)) {
3657
+ return true;
3658
+ }
3659
+ }
3660
+ return false;
3661
+ };
3662
+ function testSet(set, version2, options) {
3663
+ for (var i2 = 0; i2 < set.length; i2++) {
3664
+ if (!set[i2].test(version2)) {
3665
+ return false;
3666
+ }
3667
+ }
3668
+ if (version2.prerelease.length && !options.includePrerelease) {
3669
+ for (i2 = 0; i2 < set.length; i2++) {
3670
+ debug13(set[i2].semver);
3671
+ if (set[i2].semver === ANY) {
3672
+ continue;
3673
+ }
3674
+ if (set[i2].semver.prerelease.length > 0) {
3675
+ var allowed = set[i2].semver;
3676
+ if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
3677
+ return true;
3678
+ }
3679
+ }
3680
+ }
3681
+ return false;
3682
+ }
3683
+ return true;
3684
+ }
3685
+ exports.satisfies = satisfies;
3686
+ function satisfies(version2, range, options) {
3687
+ try {
3688
+ range = new Range(range, options);
3689
+ } catch (er) {
3690
+ return false;
3691
+ }
3692
+ return range.test(version2);
3693
+ }
3694
+ exports.maxSatisfying = maxSatisfying;
3695
+ function maxSatisfying(versions, range, options) {
3696
+ var max = null;
3697
+ var maxSV = null;
3698
+ try {
3699
+ var rangeObj = new Range(range, options);
3700
+ } catch (er) {
3701
+ return null;
3702
+ }
3703
+ versions.forEach(function(v) {
3704
+ if (rangeObj.test(v)) {
3705
+ if (!max || maxSV.compare(v) === -1) {
3706
+ max = v;
3707
+ maxSV = new SemVer(max, options);
3708
+ }
3709
+ }
3710
+ });
3711
+ return max;
3712
+ }
3713
+ exports.minSatisfying = minSatisfying;
3714
+ function minSatisfying(versions, range, options) {
3715
+ var min = null;
3716
+ var minSV = null;
3717
+ try {
3718
+ var rangeObj = new Range(range, options);
3719
+ } catch (er) {
3720
+ return null;
3721
+ }
3722
+ versions.forEach(function(v) {
3723
+ if (rangeObj.test(v)) {
3724
+ if (!min || minSV.compare(v) === 1) {
3725
+ min = v;
3726
+ minSV = new SemVer(min, options);
3727
+ }
3728
+ }
3729
+ });
3730
+ return min;
3731
+ }
3732
+ exports.minVersion = minVersion;
3733
+ function minVersion(range, loose) {
3734
+ range = new Range(range, loose);
3735
+ var minver = new SemVer("0.0.0");
3736
+ if (range.test(minver)) {
3737
+ return minver;
3738
+ }
3739
+ minver = new SemVer("0.0.0-0");
3740
+ if (range.test(minver)) {
3741
+ return minver;
3742
+ }
3743
+ minver = null;
3744
+ for (var i2 = 0; i2 < range.set.length; ++i2) {
3745
+ var comparators = range.set[i2];
3746
+ comparators.forEach(function(comparator) {
3747
+ var compver = new SemVer(comparator.semver.version);
3748
+ switch (comparator.operator) {
3749
+ case ">":
3750
+ if (compver.prerelease.length === 0) {
3751
+ compver.patch++;
3752
+ } else {
3753
+ compver.prerelease.push(0);
3754
+ }
3755
+ compver.raw = compver.format();
3756
+ case "":
3757
+ case ">=":
3758
+ if (!minver || gt(minver, compver)) {
3759
+ minver = compver;
3760
+ }
3761
+ break;
3762
+ case "<":
3763
+ case "<=":
3764
+ break;
3765
+ default:
3766
+ throw new Error("Unexpected operation: " + comparator.operator);
3767
+ }
3768
+ });
3769
+ }
3770
+ if (minver && range.test(minver)) {
3771
+ return minver;
3772
+ }
3773
+ return null;
3774
+ }
3775
+ exports.validRange = validRange;
3776
+ function validRange(range, options) {
3777
+ try {
3778
+ return new Range(range, options).range || "*";
3779
+ } catch (er) {
3780
+ return null;
3781
+ }
3782
+ }
3783
+ exports.ltr = ltr;
3784
+ function ltr(version2, range, options) {
3785
+ return outside(version2, range, "<", options);
3786
+ }
3787
+ exports.gtr = gtr;
3788
+ function gtr(version2, range, options) {
3789
+ return outside(version2, range, ">", options);
3790
+ }
3791
+ exports.outside = outside;
3792
+ function outside(version2, range, hilo, options) {
3793
+ version2 = new SemVer(version2, options);
3794
+ range = new Range(range, options);
3795
+ var gtfn, ltefn, ltfn, comp, ecomp;
3796
+ switch (hilo) {
3797
+ case ">":
3798
+ gtfn = gt;
3799
+ ltefn = lte;
3800
+ ltfn = lt;
3801
+ comp = ">";
3802
+ ecomp = ">=";
3803
+ break;
3804
+ case "<":
3805
+ gtfn = lt;
3806
+ ltefn = gte;
3807
+ ltfn = gt;
3808
+ comp = "<";
3809
+ ecomp = "<=";
3810
+ break;
3811
+ default:
3812
+ throw new TypeError('Must provide a hilo val of "<" or ">"');
3813
+ }
3814
+ if (satisfies(version2, range, options)) {
3815
+ return false;
3816
+ }
3817
+ for (var i2 = 0; i2 < range.set.length; ++i2) {
3818
+ var comparators = range.set[i2];
3819
+ var high = null;
3820
+ var low = null;
3821
+ comparators.forEach(function(comparator) {
3822
+ if (comparator.semver === ANY) {
3823
+ comparator = new Comparator(">=0.0.0");
3824
+ }
3825
+ high = high || comparator;
3826
+ low = low || comparator;
3827
+ if (gtfn(comparator.semver, high.semver, options)) {
3828
+ high = comparator;
3829
+ } else if (ltfn(comparator.semver, low.semver, options)) {
3830
+ low = comparator;
3831
+ }
3832
+ });
3833
+ if (high.operator === comp || high.operator === ecomp) {
3834
+ return false;
3835
+ }
3836
+ if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
3837
+ return false;
3838
+ } else if (low.operator === ecomp && ltfn(version2, low.semver)) {
3839
+ return false;
3840
+ }
3841
+ }
3842
+ return true;
3843
+ }
3844
+ exports.prerelease = prerelease;
3845
+ function prerelease(version2, options) {
3846
+ var parsed = parse2(version2, options);
3847
+ return parsed && parsed.prerelease.length ? parsed.prerelease : null;
3848
+ }
3849
+ exports.intersects = intersects;
3850
+ function intersects(r1, r2, options) {
3851
+ r1 = new Range(r1, options);
3852
+ r2 = new Range(r2, options);
3853
+ return r1.intersects(r2);
3854
+ }
3855
+ exports.coerce = coerce;
3856
+ function coerce(version2, options) {
3857
+ if (version2 instanceof SemVer) {
3858
+ return version2;
3859
+ }
3860
+ if (typeof version2 === "number") {
3861
+ version2 = String(version2);
3862
+ }
3863
+ if (typeof version2 !== "string") {
3864
+ return null;
3865
+ }
3866
+ options = options || {};
3867
+ var match = null;
3868
+ if (!options.rtl) {
3869
+ match = version2.match(safeRe[t.COERCE]);
3870
+ } else {
3871
+ var next;
3872
+ while ((next = safeRe[t.COERCERTL].exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
3873
+ if (!match || next.index + next[0].length !== match.index + match[0].length) {
3874
+ match = next;
3875
+ }
3876
+ safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
3877
+ }
3878
+ safeRe[t.COERCERTL].lastIndex = -1;
3879
+ }
3880
+ if (match === null) {
3881
+ return null;
3882
+ }
3883
+ return parse2(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options);
3884
+ }
3885
+ }
3886
+ });
3887
+
2738
3888
  // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js
2739
3889
  var require_process = __commonJS({
2740
3890
  "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js"(exports, module2) {
@@ -2762,27 +3912,27 @@ var require_process = __commonJS({
2762
3912
  var require_filesystem = __commonJS({
2763
3913
  "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
2764
3914
  "use strict";
2765
- var fs13 = require("fs");
3915
+ var fs14 = require("fs");
2766
3916
  var LDD_PATH = "/usr/bin/ldd";
2767
3917
  var SELF_PATH = "/proc/self/exe";
2768
3918
  var MAX_LENGTH = 2048;
2769
3919
  var readFileSync2 = (path) => {
2770
- const fd = fs13.openSync(path, "r");
3920
+ const fd = fs14.openSync(path, "r");
2771
3921
  const buffer = Buffer.alloc(MAX_LENGTH);
2772
- const bytesRead = fs13.readSync(fd, buffer, 0, MAX_LENGTH, 0);
2773
- fs13.close(fd, () => {
3922
+ const bytesRead = fs14.readSync(fd, buffer, 0, MAX_LENGTH, 0);
3923
+ fs14.close(fd, () => {
2774
3924
  });
2775
3925
  return buffer.subarray(0, bytesRead);
2776
3926
  };
2777
3927
  var readFile2 = (path) => new Promise((resolve3, reject) => {
2778
- fs13.open(path, "r", (err, fd) => {
3928
+ fs14.open(path, "r", (err, fd) => {
2779
3929
  if (err) {
2780
3930
  reject(err);
2781
3931
  } else {
2782
3932
  const buffer = Buffer.alloc(MAX_LENGTH);
2783
- fs13.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
3933
+ fs14.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
2784
3934
  resolve3(buffer.subarray(0, bytesRead));
2785
- fs13.close(fd, () => {
3935
+ fs14.close(fd, () => {
2786
3936
  });
2787
3937
  });
2788
3938
  }
@@ -3226,16 +4376,15 @@ __export(src_exports, {
3226
4376
  });
3227
4377
  module.exports = __toCommonJS(src_exports);
3228
4378
  var import_assert = __toESM(require("assert"));
3229
- var import_child_process3 = require("child_process");
3230
- var import_fs14 = __toESM(require("fs"));
3231
- var import_path14 = require("path");
4379
+ var import_fs15 = __toESM(require("fs"));
4380
+ var import_path15 = require("path");
3232
4381
 
3233
4382
  // src/package-versions.ts
3234
- var VERCEL_RUNTIME_VERSION = "0.14.2";
3235
- var VERCEL_WORKERS_VERSION = "0.0.24";
4383
+ var VERCEL_RUNTIME_VERSION = "0.15.0";
4384
+ var VERCEL_WORKERS_VERSION = "0.0.25";
3236
4385
 
3237
4386
  // src/index.ts
3238
- var import_build_utils18 = require("@vercel/build-utils");
4387
+ var import_build_utils19 = require("@vercel/build-utils");
3239
4388
 
3240
4389
  // src/install.ts
3241
4390
  var import_execa3 = __toESM(require_execa());
@@ -3261,8 +4410,10 @@ var import_execa = __toESM(require_execa());
3261
4410
  var import_fs = __toESM(require("fs"));
3262
4411
  var import_os = __toESM(require("os"));
3263
4412
  var import_which = __toESM(require_lib());
4413
+ var import_semver = __toESM(require_semver2());
3264
4414
  var import_build_utils = require("@vercel/build-utils");
3265
4415
  var UV_VERSION = "0.10.11";
4416
+ var MIN_UV_VERSION = "0.9.25";
3266
4417
  var UV_PYTHON_PATH_PREFIX = "/uv/python/";
3267
4418
  var UV_PYTHON_DOWNLOADS_MODE = "automatic";
3268
4419
  var UV_CACHE_DIR_SUBPATH = [".vercel", "python", "cache", "uv"];
@@ -3516,7 +4667,39 @@ async function findUvBinary(pythonPath) {
3516
4667
  } catch (err) {
3517
4668
  (0, import_build_utils.debug)("Failed to resolve uv fallback paths", err);
3518
4669
  }
3519
- return null;
4670
+ return null;
4671
+ }
4672
+ function checkUvBinaryVersion(uvPath) {
4673
+ let output;
4674
+ try {
4675
+ output = (0, import_child_process.execFileSync)(uvPath, ["--version"], {
4676
+ encoding: "utf8",
4677
+ stdio: ["pipe", "pipe", "pipe"],
4678
+ shell: isWin
4679
+ }).trim();
4680
+ } catch (err) {
4681
+ throw new import_build_utils.NowBuildError({
4682
+ code: "UV_ERROR",
4683
+ link: "https://vercel.link/python-version",
4684
+ message: `Found uv at "${uvPath}" but could not run "uv --version": ${err instanceof Error ? err.message : String(err)}`
4685
+ });
4686
+ }
4687
+ const found = import_semver.default.coerce(output);
4688
+ if (!found) {
4689
+ throw new import_build_utils.NowBuildError({
4690
+ code: "UV_ERROR",
4691
+ link: "https://vercel.link/python-version",
4692
+ message: `Could not determine the uv version from "${output}".`
4693
+ });
4694
+ }
4695
+ if (import_semver.default.lt(found, MIN_UV_VERSION)) {
4696
+ throw new import_build_utils.NowBuildError({
4697
+ code: "UV_VERSION_TOO_OLD",
4698
+ link: "https://vercel.link/python-version",
4699
+ message: `Found uv ${found.version} at "${uvPath}", but Vercel requires uv ${MIN_UV_VERSION} or newer. Please upgrade uv: https://docs.astral.sh/uv/getting-started/installation/`
4700
+ });
4701
+ }
4702
+ return output;
3520
4703
  }
3521
4704
  async function getUvBinaryOrInstall(pythonPath) {
3522
4705
  const uvBin = await findUvBinary(pythonPath);
@@ -4466,30 +5649,31 @@ var import_execa4 = __toESM(require_execa());
4466
5649
  var import_build_utils6 = require("@vercel/build-utils");
4467
5650
  var import_fs5 = __toESM(require("fs"));
4468
5651
  var import_path6 = require("path");
5652
+
5653
+ // src/large-functions.ts
5654
+ function isLargeFunctionsEnabled() {
5655
+ const value = process.env.VERCEL_SUPPORT_LARGE_FUNCTIONS;
5656
+ return value === "1" || value === "true";
5657
+ }
5658
+
5659
+ // src/compileall.ts
4469
5660
  function isCompileAllEnabled() {
5661
+ if (!isLargeFunctionsEnabled())
5662
+ return false;
4470
5663
  const val = process.env.VERCEL_PYTHON_COMPILEALL;
4471
- if (val !== void 0 && val !== "") {
4472
- const lower = val.toLowerCase();
4473
- return lower === "1" || lower === "true";
4474
- }
4475
- const hive = process.env.VERCEL_PYTHON_ON_HIVE;
4476
- if (hive === "1" || hive === "true") {
4477
- return true;
4478
- }
4479
- return false;
5664
+ if (val === void 0 || val === "")
5665
+ return false;
5666
+ const lower = val.toLowerCase();
5667
+ return lower === "1" || lower === "true";
4480
5668
  }
4481
5669
  function shouldUseCompileAll({
4482
5670
  isDev,
4483
- hasCustomCommand
5671
+ hasCustomCommand,
5672
+ hasCustomBuildCommand
4484
5673
  }) {
4485
5674
  if (isDev)
4486
5675
  return false;
4487
- const val = process.env.VERCEL_PYTHON_COMPILEALL;
4488
- if (val !== void 0 && val !== "") {
4489
- const lower = val.toLowerCase();
4490
- return lower === "1" || lower === "true";
4491
- }
4492
- if (hasCustomCommand)
5676
+ if (hasCustomCommand || hasCustomBuildCommand)
4493
5677
  return false;
4494
5678
  return isCompileAllEnabled();
4495
5679
  }
@@ -4609,11 +5793,9 @@ function shouldStripVendorFile(filePath) {
4609
5793
  return true;
4610
5794
  return false;
4611
5795
  }
4612
- var LAMBDA_BASE_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
4613
- var OTEL_LAYER_RESERVATION_BYTES = 5 * 1024 * 1024;
4614
- var LAMBDA_SIZE_THRESHOLD_BYTES = process.env.VERCEL_DEPLOYMENT_HAS_OTEL_LAYER === "1" ? LAMBDA_BASE_SIZE_THRESHOLD_BYTES - OTEL_LAYER_RESERVATION_BYTES : LAMBDA_BASE_SIZE_THRESHOLD_BYTES;
5796
+ var LAMBDA_SIZE_THRESHOLD_BYTES = 225 * 1024 * 1024;
4615
5797
  var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
4616
- var HIVE_LAMBDA_SIZE_BYTES = 1 * 1024 * 1024 * 1024;
5798
+ var MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE = 5 * 1024 * 1024 * 1024;
4617
5799
  var BUNDLING_DOCS_LINK = "https://vercel.com/docs/functions/runtimes/python#controlling-what-gets-bundled";
4618
5800
  var PythonDependencyExternalizer = class {
4619
5801
  constructor(options) {
@@ -4639,20 +5821,20 @@ var PythonDependencyExternalizer = class {
4639
5821
  if (this.hasCustomCommand) {
4640
5822
  return false;
4641
5823
  }
4642
- const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
4643
- if (pythonOnHiveEnabled) {
5824
+ if (this.totalBundleSize <= LAMBDA_SIZE_THRESHOLD_BYTES || this.uvLockPath === null) {
4644
5825
  return false;
4645
- } else if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.uvLockPath !== null) {
4646
- return true;
4647
5826
  }
4648
- return false;
5827
+ if (isLargeFunctionsEnabled() && this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
5828
+ return false;
5829
+ }
5830
+ return true;
4649
5831
  }
4650
5832
  /**
4651
5833
  * Analyze the bundle: mirror all vendor files, calculate total size,
4652
5834
  * and determine whether runtime installation is needed.
4653
5835
  * Must be called before generateBundle().
4654
5836
  */
4655
- async analyze(files) {
5837
+ async analyze(files, options = {}) {
4656
5838
  this.sitePackageDirs = await getVenvSitePackagesDirs(this.venvPath);
4657
5839
  this.distributions = /* @__PURE__ */ new Map();
4658
5840
  for (const dir of this.sitePackageDirs) {
@@ -4675,25 +5857,28 @@ var PythonDependencyExternalizer = class {
4675
5857
  const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
4676
5858
  (0, import_build_utils7.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
4677
5859
  const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
4678
- const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
4679
- if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
5860
+ const largeFunctionsEnabled = isLargeFunctionsEnabled();
5861
+ options.onSized?.({
5862
+ totalSizeBytes: this.totalBundleSize,
5863
+ runtimeInstallEnabled
5864
+ });
5865
+ if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !largeFunctionsEnabled) {
4680
5866
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
4681
5867
  throw new import_build_utils7.NowBuildError({
4682
5868
  code: "LAMBDA_SIZE_EXCEEDED",
4683
- message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
5869
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
4684
5870
 
4685
- When using a custom install command, Vercel cannot automatically
4686
- optimize dependency bundling. To reduce the size of your
4687
- dependencies, you can:
4688
- 1. Remove unused dependencies from your project.
4689
- 2. Remove the custom install command to allow Vercel to manage
4690
- and optimize dependencies automatically.`,
5871
+ A custom install command prevents Vercel from optimizing your
5872
+ function bundle size automatically. To fix this, you can:
5873
+ 1. Remove unused dependencies from your project, or
5874
+ 2. Remove the custom install command so Vercel can optimize
5875
+ the function bundle automatically.`,
4691
5876
  link: BUNDLING_DOCS_LINK,
4692
5877
  action: "Learn More"
4693
5878
  });
4694
5879
  }
4695
- if (pythonOnHiveEnabled && this.totalBundleSize > HIVE_LAMBDA_SIZE_BYTES) {
4696
- const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
5880
+ if (largeFunctionsEnabled && this.totalBundleSize >= MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE) {
5881
+ const limitMB = (MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE / (1024 * 1024)).toFixed(0);
4697
5882
  throw new import_build_utils7.NowBuildError({
4698
5883
  code: "LAMBDA_SIZE_EXCEEDED",
4699
5884
  message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
@@ -4715,6 +5900,10 @@ application into smaller functions.`,
4715
5900
  * Mutates `files` in place: adds vendor files (private + knapsack-selected
4716
5901
  * public), runtime config, and uv binary.
4717
5902
  * Must be called after analyze().
5903
+ *
5904
+ * If large functions are allowed and the bundle can't fit AWS Lambda, falls
5905
+ * back to bundling everything for Hive and returns `fellBackToFullBundle:
5906
+ * true` so the caller can apply the same compileall handling.
4718
5907
  */
4719
5908
  async generateBundle(files) {
4720
5909
  if (!this.analyzed) {
@@ -4723,54 +5912,49 @@ application into smaller functions.`,
4723
5912
  );
4724
5913
  }
4725
5914
  if (!this.uvLockPath || !this.uvProjectDir) {
4726
- throw new import_build_utils7.NowBuildError({
4727
- code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4728
- message: "Runtime dependency installation requires a uv.lock file and project directory."
4729
- });
5915
+ throw new Error(
5916
+ "generateBundle() requires uvLockPath and uvProjectDir to be set"
5917
+ );
4730
5918
  }
4731
5919
  const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
4732
- console.log(
4733
- `Bundle size (${totalBundleSizeMB} MB) exceeds limit. Enabling runtime dependency installation.`
4734
- );
5920
+ const largeFunctionsEnabled = isLargeFunctionsEnabled();
4735
5921
  if (this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
4736
- const ephemeralLimitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(0);
5922
+ if (largeFunctionsEnabled) {
5923
+ return this.bundleAllForHive(files);
5924
+ }
5925
+ const limitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(
5926
+ 0
5927
+ );
4737
5928
  throw new import_build_utils7.NowBuildError({
4738
5929
  code: "LAMBDA_SIZE_EXCEEDED",
4739
- message: `Total bundle size (${totalBundleSizeMB} MB) exceeds Lambda ephemeral storage limit (${ephemeralLimitMB} MB).
5930
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size (${limitMB} MB).
4740
5931
 
4741
- Even with runtime dependency installation, all packages must fit
4742
- within the ${ephemeralLimitMB} MB ephemeral storage available to Lambda
4743
- functions. Consider removing unused dependencies or splitting
4744
- your application into smaller functions.`,
5932
+ Reduce the size of your dependencies or split your application into
5933
+ smaller functions.`,
4745
5934
  link: BUNDLING_DOCS_LINK,
4746
5935
  action: "Learn More"
4747
5936
  });
4748
5937
  }
5938
+ const relLockPath = (0, import_path7.relative)(this.workPath, this.uvLockPath);
4749
5939
  let lockContent;
4750
5940
  try {
4751
5941
  lockContent = await readFile(this.uvLockPath, "utf8");
4752
5942
  } catch (error) {
4753
- if (error instanceof Error) {
4754
- console.log(
4755
- `Failed to read uv.lock file at "${this.uvLockPath}": ${error.message}`
4756
- );
4757
- } else {
4758
- console.log(
4759
- `Failed to read uv.lock file at "${this.uvLockPath}": ${String(error)}`
4760
- );
4761
- }
5943
+ (0, import_build_utils7.debug)(
5944
+ `Failed to read uv.lock at ${this.uvLockPath}: ${error instanceof Error ? error.message : String(error)}`
5945
+ );
4762
5946
  throw new import_build_utils7.NowBuildError({
4763
5947
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4764
- message: `Failed to read uv.lock file at "${this.uvLockPath}"`
5948
+ message: `Failed to read the uv.lock file at "${relLockPath}".`
4765
5949
  });
4766
5950
  }
4767
5951
  let lockFile;
4768
5952
  try {
4769
- lockFile = (0, import_python_analysis3.parseUvLock)(lockContent, this.uvLockPath);
5953
+ lockFile = (0, import_python_analysis3.parseUvLock)(lockContent, relLockPath);
4770
5954
  } catch (error) {
4771
5955
  if (error instanceof import_python_analysis3.PythonAnalysisError) {
4772
5956
  if (error.fileContent) {
4773
- console.log(
5957
+ (0, import_build_utils7.debug)(
4774
5958
  `Failed to parse "${error.path}". File content:
4775
5959
  ${error.fileContent}`
4776
5960
  );
@@ -4812,19 +5996,18 @@ ${error.fileContent}`
4812
5996
  (name) => !forceBundledSet.has((0, import_python_analysis3.normalizePackageName)(name))
4813
5997
  );
4814
5998
  if (externalizablePublic.length === 0) {
5999
+ if (largeFunctionsEnabled) {
6000
+ return this.bundleAllForHive(files);
6001
+ }
4815
6002
  throw new import_build_utils7.NowBuildError({
4816
6003
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4817
- message: `Bundle size exceeds the Lambda limit and requires runtime
4818
- dependency installation, but no public packages have compatible
4819
- pre-built wheels for the Lambda platform.
4820
-
4821
- Runtime dependency installation requires packages to have binary
4822
- wheels.
6004
+ message: `Total bundle size (${totalBundleSizeMB} MB) exceeds the maximum function size and
6005
+ can't be optimized automatically because some dependencies don't
6006
+ provide a compatible pre-built wheel.
4823
6007
 
4824
6008
  To fix this, either:
4825
6009
  1. Regenerate your lock file with: uv lock --upgrade, or
4826
- 2. Switch the problematic packages to ones that have pre-built
4827
- wheels available.`
6010
+ 2. Replace the packages that don't provide a pre-built wheel.`
4828
6011
  });
4829
6012
  }
4830
6013
  const packageSizes = await this.calculatePerPackageSizes();
@@ -4869,6 +6052,12 @@ To fix this, either:
4869
6052
  (0, import_build_utils7.debug)(
4870
6053
  `Fixed overhead: ${(fixedOverhead / (1024 * 1024)).toFixed(2)} MB, runtime tooling: ${(runtimeToolingOverhead / (1024 * 1024)).toFixed(2)} MB, remaining capacity for public packages: ${(remainingCapacity / (1024 * 1024)).toFixed(2)} MB`
4871
6054
  );
6055
+ if (largeFunctionsEnabled && remainingCapacity < 0) {
6056
+ return this.bundleAllForHive(files);
6057
+ }
6058
+ console.log(
6059
+ `Bundle size (${totalBundleSizeMB} MB) exceeds the standard size; optimizing dependencies.`
6060
+ );
4872
6061
  const externalizableSet = new Set(
4873
6062
  externalizablePublic.map(import_python_analysis3.normalizePackageName)
4874
6063
  );
@@ -4922,27 +6111,54 @@ To fix this, either:
4922
6111
  });
4923
6112
  (0, import_build_utils7.debug)(`Bundled uv binary from ${uvBinaryPath} to ${uvLocalPath}`);
4924
6113
  } catch (err) {
6114
+ (0, import_build_utils7.debug)(
6115
+ `Failed to bundle uv binary: ${err instanceof Error ? err.message : String(err)}`
6116
+ );
4925
6117
  throw new import_build_utils7.NowBuildError({
4926
6118
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4927
- message: `Failed to bundle uv binary for runtime installation: ${err instanceof Error ? err.message : String(err)}`
6119
+ message: "Failed to prepare dependency tooling."
4928
6120
  });
4929
6121
  }
4930
6122
  const finalBundleSize = await calculateBundleSize(files);
4931
6123
  if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES + 100 * 1024) {
6124
+ if (largeFunctionsEnabled) {
6125
+ return this.bundleAllForHive(files);
6126
+ }
4932
6127
  const finalSizeMB = (finalBundleSize / (1024 * 1024)).toFixed(2);
4933
6128
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
4934
6129
  throw new import_build_utils7.NowBuildError({
4935
6130
  code: "LAMBDA_SIZE_EXCEEDED",
4936
- message: `Total bundle size (${finalSizeMB} MB) exceeds Lambda limit (${limitMB} MB) even after
4937
- deferring public packages to runtime installation.
6131
+ message: `Total bundle size (${finalSizeMB} MB) exceeds the maximum function size (${limitMB} MB) even after
6132
+ optimizing dependencies.
4938
6133
 
4939
- This usually means your private packages or source code are too
4940
- large. Consider reducing the size of private dependencies or
4941
- splitting your application.`,
6134
+ This usually means your source code or private packages are too
6135
+ large. Reduce their size or split your application into smaller
6136
+ functions.`,
4942
6137
  link: BUNDLING_DOCS_LINK,
4943
6138
  action: "Learn More"
4944
6139
  });
4945
6140
  }
6141
+ return { fellBackToFullBundle: false };
6142
+ }
6143
+ /**
6144
+ * Discard any runtime-install artifacts added so far and bundle every
6145
+ * dependency directly, for a function that will run on Hive. Returns the
6146
+ * fell-back signal so the caller can apply the same compileall handling.
6147
+ */
6148
+ bundleAllForHive(files) {
6149
+ for (const key of [
6150
+ `${UV_BUNDLE_DIR}/_runtime_config.json`,
6151
+ `${UV_BUNDLE_DIR}/uv`,
6152
+ `${UV_BUNDLE_DIR}/pyproject.toml`,
6153
+ `${UV_BUNDLE_DIR}/uv.lock`
6154
+ ]) {
6155
+ delete files[key];
6156
+ }
6157
+ for (const [p, f] of Object.entries(this.allVendorFiles)) {
6158
+ files[p] = f;
6159
+ }
6160
+ (0, import_build_utils7.debug)("Bundling all dependencies for the large functions path.");
6161
+ return { fellBackToFullBundle: true };
4946
6162
  }
4947
6163
  /**
4948
6164
  * Identify public packages that have no compatible wheel for the Lambda platform.
@@ -6603,6 +7819,9 @@ var startDevServer = async (opts) => {
6603
7819
  try {
6604
7820
  const { pythonPath: systemPython } = getDefaultPythonVersion(meta);
6605
7821
  const uvPath = await findUvBinary(systemPython);
7822
+ if (uvPath) {
7823
+ checkUvBinaryVersion(uvPath);
7824
+ }
6606
7825
  const venv = isInVirtualEnv();
6607
7826
  const serviceCount = meta.serviceCount ?? 0;
6608
7827
  const pythonServiceCount = meta.pythonServiceCount ?? 1;
@@ -7360,7 +8579,177 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
7360
8579
 
7361
8580
  // src/index.ts
7362
8581
  var import_python_analysis9 = require("@vercel/python-analysis");
7363
- var writeFile = import_fs14.default.promises.writeFile;
8582
+
8583
+ // src/subscribers.ts
8584
+ var import_path14 = require("path");
8585
+ var import_fs14 = __toESM(require("fs"));
8586
+ var import_build_utils18 = require("@vercel/build-utils");
8587
+ var SUBSCRIBER_NAME_RE = /^[A-Za-z]([A-Za-z0-9_-]*[A-Za-z0-9])?$/;
8588
+ var MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
8589
+ var TRIGGER_NUMBER_FIELDS = [
8590
+ {
8591
+ field: "max_deliveries",
8592
+ output: "maxDeliveries",
8593
+ isValid: (value) => Number.isInteger(value) && value >= 1,
8594
+ expected: "an integer greater than or equal to 1"
8595
+ },
8596
+ {
8597
+ field: "retry_after_seconds",
8598
+ output: "retryAfterSeconds",
8599
+ isValid: (value) => value > 0,
8600
+ expected: "greater than 0"
8601
+ },
8602
+ {
8603
+ field: "initial_delay_seconds",
8604
+ output: "initialDelaySeconds",
8605
+ isValid: (value) => value >= 0,
8606
+ expected: "greater than or equal to 0"
8607
+ },
8608
+ {
8609
+ field: "max_concurrency",
8610
+ output: "maxConcurrency",
8611
+ isValid: (value) => Number.isInteger(value) && value >= 1,
8612
+ expected: "an integer greater than or equal to 1"
8613
+ }
8614
+ ];
8615
+ var SUBSCRIBER_FIELD_NAMES = /* @__PURE__ */ new Set([
8616
+ "entrypoint",
8617
+ "topics",
8618
+ ...TRIGGER_NUMBER_FIELDS.map(({ field }) => field)
8619
+ ]);
8620
+ function safePathSegment(value) {
8621
+ return [...value].map((char) => {
8622
+ if (char === "_") {
8623
+ return "__";
8624
+ }
8625
+ return /[A-Za-z0-9-]/.test(char) ? char : `_${char.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`;
8626
+ }).join("");
8627
+ }
8628
+ async function getPyprojectSubscribers(workPath) {
8629
+ const pyprojectPath = (0, import_path14.join)(workPath, "pyproject.toml");
8630
+ if (!import_fs14.default.existsSync(pyprojectPath)) {
8631
+ return [];
8632
+ }
8633
+ const pyproject = await (0, import_build_utils18.readConfigFile)(pyprojectPath);
8634
+ const subscribers = pyproject?.tool?.vercel?.subscribers;
8635
+ if (!subscribers) {
8636
+ return [];
8637
+ }
8638
+ if (typeof subscribers !== "object" || Array.isArray(subscribers)) {
8639
+ throw subscriberError('"tool.vercel.subscribers" must be an object');
8640
+ }
8641
+ return Promise.all(
8642
+ Object.entries(subscribers).map(
8643
+ ([name, config]) => parseSubscriber(workPath, name, config)
8644
+ )
8645
+ );
8646
+ }
8647
+ async function parseSubscriber(workPath, name, config) {
8648
+ if (!SUBSCRIBER_NAME_RE.test(name)) {
8649
+ throw subscriberError(
8650
+ `subscriber name "${name}" is invalid. Names must start with a letter, end with an alphanumeric character, and contain only alphanumeric characters, hyphens, and underscores`
8651
+ );
8652
+ }
8653
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
8654
+ throw subscriberError(`subscriber "${name}" must be an object`);
8655
+ }
8656
+ for (const key of Object.keys(config)) {
8657
+ if (!SUBSCRIBER_FIELD_NAMES.has(key)) {
8658
+ throw subscriberError(
8659
+ `subscriber "${name}" has unrecognized field "${key}"`
8660
+ );
8661
+ }
8662
+ }
8663
+ if (typeof config.entrypoint !== "string") {
8664
+ throw subscriberError(
8665
+ `subscriber "${name}" must define string field "entrypoint"`
8666
+ );
8667
+ }
8668
+ const entrypoint = parseEntrypoint(name, config.entrypoint);
8669
+ const existingEntrypoint = await resolveExistingEntrypoint(
8670
+ workPath,
8671
+ entrypoint.filePath
8672
+ );
8673
+ if (!existingEntrypoint) {
8674
+ throw subscriberError(
8675
+ `subscriber "${name}" has entrypoint "${config.entrypoint}" but file "${entrypoint.filePath}" does not exist`
8676
+ );
8677
+ }
8678
+ return {
8679
+ name,
8680
+ entrypoint: existingEntrypoint,
8681
+ moduleName: entrypoint.moduleName,
8682
+ variableName: entrypoint.variableName,
8683
+ topics: parseTopics(name, config.topics),
8684
+ triggerDefaults: parseTriggerDefaults(name, config)
8685
+ };
8686
+ }
8687
+ function parseEntrypoint(name, value) {
8688
+ const match = MODULE_ATTR_RE.exec(value);
8689
+ if (!match) {
8690
+ throw subscriberError(
8691
+ `subscriber "${name}" has invalid entrypoint "${value}". Use "module:object"`
8692
+ );
8693
+ }
8694
+ return {
8695
+ moduleName: match[1],
8696
+ variableName: match[2],
8697
+ filePath: `${match[1].replace(/\./g, "/")}.py`
8698
+ };
8699
+ }
8700
+ async function resolveExistingEntrypoint(workPath, filePath) {
8701
+ const candidates = [filePath, filePath.replace(/\.py$/i, "/__init__.py")];
8702
+ for (const candidate of candidates) {
8703
+ try {
8704
+ const stat = await import_fs14.default.promises.stat((0, import_path14.join)(workPath, candidate));
8705
+ if (stat.isFile()) {
8706
+ return candidate;
8707
+ }
8708
+ } catch {
8709
+ }
8710
+ }
8711
+ return null;
8712
+ }
8713
+ function parseTopics(name, value) {
8714
+ if (!Array.isArray(value) || value.length === 0) {
8715
+ throw subscriberError(
8716
+ `subscriber "${name}" must define non-empty array field "topics"`
8717
+ );
8718
+ }
8719
+ for (const topic of value) {
8720
+ if (typeof topic !== "string" || topic.length === 0) {
8721
+ throw subscriberError(
8722
+ `subscriber "${name}" field "topics" must contain only non-empty strings`
8723
+ );
8724
+ }
8725
+ }
8726
+ return value;
8727
+ }
8728
+ function parseTriggerDefaults(subscriber, config) {
8729
+ const defaults = {};
8730
+ for (const { field, output, isValid, expected } of TRIGGER_NUMBER_FIELDS) {
8731
+ const value = config[field];
8732
+ if (value === void 0) {
8733
+ continue;
8734
+ }
8735
+ if (typeof value !== "number" || !isValid(value)) {
8736
+ throw subscriberError(
8737
+ `subscriber "${subscriber}" field "${field}" must be ${expected}`
8738
+ );
8739
+ }
8740
+ defaults[output] = value;
8741
+ }
8742
+ return defaults;
8743
+ }
8744
+ function subscriberError(message) {
8745
+ return new import_build_utils18.NowBuildError({
8746
+ code: "PYTHON_INVALID_SUBSCRIBER_CONFIG",
8747
+ message
8748
+ });
8749
+ }
8750
+
8751
+ // src/index.ts
8752
+ var writeFile = import_fs15.default.promises.writeFile;
7364
8753
  var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
7365
8754
  var version = -1;
7366
8755
  function addFiles(target, source) {
@@ -7424,7 +8813,7 @@ var frameworkHooks = {
7424
8813
  detected
7425
8814
  }) => {
7426
8815
  if (detected?.baseDir === void 0) {
7427
- (0, import_build_utils18.debug)("Django hook: no manage.py detected, skipping");
8816
+ (0, import_build_utils19.debug)("Django hook: no manage.py detected, skipping");
7428
8817
  return;
7429
8818
  }
7430
8819
  let settingsResult;
@@ -7438,13 +8827,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
7438
8827
  } else {
7439
8828
  detail = err?.stderr || err?.message || String(err);
7440
8829
  }
7441
- throw new import_build_utils18.NowBuildError({
8830
+ throw new import_build_utils19.NowBuildError({
7442
8831
  code: "DJANGO_SETTINGS_FAILED",
7443
8832
  message: `Failed to read Django application settings from ${projectDir}/manage.py:
7444
8833
  ${detail}`
7445
8834
  });
7446
8835
  }
7447
- (0, import_build_utils18.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
8836
+ (0, import_build_utils19.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
7448
8837
  const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
7449
8838
  if (djangoVersion) {
7450
8839
  console.log(`Django ${djangoVersion.join(".")} detected`);
@@ -7457,7 +8846,7 @@ ${detail}`
7457
8846
  const variableName = parts.at(-1);
7458
8847
  const rel = `${parts.slice(0, -1).join("/")}.py`;
7459
8848
  const ep = baseDir ? `${baseDir}/${rel}` : rel;
7460
- (0, import_build_utils18.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
8849
+ (0, import_build_utils19.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
7461
8850
  resolvedEntrypoint = { entrypoint: ep, variableName };
7462
8851
  } else {
7463
8852
  const wsgiApp = djangoSettings["WSGI_APPLICATION"];
@@ -7466,7 +8855,7 @@ ${detail}`
7466
8855
  const variableName = parts.at(-1);
7467
8856
  const rel = `${parts.slice(0, -1).join("/")}.py`;
7468
8857
  const ep = baseDir ? `${baseDir}/${rel}` : rel;
7469
- (0, import_build_utils18.debug)(
8858
+ (0, import_build_utils19.debug)(
7470
8859
  `Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
7471
8860
  );
7472
8861
  resolvedEntrypoint = { entrypoint: ep, variableName };
@@ -7474,7 +8863,7 @@ ${detail}`
7474
8863
  }
7475
8864
  let djangoStatic = null;
7476
8865
  if (workPath && venvPath) {
7477
- const outputStaticDir = (0, import_path14.join)(workPath, ".vercel", "output", "static");
8866
+ const outputStaticDir = (0, import_path15.join)(workPath, ".vercel", "output", "static");
7478
8867
  djangoStatic = await runDjangoCollectStatic(
7479
8868
  venvPath,
7480
8869
  workPath,
@@ -7488,29 +8877,78 @@ ${detail}`
7488
8877
  return { entrypoint: resolvedEntrypoint, djangoStatic };
7489
8878
  }
7490
8879
  };
8880
+ function createRuntimeTrampoline({
8881
+ moduleName,
8882
+ entrypoint,
8883
+ vendorDir,
8884
+ variableName,
8885
+ extraEnv = []
8886
+ }) {
8887
+ const extraEnvLines = extraEnv.map((line) => `,
8888
+ ${line}`).join("");
8889
+ return `
8890
+ import importlib
8891
+ import os
8892
+ import os.path
8893
+ import site
8894
+ import sys
8895
+
8896
+ _here = os.path.dirname(__file__)
8897
+
8898
+ os.environ.update({
8899
+ "__VC_HANDLER_MODULE_NAME": "${moduleName}",
8900
+ "__VC_HANDLER_ENTRYPOINT": "${entrypoint}",
8901
+ "__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypoint}"),
8902
+ "__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
8903
+ "__VC_HANDLER_VARIABLE_NAME": "${variableName}"${extraEnvLines}
8904
+ })
8905
+
8906
+ _vendor_rel = '${vendorDir}'
8907
+ _vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
8908
+
8909
+ if os.path.isdir(_vendor):
8910
+ # Process .pth files like a real site-packages dir
8911
+ site.addsitedir(_vendor)
8912
+
8913
+ # Move _vendor to the front (after script dir if present)
8914
+ try:
8915
+ while _vendor in sys.path:
8916
+ sys.path.remove(_vendor)
8917
+ except ValueError:
8918
+ pass
8919
+
8920
+ # Put vendored deps ahead of site-packages but after the script dir
8921
+ idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
8922
+ sys.path.insert(idx, _vendor)
8923
+
8924
+ importlib.invalidate_caches()
8925
+
8926
+ from vercel_runtime.vc_init import vc_handler
8927
+ `;
8928
+ }
7491
8929
  async function downloadFilesInWorkPath({
7492
8930
  entrypoint,
7493
8931
  workPath,
7494
8932
  files,
7495
8933
  meta = {}
7496
8934
  }) {
7497
- (0, import_build_utils18.debug)("Downloading user files...");
7498
- let downloadedFiles = await (0, import_build_utils18.download)(files, workPath, meta);
8935
+ (0, import_build_utils19.debug)("Downloading user files...");
8936
+ let downloadedFiles = await (0, import_build_utils19.download)(files, workPath, meta);
7499
8937
  if (meta.isDev && entrypoint) {
7500
8938
  const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
7501
8939
  if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
7502
- throw new import_build_utils18.NowBuildError({
8940
+ throw new import_build_utils19.NowBuildError({
7503
8941
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
7504
8942
  message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
7505
8943
  link: PYTHON_ENTRYPOINT_DOCS_URL2,
7506
8944
  action: "Learn More"
7507
8945
  });
7508
8946
  }
7509
- const { devCacheDir = (0, import_path14.join)(workPath, ".now", "cache") } = meta;
7510
- const cacheKey = (0, import_path14.basename)(entrypoint).replace(/\./g, "_");
7511
- const destCache = (0, import_path14.join)(devCacheDir, cacheKey);
7512
- await (0, import_build_utils18.download)(downloadedFiles, destCache);
7513
- downloadedFiles = await (0, import_build_utils18.glob)("**", destCache);
8947
+ const { devCacheDir = (0, import_path15.join)(workPath, ".now", "cache") } = meta;
8948
+ const cacheKey = (0, import_path15.basename)(entrypoint).replace(/\./g, "_");
8949
+ const destCache = (0, import_path15.join)(devCacheDir, cacheKey);
8950
+ await (0, import_build_utils19.download)(downloadedFiles, destCache);
8951
+ downloadedFiles = await (0, import_build_utils19.glob)("**", destCache);
7514
8952
  workPath = destCache;
7515
8953
  }
7516
8954
  return workPath;
@@ -7543,11 +8981,11 @@ async function installInjectedPackage({
7543
8981
  projectDir,
7544
8982
  pipPlatformArgs
7545
8983
  }) {
7546
- const localDir = (0, import_path14.join)(__dirname, "..", "..", "..", "python", name);
7547
- const isLocalDev = import_fs14.default.existsSync((0, import_path14.join)(localDir, "pyproject.toml"));
8984
+ const localDir = (0, import_path15.join)(__dirname, "..", "..", "..", "python", name);
8985
+ const isLocalDev = import_fs15.default.existsSync((0, import_path15.join)(localDir, "pyproject.toml"));
7548
8986
  const dep = envOverride || (isLocalDev ? localDir : pinned);
7549
8987
  const noExclude = ["--exclude-newer-package", `${name}=false`];
7550
- (0, import_build_utils18.debug)(`Installing ${dep}`);
8988
+ (0, import_build_utils19.debug)(`Installing ${dep}`);
7551
8989
  await uv.pip({
7552
8990
  venvPath,
7553
8991
  projectDir,
@@ -7573,23 +9011,29 @@ var build = async ({
7573
9011
  registerPreDeploy
7574
9012
  }) => {
7575
9013
  let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
7576
- const builderSpan = parentSpan ?? new import_build_utils18.Span({ name: "vc.builder" });
9014
+ const builderSpan = parentSpan ?? new import_build_utils19.Span({ name: "vc.builder" });
7577
9015
  const framework = config?.framework;
7578
- const shouldInstallVercelWorkers = config?.hasWorkerServices === true;
9016
+ let shouldInstallVercelWorkers = config?.hasWorkerServices === true;
9017
+ let subscribers = [];
7579
9018
  let spawnEnv;
7580
9019
  let projectInstallCommand;
7581
9020
  let hasCustomCommand = false;
9021
+ let hasCustomBuildCommand = false;
7582
9022
  const target = getTargetPlatform(meta.isDev ?? false);
7583
- (0, import_build_utils18.debug)(`workPath: ${workPath}`);
9023
+ (0, import_build_utils19.debug)(`workPath: ${workPath}`);
7584
9024
  workPath = await downloadFilesInWorkPath({
7585
9025
  workPath,
7586
9026
  files: originalFiles,
7587
9027
  entrypoint,
7588
9028
  meta
7589
9029
  });
9030
+ if (!service && (0, import_build_utils19.isPythonFramework)(framework)) {
9031
+ subscribers = await getPyprojectSubscribers(workPath);
9032
+ shouldInstallVercelWorkers ||= subscribers.length > 0;
9033
+ }
7590
9034
  try {
7591
9035
  if (meta.isDev) {
7592
- const setupCfg = (0, import_path14.join)(workPath, "setup.cfg");
9036
+ const setupCfg = (0, import_path15.join)(workPath, "setup.cfg");
7593
9037
  await writeFile(setupCfg, "[install]\nprefix=\n");
7594
9038
  }
7595
9039
  } catch (err) {
@@ -7605,15 +9049,15 @@ var build = async ({
7605
9049
  filePath: entrypoint,
7606
9050
  // For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
7607
9051
  // For other services, handlerFunction is used as the entrypoint variable name.
7608
- varName: service && (0, import_build_utils18.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
9052
+ varName: service && (0, import_build_utils19.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
7609
9053
  } : void 0,
7610
9054
  service
7611
9055
  ) ?? void 0;
7612
9056
  if (detected?.error && detected?.baseDir === void 0) {
7613
9057
  throw detected?.error;
7614
9058
  }
7615
- const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path14.dirname)(entrypoint) : ".");
7616
- const entrypointAbsDir = (0, import_path14.join)(workPath, entryDirectory);
9059
+ const entryDirectory = detected?.baseDir ?? (entrypoint ? (0, import_path15.dirname)(entrypoint) : ".");
9060
+ const entrypointAbsDir = (0, import_path15.join)(workPath, entryDirectory);
7617
9061
  const rootDir = repoRootPath ?? workPath;
7618
9062
  const pythonPackage = await builderSpan.child("vc.builder.python.discover").trace(
7619
9063
  () => discoverPackage({
@@ -7646,22 +9090,20 @@ var build = async ({
7646
9090
  try {
7647
9091
  const uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
7648
9092
  uv = new UvRunner(uvPath, uvCacheDir);
7649
- const uvVersionOutput = (0, import_child_process3.execSync)(`${uvPath} --version`, {
7650
- encoding: "utf8"
7651
- }).trim();
7652
- console.log(`Using ${uvVersionOutput}`);
7653
9093
  } catch (err) {
7654
9094
  console.log("Failed to install or locate uv");
7655
9095
  throw new Error(
7656
9096
  `uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
7657
9097
  );
7658
9098
  }
7659
- const venvPath = service?.name ? (0, import_path14.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path14.join)(workPath, ".vercel", "python", ".venv");
7660
- const hasCachedVenv = import_fs14.default.existsSync((0, import_path14.join)(venvPath, "pyvenv.cfg"));
7661
- const hasCachedUv = import_fs14.default.existsSync(uvCacheDir);
9099
+ const uvVersion = checkUvBinaryVersion(uv.getPath());
9100
+ console.log(`Using ${uvVersion}`);
9101
+ const venvPath = service?.name ? (0, import_path15.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path15.join)(workPath, ".vercel", "python", ".venv");
9102
+ const hasCachedVenv = import_fs15.default.existsSync((0, import_path15.join)(venvPath, "pyvenv.cfg"));
9103
+ const hasCachedUv = import_fs15.default.existsSync(uvCacheDir);
7662
9104
  const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
7663
9105
  if (hasCachedVenv || hasCachedUv) {
7664
- (0, import_build_utils18.debug)(
9106
+ (0, import_build_utils19.debug)(
7665
9107
  `Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
7666
9108
  );
7667
9109
  }
@@ -7673,14 +9115,14 @@ var build = async ({
7673
9115
  uvCacheDir
7674
9116
  });
7675
9117
  });
7676
- if ((0, import_build_utils18.isPythonFramework)(framework)) {
9118
+ if ((0, import_build_utils19.isPythonFramework)(framework)) {
7677
9119
  const {
7678
9120
  cliType,
7679
9121
  lockfileVersion,
7680
9122
  packageJsonPackageManager,
7681
9123
  turboSupportsCorepackHome
7682
- } = await (0, import_build_utils18.scanParentDirs)(workPath, true);
7683
- spawnEnv = (0, import_build_utils18.getEnvForPackageManager)({
9124
+ } = await (0, import_build_utils19.scanParentDirs)(workPath, true);
9125
+ spawnEnv = (0, import_build_utils19.getEnvForPackageManager)({
7684
9126
  cliType,
7685
9127
  lockfileVersion,
7686
9128
  packageJsonPackageManager,
@@ -7705,13 +9147,13 @@ var build = async ({
7705
9147
  let uvLockPath = null;
7706
9148
  let uvProjectDir = null;
7707
9149
  let projectName;
7708
- await builderSpan.child(import_build_utils18.BUILDER_INSTALLER_STEP, {
9150
+ await builderSpan.child(import_build_utils19.BUILDER_INSTALLER_STEP, {
7709
9151
  installCommand: projectInstallCommand || void 0,
7710
9152
  runtime: "python",
7711
9153
  "python.cache.restored": restoredCache
7712
9154
  }).trace(async () => {
7713
9155
  if (projectInstallCommand) {
7714
- await import_fs14.default.promises.rm(venvPath, { recursive: true, force: true });
9156
+ await import_fs15.default.promises.rm(venvPath, { recursive: true, force: true });
7715
9157
  await ensureVenv({
7716
9158
  pythonVersion,
7717
9159
  venvPath,
@@ -7722,7 +9164,7 @@ var build = async ({
7722
9164
  console.log(
7723
9165
  `Running "install" command: \`${projectInstallCommand}\`...`
7724
9166
  );
7725
- await (0, import_build_utils18.execCommand)(projectInstallCommand, {
9167
+ await (0, import_build_utils19.execCommand)(projectInstallCommand, {
7726
9168
  env: pythonEnv,
7727
9169
  cwd: workPath
7728
9170
  });
@@ -7743,7 +9185,7 @@ var build = async ({
7743
9185
  }
7744
9186
  if (!assumeDepsInstalled) {
7745
9187
  const lockCacheKey = service?.name ? `uv.lock.${service.name}` : "uv.lock";
7746
- const cachedLockPath = (0, import_path14.join)(uvCacheDir, lockCacheKey);
9188
+ const cachedLockPath = (0, import_path15.join)(uvCacheDir, lockCacheKey);
7747
9189
  const { projectDir, lockPath, lockFileProvidedByUser } = await ensureUvProject({
7748
9190
  workPath,
7749
9191
  rootDir,
@@ -7764,36 +9206,40 @@ var build = async ({
7764
9206
  locked: !lockFileProvidedByUser,
7765
9207
  pythonPlatform: target.uvPlatform
7766
9208
  });
7767
- if (lockPath && import_fs14.default.existsSync(lockPath)) {
7768
- await import_fs14.default.promises.mkdir(uvCacheDir, { recursive: true });
7769
- await import_fs14.default.promises.copyFile(lockPath, cachedLockPath);
9209
+ if (lockPath && import_fs15.default.existsSync(lockPath)) {
9210
+ await import_fs15.default.promises.mkdir(uvCacheDir, { recursive: true });
9211
+ await import_fs15.default.promises.copyFile(lockPath, cachedLockPath);
7770
9212
  }
7771
9213
  }
7772
9214
  });
7773
- if ((0, import_build_utils18.isPythonFramework)(framework)) {
9215
+ if ((0, import_build_utils19.isPythonFramework)(framework)) {
7774
9216
  const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
7775
9217
  config?.buildCommand;
7776
- await builderSpan.child(import_build_utils18.BUILDER_COMPILE_STEP, {
9218
+ await builderSpan.child(import_build_utils19.BUILDER_COMPILE_STEP, {
7777
9219
  buildCommand: projectBuildCommand || void 0
7778
9220
  }).trace(async () => {
7779
9221
  if (projectBuildCommand) {
7780
9222
  console.log(`Running "${projectBuildCommand}"`);
7781
- await (0, import_build_utils18.execCommand)(projectBuildCommand, {
9223
+ await (0, import_build_utils19.execCommand)(projectBuildCommand, {
7782
9224
  env: pythonEnv,
7783
9225
  cwd: workPath
7784
9226
  });
9227
+ hasCustomBuildCommand = true;
7785
9228
  } else {
7786
- await runPyprojectScript(
9229
+ const ranBuildScript = await runPyprojectScript(
7787
9230
  workPath,
7788
9231
  ["vercel-build", "now-build", "build"],
7789
9232
  pythonEnv
7790
9233
  );
9234
+ if (ranBuildScript) {
9235
+ hasCustomBuildCommand = true;
9236
+ }
7791
9237
  }
7792
9238
  });
7793
9239
  }
7794
9240
  const hookResult = await runFrameworkHook(framework, {
7795
9241
  pythonEnv,
7796
- projectDir: (0, import_path14.join)(workPath, entryDirectory),
9242
+ projectDir: (0, import_path15.join)(workPath, entryDirectory),
7797
9243
  workPath,
7798
9244
  venvPath,
7799
9245
  entrypoint,
@@ -7805,7 +9251,7 @@ var build = async ({
7805
9251
  }
7806
9252
  entrypoint = resolved?.entrypoint;
7807
9253
  if (!entrypoint) {
7808
- throw new import_build_utils18.NowBuildError({
9254
+ throw new import_build_utils19.NowBuildError({
7809
9255
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
7810
9256
  message: "No Python entrypoint could be detected. Please specify an entrypoint file."
7811
9257
  });
@@ -7818,7 +9264,7 @@ var build = async ({
7818
9264
  envOverride: baseEnv.VERCEL_RUNTIME_PYTHON,
7819
9265
  uv,
7820
9266
  venvPath,
7821
- projectDir: (0, import_path14.join)(workPath, entryDirectory),
9267
+ projectDir: (0, import_path15.join)(workPath, entryDirectory),
7822
9268
  pipPlatformArgs
7823
9269
  });
7824
9270
  if (shouldInstallVercelWorkers) {
@@ -7828,7 +9274,7 @@ var build = async ({
7828
9274
  envOverride: baseEnv.VERCEL_WORKERS_PYTHON,
7829
9275
  uv,
7830
9276
  venvPath,
7831
- projectDir: (0, import_path14.join)(workPath, entryDirectory),
9277
+ projectDir: (0, import_path15.join)(workPath, entryDirectory),
7832
9278
  pipPlatformArgs
7833
9279
  });
7834
9280
  }
@@ -7841,25 +9287,25 @@ var build = async ({
7841
9287
  const capturedEnv = { ...pythonEnv };
7842
9288
  const capturedCwd = workPath;
7843
9289
  registerPreDeploy(async () => {
7844
- await builderSpan.child(import_build_utils18.BUILDER_PRE_DEPLOY_STEP, {
9290
+ await builderSpan.child(import_build_utils19.BUILDER_PRE_DEPLOY_STEP, {
7845
9291
  preDeployCommand
7846
9292
  }).trace(async () => {
7847
9293
  console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
7848
- await (0, import_build_utils18.execCommand)(preDeployCommand, {
9294
+ await (0, import_build_utils19.execCommand)(preDeployCommand, {
7849
9295
  env: capturedEnv,
7850
9296
  cwd: capturedCwd
7851
9297
  });
7852
9298
  });
7853
9299
  });
7854
9300
  }
7855
- (0, import_build_utils18.debug)("Entrypoint is", entrypoint);
9301
+ (0, import_build_utils19.debug)("Entrypoint is", entrypoint);
7856
9302
  const moduleName = entrypointToModule(entrypoint);
7857
9303
  if (handlerFunction) {
7858
- const entrypointPath = (0, import_path14.join)(workPath, entrypoint);
7859
- const source = await import_fs14.default.promises.readFile(entrypointPath, "utf-8");
9304
+ const entrypointPath = (0, import_path15.join)(workPath, entrypoint);
9305
+ const source = await import_fs15.default.promises.readFile(entrypointPath, "utf-8");
7860
9306
  const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
7861
9307
  if (!found) {
7862
- throw new import_build_utils18.NowBuildError({
9308
+ throw new import_build_utils19.NowBuildError({
7863
9309
  code: "PYTHON_HANDLER_NOT_FOUND",
7864
9310
  message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
7865
9311
  });
@@ -7868,7 +9314,7 @@ var build = async ({
7868
9314
  const vendorDir = resolveVendorDir();
7869
9315
  const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
7870
9316
  const entrypointWithSuffix = `${entrypoint}${suffix}`;
7871
- (0, import_build_utils18.debug)("Entrypoint with suffix is", entrypointWithSuffix);
9317
+ (0, import_build_utils19.debug)("Entrypoint with suffix is", entrypointWithSuffix);
7872
9318
  const crons = await getServiceCrons({
7873
9319
  service,
7874
9320
  entrypoint,
@@ -7878,56 +9324,24 @@ var build = async ({
7878
9324
  env: pythonEnv,
7879
9325
  workPath
7880
9326
  });
7881
- let cronEnvLine = "";
9327
+ const extraTrampolineEnv = [];
7882
9328
  if (crons?.length) {
7883
9329
  const json = JSON.stringify(buildCronRouteTable(crons));
7884
9330
  (0, import_assert.default)(!json.includes("\\"), `backslash in cron route table: ${json}`);
7885
- cronEnvLine = `
7886
- "__VC_CRON_ROUTES": '${json}',`;
9331
+ extraTrampolineEnv.push(`"__VC_CRON_ROUTES": '${json}'`);
7887
9332
  }
7888
9333
  const variableName = resolved?.variableName ?? "";
7889
- const runtimeTrampoline = `
7890
- import importlib
7891
- import os
7892
- import os.path
7893
- import site
7894
- import sys
7895
-
7896
- _here = os.path.dirname(__file__)
7897
-
7898
- os.environ.update({
7899
- "__VC_HANDLER_MODULE_NAME": "${moduleName}",
7900
- "__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
7901
- "__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
7902
- "__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
7903
- "__VC_HANDLER_VARIABLE_NAME": "${variableName}",${cronEnvLine}
7904
- })
7905
-
7906
- _vendor_rel = '${vendorDir}'
7907
- _vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
7908
-
7909
- if os.path.isdir(_vendor):
7910
- # Process .pth files like a real site-packages dir
7911
- site.addsitedir(_vendor)
7912
-
7913
- # Move _vendor to the front (after script dir if present)
7914
- try:
7915
- while _vendor in sys.path:
7916
- sys.path.remove(_vendor)
7917
- except ValueError:
7918
- pass
7919
-
7920
- # Put vendored deps ahead of site-packages but after the script dir
7921
- idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
7922
- sys.path.insert(idx, _vendor)
7923
-
7924
- importlib.invalidate_caches()
7925
-
7926
- from vercel_runtime.vc_init import vc_handler
7927
- `;
9334
+ const runtimeTrampoline = createRuntimeTrampoline({
9335
+ moduleName,
9336
+ entrypoint: entrypointWithSuffix,
9337
+ vendorDir,
9338
+ variableName,
9339
+ extraEnv: extraTrampolineEnv
9340
+ });
7928
9341
  const automaticCompileAllEnabled = shouldUseCompileAll({
7929
9342
  isDev: meta.isDev,
7930
- hasCustomCommand
9343
+ hasCustomCommand,
9344
+ hasCustomBuildCommand
7931
9345
  });
7932
9346
  const predefinedExcludes = [
7933
9347
  ".git/**",
@@ -7958,17 +9372,16 @@ from vercel_runtime.vc_init import vc_handler
7958
9372
  cwd: workPath,
7959
9373
  ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
7960
9374
  };
7961
- const files = await (0, import_build_utils18.glob)("**", globOptions);
9375
+ const files = await (0, import_build_utils19.glob)("**", globOptions);
7962
9376
  if (djangoStatic?.manifestRelPath) {
7963
- files[djangoStatic.manifestRelPath] = new import_build_utils18.FileFsRef({
7964
- fsPath: (0, import_path14.join)(workPath, djangoStatic.manifestRelPath)
9377
+ files[djangoStatic.manifestRelPath] = new import_build_utils19.FileFsRef({
9378
+ fsPath: (0, import_path15.join)(workPath, djangoStatic.manifestRelPath)
7965
9379
  });
7966
9380
  }
7967
9381
  const handlerPyFilename = "vc__handler__python";
7968
- files[`${handlerPyFilename}.py`] = new import_build_utils18.FileBlob({ data: runtimeTrampoline });
7969
9382
  if (config.framework === "fasthtml") {
7970
9383
  const { SESSKEY = "" } = process.env;
7971
- files[".sesskey"] = new import_build_utils18.FileBlob({ data: `"${SESSKEY}"` });
9384
+ files[".sesskey"] = new import_build_utils19.FileBlob({ data: `"${SESSKEY}"` });
7972
9385
  }
7973
9386
  const depExternalizer = new PythonDependencyExternalizer({
7974
9387
  venvPath,
@@ -7987,81 +9400,136 @@ from vercel_runtime.vc_init import vc_handler
7987
9400
  ]
7988
9401
  });
7989
9402
  await builderSpan.child("vc.builder.python.bundle").trace(async (bundleSpan) => {
7990
- const depAnalysis = await depExternalizer.analyze(files);
7991
- bundleSpan.setAttributes({
7992
- "python.bundle.totalSizeBytes": String(depAnalysis.totalBundleSize),
7993
- "python.bundle.runtimeInstallEnabled": String(
7994
- depAnalysis.runtimeInstallEnabled
7995
- )
9403
+ const depAnalysis = await depExternalizer.analyze(files, {
9404
+ onSized: ({ totalSizeBytes, runtimeInstallEnabled }) => {
9405
+ bundleSpan.setAttributes({
9406
+ "python.bundle.totalSizeBytes": String(totalSizeBytes),
9407
+ "python.bundle.runtimeInstallEnabled": String(
9408
+ runtimeInstallEnabled
9409
+ )
9410
+ });
9411
+ }
7996
9412
  });
7997
- if (depAnalysis.runtimeInstallEnabled) {
7998
- await depExternalizer.generateBundle(files);
7999
- } else {
8000
- addFiles(files, depAnalysis.allVendorFiles);
8001
- if (automaticCompileAllEnabled) {
8002
- await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
8003
- const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs14.default.existsSync(d));
8004
- const pythonBin = getVenvPythonBin(venvPath);
8005
- console.log("Compiling Python application bytecode...");
8006
- await runCompileAll({
8007
- pythonBin,
8008
- filesOrDirectories: [workPath],
8009
- env: pythonEnv,
8010
- excludeRegex: getCompileAllAppExcludeRegex(workPath)
8011
- });
8012
- console.log("Compiling Python dependency bytecode...");
8013
- await runCompileAll({
8014
- pythonBin,
8015
- filesOrDirectories: sitePackageDirs,
8016
- env: pythonEnv
8017
- });
8018
- compileSpan.setAttributes({
8019
- "python.compileall.enabled": "true",
8020
- "python.compileall.sitePackageDirectoryCount": String(
8021
- sitePackageDirs.length
8022
- )
8023
- });
9413
+ const runCompileAllAndFillBytecode = async () => {
9414
+ await builderSpan.child("vc.builder.python.compileall").trace(async (compileSpan) => {
9415
+ const sitePackageDirs = (await getVenvSitePackagesDirs(venvPath)).filter((d) => import_fs15.default.existsSync(d));
9416
+ const pythonBin = getVenvPythonBin(venvPath);
9417
+ console.log("Compiling Python application bytecode...");
9418
+ await runCompileAll({
9419
+ pythonBin,
9420
+ filesOrDirectories: [workPath],
9421
+ env: pythonEnv,
9422
+ excludeRegex: getCompileAllAppExcludeRegex(workPath)
8024
9423
  });
8025
- const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
8026
- const activeThreshold = pythonOnHiveEnabled ? HIVE_LAMBDA_SIZE_BYTES : LAMBDA_SIZE_THRESHOLD_BYTES;
8027
- const currentSize = await calculateBundleSize(files);
8028
- let remainingCapacity = activeThreshold - currentSize;
8029
- if (pythonVersion.major != null && pythonVersion.minor != null) {
8030
- const appBytecodeInfo = await collectAppBytecodeFiles({
8031
- workPath,
8032
- files,
8033
- pythonMajor: pythonVersion.major,
8034
- pythonMinor: pythonVersion.minor
8035
- });
8036
- remainingCapacity = addBytecodeWithinCapacity(
8037
- files,
8038
- appBytecodeInfo,
8039
- remainingCapacity
8040
- );
8041
- }
8042
- const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles(
8043
- {
8044
- vendorDirName: vendorDir
8045
- }
8046
- );
8047
- await addVendorBytecodeWithinCapacity({
9424
+ console.log("Compiling Python dependency bytecode...");
9425
+ await runCompileAll({
9426
+ pythonBin,
9427
+ filesOrDirectories: sitePackageDirs,
9428
+ env: pythonEnv
9429
+ });
9430
+ compileSpan.setAttributes({
9431
+ "python.compileall.enabled": "true",
9432
+ "python.compileall.sitePackageDirectoryCount": String(
9433
+ sitePackageDirs.length
9434
+ )
9435
+ });
9436
+ });
9437
+ const currentSize = await calculateBundleSize(files);
9438
+ let remainingCapacity = MAX_LARGE_FUNCTION_UNCOMPRESSED_SIZE - currentSize;
9439
+ if (pythonVersion.major != null && pythonVersion.minor != null) {
9440
+ const appBytecodeInfo = await collectAppBytecodeFiles({
9441
+ workPath,
8048
9442
  files,
8049
- depExternalizer,
8050
- vendorDir,
8051
- bytecodeInfo: vendorBytecodeInfo,
8052
- capacity: remainingCapacity
9443
+ pythonMajor: pythonVersion.major,
9444
+ pythonMinor: pythonVersion.minor
8053
9445
  });
9446
+ remainingCapacity = addBytecodeWithinCapacity(
9447
+ files,
9448
+ appBytecodeInfo,
9449
+ remainingCapacity
9450
+ );
9451
+ }
9452
+ const vendorBytecodeInfo = await depExternalizer.collectBytecodeFiles({
9453
+ vendorDirName: vendorDir
9454
+ });
9455
+ await addVendorBytecodeWithinCapacity({
9456
+ files,
9457
+ depExternalizer,
9458
+ vendorDir,
9459
+ bytecodeInfo: vendorBytecodeInfo,
9460
+ capacity: remainingCapacity
9461
+ });
9462
+ };
9463
+ const announceLargeFunction = () => console.log(
9464
+ `Function "${entrypoint}" exceeds the standard size limit; enabling large functions (beta).`
9465
+ );
9466
+ if (depAnalysis.runtimeInstallEnabled) {
9467
+ const { fellBackToFullBundle } = await depExternalizer.generateBundle(files);
9468
+ if (fellBackToFullBundle) {
9469
+ announceLargeFunction();
9470
+ if (automaticCompileAllEnabled) {
9471
+ await runCompileAllAndFillBytecode();
9472
+ }
9473
+ }
9474
+ } else {
9475
+ addFiles(files, depAnalysis.allVendorFiles);
9476
+ if (isLargeFunctionsEnabled() && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
9477
+ announceLargeFunction();
9478
+ }
9479
+ if (automaticCompileAllEnabled && depAnalysis.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES) {
9480
+ await runCompileAllAndFillBytecode();
8054
9481
  }
8055
9482
  }
8056
9483
  });
8057
- const output = new import_build_utils18.Lambda({
8058
- files,
9484
+ const webFiles = {
9485
+ ...files,
9486
+ [`${handlerPyFilename}.py`]: new import_build_utils19.FileBlob({ data: runtimeTrampoline })
9487
+ };
9488
+ const output = new import_build_utils19.Lambda({
9489
+ files: webFiles,
8059
9490
  handler: `${handlerPyFilename}.vc_handler`,
8060
9491
  runtime: pythonVersion.runtime,
8061
9492
  architecture: target.architecture,
8062
9493
  environment: lambdaEnv,
8063
9494
  supportsResponseStreaming: true
8064
9495
  });
9496
+ const subscriberLambdas = {};
9497
+ for (const subscriber of subscribers) {
9498
+ const safeName = safePathSegment(subscriber.name);
9499
+ const outputPath = `_py_subscribers/${safeName}`;
9500
+ const consumer = (0, import_build_utils19.sanitizeConsumerName)(outputPath);
9501
+ const experimentalTriggers = subscriber.topics.map(
9502
+ (topic) => ({
9503
+ type: "queue/v2beta",
9504
+ topic,
9505
+ consumer,
9506
+ ...subscriber.triggerDefaults
9507
+ })
9508
+ );
9509
+ subscriberLambdas[outputPath] = new import_build_utils19.Lambda({
9510
+ files: {
9511
+ ...files,
9512
+ [`${handlerPyFilename}.py`]: new import_build_utils19.FileBlob({
9513
+ data: createRuntimeTrampoline({
9514
+ moduleName: subscriber.moduleName,
9515
+ entrypoint: subscriber.entrypoint,
9516
+ vendorDir,
9517
+ variableName: subscriber.variableName
9518
+ })
9519
+ })
9520
+ },
9521
+ handler: `${handlerPyFilename}.vc_handler`,
9522
+ runtime: pythonVersion.runtime,
9523
+ architecture: target.architecture,
9524
+ environment: {
9525
+ ...lambdaEnv,
9526
+ VERCEL_HAS_WORKER_SERVICES: "1",
9527
+ VERCEL_SERVICE_TYPE: "worker"
9528
+ },
9529
+ experimentalTriggers,
9530
+ supportsResponseStreaming: true
9531
+ });
9532
+ }
8065
9533
  if (uvLockPath && !meta.isDev) {
8066
9534
  try {
8067
9535
  await generateProjectManifest({
@@ -8070,25 +9538,30 @@ from vercel_runtime.vc_init import vc_handler
8070
9538
  pythonVersion,
8071
9539
  uvLockPath,
8072
9540
  framework,
8073
- serviceType: service ? (0, import_build_utils18.getReportedServiceType)(service) : void 0
9541
+ serviceType: service ? (0, import_build_utils19.getReportedServiceType)(service) : void 0
8074
9542
  });
8075
9543
  } catch (err) {
8076
- (0, import_build_utils18.debug)(
9544
+ (0, import_build_utils19.debug)(
8077
9545
  `Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
8078
9546
  );
8079
9547
  }
8080
9548
  }
8081
- if (!(0, import_build_utils18.isPythonFramework)(framework) && !service?.name) {
9549
+ if (!(0, import_build_utils19.isPythonFramework)(framework) && !service?.name) {
8082
9550
  return { resultVersion: 3, result: { output } };
8083
9551
  }
8084
9552
  const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
8085
- const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils18.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
8086
- const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
9553
+ const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
9554
+ const isNonWebService = service?.name && service.type && service.type !== "web";
9555
+ const routes = isNonWebService ? void 0 : [
9556
+ { handle: "filesystem" },
9557
+ { src: "/(.*)", dest: `/${lambdaPath}` }
9558
+ ];
8087
9559
  return {
8088
9560
  resultVersion: 2,
8089
9561
  result: {
8090
9562
  output: {
8091
9563
  [lambdaPath]: output,
9564
+ ...subscriberLambdas,
8092
9565
  ...staticFiles
8093
9566
  },
8094
9567
  ...routes ? { routes } : {},
@@ -8111,14 +9584,14 @@ var prepareCache = async ({
8111
9584
  }
8112
9585
  } catch {
8113
9586
  }
8114
- return (0, import_build_utils18.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
9587
+ return (0, import_build_utils19.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
8115
9588
  cwd: root,
8116
9589
  ignore
8117
9590
  });
8118
9591
  };
8119
9592
  var shouldServe = (opts) => {
8120
9593
  const framework = opts.config.framework;
8121
- if ((0, import_build_utils18.isPythonFramework)(framework)) {
9594
+ if ((0, import_build_utils19.isPythonFramework)(framework)) {
8122
9595
  const requestPath = opts.requestPath.replace(/\/$/, "");
8123
9596
  if (requestPath.startsWith("api") && opts.hasMatched) {
8124
9597
  return false;
@@ -8137,7 +9610,7 @@ var defaultShouldServe = ({
8137
9610
  if (entrypoint === requestPath && hasProp(files, entrypoint)) {
8138
9611
  return true;
8139
9612
  }
8140
- const { dir, name } = (0, import_path14.parse)(entrypoint);
9613
+ const { dir, name } = (0, import_path15.parse)(entrypoint);
8141
9614
  if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
8142
9615
  return true;
8143
9616
  }