@vercel/python 6.22.1 → 6.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js 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 fs9 = require("fs");
51
+ var fs10 = 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
- fs9.stat(path, function(er, stat) {
76
+ fs10.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(fs9.statSync(path), path, options);
81
+ return checkStat(fs10.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 fs9 = require("fs");
91
+ var fs10 = require("fs");
92
92
  function isexe(path, options, cb) {
93
- fs9.stat(path, function(er, stat) {
93
+ fs10.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(fs9.statSync(path), options);
98
+ return checkStat(fs10.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 fs9 = require("fs");
122
+ var fs10 = require("fs");
123
123
  var core;
124
124
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
125
125
  core = require_windows();
@@ -137,12 +137,12 @@ var require_isexe = __commonJS({
137
137
  if (typeof Promise !== "function") {
138
138
  throw new TypeError("callback not provided");
139
139
  }
140
- return new Promise(function(resolve2, reject) {
140
+ return new Promise(function(resolve3, reject) {
141
141
  isexe(path, options || {}, function(er, is) {
142
142
  if (er) {
143
143
  reject(er);
144
144
  } else {
145
- resolve2(is);
145
+ resolve3(is);
146
146
  }
147
147
  });
148
148
  });
@@ -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 fs9 = require("fs");
398
+ var fs10 = 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 = fs9.openSync(command, "r");
412
- fs9.readSync(fd, buffer, 0, size, 0);
413
- fs9.closeSync(fd);
411
+ fd = fs10.openSync(command, "r");
412
+ fs10.readSync(fd, buffer, 0, size, 0);
413
+ fs10.closeSync(fd);
414
414
  } catch (e) {
415
415
  }
416
416
  return shebangCommand(buffer.toString());
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
1895
1895
  "../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
1896
1896
  var once = require_once();
1897
1897
  var eos = require_end_of_stream();
1898
- var fs9;
1898
+ var fs10;
1899
1899
  try {
1900
- fs9 = require("fs");
1900
+ fs10 = 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 (!fs9)
1912
+ if (!fs10)
1913
1913
  return false;
1914
- return (stream instanceof (fs9.ReadStream || noop) || stream instanceof (fs9.WriteStream || noop)) && isFn(stream.close);
1914
+ return (stream instanceof (fs10.ReadStream || noop) || stream instanceof (fs10.WriteStream || noop)) && isFn(stream.close);
1915
1915
  };
1916
1916
  var isRequest = function(stream) {
1917
1917
  return stream.setHeader && isFn(stream.abort);
@@ -2042,7 +2042,7 @@ var require_get_stream = __commonJS({
2042
2042
  options = Object.assign({ maxBuffer: Infinity }, options);
2043
2043
  const { maxBuffer } = options;
2044
2044
  let stream;
2045
- return new Promise((resolve2, reject) => {
2045
+ return new Promise((resolve3, reject) => {
2046
2046
  const rejectPromise = (error) => {
2047
2047
  if (error) {
2048
2048
  error.bufferedData = stream.getBufferedValue();
@@ -2054,7 +2054,7 @@ var require_get_stream = __commonJS({
2054
2054
  rejectPromise(error);
2055
2055
  return;
2056
2056
  }
2057
- resolve2();
2057
+ resolve3();
2058
2058
  });
2059
2059
  stream.on("data", () => {
2060
2060
  if (stream.getBufferedLength() > maxBuffer) {
@@ -2078,11 +2078,11 @@ var require_p_finally = __commonJS({
2078
2078
  onFinally = onFinally || (() => {
2079
2079
  });
2080
2080
  return promise.then(
2081
- (val) => new Promise((resolve2) => {
2082
- resolve2(onFinally());
2081
+ (val) => new Promise((resolve3) => {
2082
+ resolve3(onFinally());
2083
2083
  }).then(() => val),
2084
- (err) => new Promise((resolve2) => {
2085
- resolve2(onFinally());
2084
+ (err) => new Promise((resolve3) => {
2085
+ resolve3(onFinally());
2086
2086
  }).then(() => {
2087
2087
  throw err;
2088
2088
  })
@@ -2461,8 +2461,8 @@ var require_execa = __commonJS({
2461
2461
  }
2462
2462
  let ret;
2463
2463
  if (!buffer) {
2464
- ret = new Promise((resolve2, reject) => {
2465
- process2[stream].once("end", resolve2).once("error", reject);
2464
+ ret = new Promise((resolve3, reject) => {
2465
+ process2[stream].once("end", resolve3).once("error", reject);
2466
2466
  });
2467
2467
  } else if (encoding) {
2468
2468
  ret = _getStream(process2[stream], {
@@ -2551,19 +2551,19 @@ ${stderr}${stdout}`;
2551
2551
  spawned.kill(parsed.opts.killSignal);
2552
2552
  }, parsed.opts.timeout);
2553
2553
  }
2554
- const processDone = new Promise((resolve2) => {
2554
+ const processDone = new Promise((resolve3) => {
2555
2555
  spawned.on("exit", (code, signal) => {
2556
2556
  cleanup();
2557
- resolve2({ code, signal });
2557
+ resolve3({ code, signal });
2558
2558
  });
2559
2559
  spawned.on("error", (err) => {
2560
2560
  cleanup();
2561
- resolve2({ error: err });
2561
+ resolve3({ error: err });
2562
2562
  });
2563
2563
  if (spawned.stdin) {
2564
2564
  spawned.stdin.on("error", (err) => {
2565
2565
  cleanup();
2566
- resolve2({ error: err });
2566
+ resolve3({ error: err });
2567
2567
  });
2568
2568
  }
2569
2569
  });
@@ -2647,6 +2647,360 @@ ${stderr}${stdout}`;
2647
2647
  }
2648
2648
  });
2649
2649
 
2650
+ // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js
2651
+ var require_process = __commonJS({
2652
+ "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js"(exports, module2) {
2653
+ "use strict";
2654
+ var isLinux = () => process.platform === "linux";
2655
+ var report = null;
2656
+ var getReport = () => {
2657
+ if (!report) {
2658
+ if (isLinux() && process.report) {
2659
+ const orig = process.report.excludeNetwork;
2660
+ process.report.excludeNetwork = true;
2661
+ report = process.report.getReport();
2662
+ process.report.excludeNetwork = orig;
2663
+ } else {
2664
+ report = {};
2665
+ }
2666
+ }
2667
+ return report;
2668
+ };
2669
+ module2.exports = { isLinux, getReport };
2670
+ }
2671
+ });
2672
+
2673
+ // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js
2674
+ var require_filesystem = __commonJS({
2675
+ "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports, module2) {
2676
+ "use strict";
2677
+ var fs10 = require("fs");
2678
+ var LDD_PATH = "/usr/bin/ldd";
2679
+ var SELF_PATH = "/proc/self/exe";
2680
+ var MAX_LENGTH = 2048;
2681
+ var readFileSync2 = (path) => {
2682
+ const fd = fs10.openSync(path, "r");
2683
+ const buffer = Buffer.alloc(MAX_LENGTH);
2684
+ const bytesRead = fs10.readSync(fd, buffer, 0, MAX_LENGTH, 0);
2685
+ fs10.close(fd, () => {
2686
+ });
2687
+ return buffer.subarray(0, bytesRead);
2688
+ };
2689
+ var readFile2 = (path) => new Promise((resolve3, reject) => {
2690
+ fs10.open(path, "r", (err, fd) => {
2691
+ if (err) {
2692
+ reject(err);
2693
+ } else {
2694
+ const buffer = Buffer.alloc(MAX_LENGTH);
2695
+ fs10.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
2696
+ resolve3(buffer.subarray(0, bytesRead));
2697
+ fs10.close(fd, () => {
2698
+ });
2699
+ });
2700
+ }
2701
+ });
2702
+ });
2703
+ module2.exports = {
2704
+ LDD_PATH,
2705
+ SELF_PATH,
2706
+ readFileSync: readFileSync2,
2707
+ readFile: readFile2
2708
+ };
2709
+ }
2710
+ });
2711
+
2712
+ // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js
2713
+ var require_elf = __commonJS({
2714
+ "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/elf.js"(exports, module2) {
2715
+ "use strict";
2716
+ var interpreterPath = (elf) => {
2717
+ if (elf.length < 64) {
2718
+ return null;
2719
+ }
2720
+ if (elf.readUInt32BE(0) !== 2135247942) {
2721
+ return null;
2722
+ }
2723
+ if (elf.readUInt8(4) !== 2) {
2724
+ return null;
2725
+ }
2726
+ if (elf.readUInt8(5) !== 1) {
2727
+ return null;
2728
+ }
2729
+ const offset = elf.readUInt32LE(32);
2730
+ const size = elf.readUInt16LE(54);
2731
+ const count = elf.readUInt16LE(56);
2732
+ for (let i = 0; i < count; i++) {
2733
+ const headerOffset = offset + i * size;
2734
+ const type = elf.readUInt32LE(headerOffset);
2735
+ if (type === 3) {
2736
+ const fileOffset = elf.readUInt32LE(headerOffset + 8);
2737
+ const fileSize = elf.readUInt32LE(headerOffset + 32);
2738
+ return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\0.*$/g, "");
2739
+ }
2740
+ }
2741
+ return null;
2742
+ };
2743
+ module2.exports = {
2744
+ interpreterPath
2745
+ };
2746
+ }
2747
+ });
2748
+
2749
+ // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js
2750
+ var require_detect_libc = __commonJS({
2751
+ "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/detect-libc.js"(exports, module2) {
2752
+ "use strict";
2753
+ var childProcess = require("child_process");
2754
+ var { isLinux, getReport } = require_process();
2755
+ var { LDD_PATH, SELF_PATH, readFile: readFile2, readFileSync: readFileSync2 } = require_filesystem();
2756
+ var { interpreterPath } = require_elf();
2757
+ var cachedFamilyInterpreter;
2758
+ var cachedFamilyFilesystem;
2759
+ var cachedVersionFilesystem;
2760
+ var command = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
2761
+ var commandOut = "";
2762
+ var safeCommand = () => {
2763
+ if (!commandOut) {
2764
+ return new Promise((resolve3) => {
2765
+ childProcess.exec(command, (err, out) => {
2766
+ commandOut = err ? " " : out;
2767
+ resolve3(commandOut);
2768
+ });
2769
+ });
2770
+ }
2771
+ return commandOut;
2772
+ };
2773
+ var safeCommandSync = () => {
2774
+ if (!commandOut) {
2775
+ try {
2776
+ commandOut = childProcess.execSync(command, { encoding: "utf8" });
2777
+ } catch (_err) {
2778
+ commandOut = " ";
2779
+ }
2780
+ }
2781
+ return commandOut;
2782
+ };
2783
+ var GLIBC2 = "glibc";
2784
+ var RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
2785
+ var MUSL2 = "musl";
2786
+ var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
2787
+ var familyFromReport = () => {
2788
+ const report = getReport();
2789
+ if (report.header && report.header.glibcVersionRuntime) {
2790
+ return GLIBC2;
2791
+ }
2792
+ if (Array.isArray(report.sharedObjects)) {
2793
+ if (report.sharedObjects.some(isFileMusl)) {
2794
+ return MUSL2;
2795
+ }
2796
+ }
2797
+ return null;
2798
+ };
2799
+ var familyFromCommand = (out) => {
2800
+ const [getconf, ldd1] = out.split(/[\r\n]+/);
2801
+ if (getconf && getconf.includes(GLIBC2)) {
2802
+ return GLIBC2;
2803
+ }
2804
+ if (ldd1 && ldd1.includes(MUSL2)) {
2805
+ return MUSL2;
2806
+ }
2807
+ return null;
2808
+ };
2809
+ var familyFromInterpreterPath = (path) => {
2810
+ if (path) {
2811
+ if (path.includes("/ld-musl-")) {
2812
+ return MUSL2;
2813
+ } else if (path.includes("/ld-linux-")) {
2814
+ return GLIBC2;
2815
+ }
2816
+ }
2817
+ return null;
2818
+ };
2819
+ var getFamilyFromLddContent = (content) => {
2820
+ content = content.toString();
2821
+ if (content.includes("musl")) {
2822
+ return MUSL2;
2823
+ }
2824
+ if (content.includes("GNU C Library")) {
2825
+ return GLIBC2;
2826
+ }
2827
+ return null;
2828
+ };
2829
+ var familyFromFilesystem = async () => {
2830
+ if (cachedFamilyFilesystem !== void 0) {
2831
+ return cachedFamilyFilesystem;
2832
+ }
2833
+ cachedFamilyFilesystem = null;
2834
+ try {
2835
+ const lddContent = await readFile2(LDD_PATH);
2836
+ cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
2837
+ } catch (e) {
2838
+ }
2839
+ return cachedFamilyFilesystem;
2840
+ };
2841
+ var familyFromFilesystemSync = () => {
2842
+ if (cachedFamilyFilesystem !== void 0) {
2843
+ return cachedFamilyFilesystem;
2844
+ }
2845
+ cachedFamilyFilesystem = null;
2846
+ try {
2847
+ const lddContent = readFileSync2(LDD_PATH);
2848
+ cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
2849
+ } catch (e) {
2850
+ }
2851
+ return cachedFamilyFilesystem;
2852
+ };
2853
+ var familyFromInterpreter = async () => {
2854
+ if (cachedFamilyInterpreter !== void 0) {
2855
+ return cachedFamilyInterpreter;
2856
+ }
2857
+ cachedFamilyInterpreter = null;
2858
+ try {
2859
+ const selfContent = await readFile2(SELF_PATH);
2860
+ const path = interpreterPath(selfContent);
2861
+ cachedFamilyInterpreter = familyFromInterpreterPath(path);
2862
+ } catch (e) {
2863
+ }
2864
+ return cachedFamilyInterpreter;
2865
+ };
2866
+ var familyFromInterpreterSync = () => {
2867
+ if (cachedFamilyInterpreter !== void 0) {
2868
+ return cachedFamilyInterpreter;
2869
+ }
2870
+ cachedFamilyInterpreter = null;
2871
+ try {
2872
+ const selfContent = readFileSync2(SELF_PATH);
2873
+ const path = interpreterPath(selfContent);
2874
+ cachedFamilyInterpreter = familyFromInterpreterPath(path);
2875
+ } catch (e) {
2876
+ }
2877
+ return cachedFamilyInterpreter;
2878
+ };
2879
+ var family = async () => {
2880
+ let family2 = null;
2881
+ if (isLinux()) {
2882
+ family2 = await familyFromInterpreter();
2883
+ if (!family2) {
2884
+ family2 = await familyFromFilesystem();
2885
+ if (!family2) {
2886
+ family2 = familyFromReport();
2887
+ }
2888
+ if (!family2) {
2889
+ const out = await safeCommand();
2890
+ family2 = familyFromCommand(out);
2891
+ }
2892
+ }
2893
+ }
2894
+ return family2;
2895
+ };
2896
+ var familySync2 = () => {
2897
+ let family2 = null;
2898
+ if (isLinux()) {
2899
+ family2 = familyFromInterpreterSync();
2900
+ if (!family2) {
2901
+ family2 = familyFromFilesystemSync();
2902
+ if (!family2) {
2903
+ family2 = familyFromReport();
2904
+ }
2905
+ if (!family2) {
2906
+ const out = safeCommandSync();
2907
+ family2 = familyFromCommand(out);
2908
+ }
2909
+ }
2910
+ }
2911
+ return family2;
2912
+ };
2913
+ var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC2;
2914
+ var isNonGlibcLinuxSync = () => isLinux() && familySync2() !== GLIBC2;
2915
+ var versionFromFilesystem = async () => {
2916
+ if (cachedVersionFilesystem !== void 0) {
2917
+ return cachedVersionFilesystem;
2918
+ }
2919
+ cachedVersionFilesystem = null;
2920
+ try {
2921
+ const lddContent = await readFile2(LDD_PATH);
2922
+ const versionMatch = lddContent.match(RE_GLIBC_VERSION);
2923
+ if (versionMatch) {
2924
+ cachedVersionFilesystem = versionMatch[1];
2925
+ }
2926
+ } catch (e) {
2927
+ }
2928
+ return cachedVersionFilesystem;
2929
+ };
2930
+ var versionFromFilesystemSync = () => {
2931
+ if (cachedVersionFilesystem !== void 0) {
2932
+ return cachedVersionFilesystem;
2933
+ }
2934
+ cachedVersionFilesystem = null;
2935
+ try {
2936
+ const lddContent = readFileSync2(LDD_PATH);
2937
+ const versionMatch = lddContent.match(RE_GLIBC_VERSION);
2938
+ if (versionMatch) {
2939
+ cachedVersionFilesystem = versionMatch[1];
2940
+ }
2941
+ } catch (e) {
2942
+ }
2943
+ return cachedVersionFilesystem;
2944
+ };
2945
+ var versionFromReport = () => {
2946
+ const report = getReport();
2947
+ if (report.header && report.header.glibcVersionRuntime) {
2948
+ return report.header.glibcVersionRuntime;
2949
+ }
2950
+ return null;
2951
+ };
2952
+ var versionSuffix = (s) => s.trim().split(/\s+/)[1];
2953
+ var versionFromCommand = (out) => {
2954
+ const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
2955
+ if (getconf && getconf.includes(GLIBC2)) {
2956
+ return versionSuffix(getconf);
2957
+ }
2958
+ if (ldd1 && ldd2 && ldd1.includes(MUSL2)) {
2959
+ return versionSuffix(ldd2);
2960
+ }
2961
+ return null;
2962
+ };
2963
+ var version2 = async () => {
2964
+ let version3 = null;
2965
+ if (isLinux()) {
2966
+ version3 = await versionFromFilesystem();
2967
+ if (!version3) {
2968
+ version3 = versionFromReport();
2969
+ }
2970
+ if (!version3) {
2971
+ const out = await safeCommand();
2972
+ version3 = versionFromCommand(out);
2973
+ }
2974
+ }
2975
+ return version3;
2976
+ };
2977
+ var versionSync2 = () => {
2978
+ let version3 = null;
2979
+ if (isLinux()) {
2980
+ version3 = versionFromFilesystemSync();
2981
+ if (!version3) {
2982
+ version3 = versionFromReport();
2983
+ }
2984
+ if (!version3) {
2985
+ const out = safeCommandSync();
2986
+ version3 = versionFromCommand(out);
2987
+ }
2988
+ }
2989
+ return version3;
2990
+ };
2991
+ module2.exports = {
2992
+ GLIBC: GLIBC2,
2993
+ MUSL: MUSL2,
2994
+ family,
2995
+ familySync: familySync2,
2996
+ isNonGlibcLinux,
2997
+ isNonGlibcLinuxSync,
2998
+ version: version2,
2999
+ versionSync: versionSync2
3000
+ };
3001
+ }
3002
+ });
3003
+
2650
3004
  // ../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js
2651
3005
  var require_lib = __commonJS({
2652
3006
  "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
@@ -2751,14 +3105,14 @@ var require_get_port = __commonJS({
2751
3105
  };
2752
3106
  var releaseOldLockedPortsIntervalMs = 1e3 * 15;
2753
3107
  var interval;
2754
- var getAvailablePort = (options) => new Promise((resolve2, reject) => {
3108
+ var getAvailablePort = (options) => new Promise((resolve3, reject) => {
2755
3109
  const server = net.createServer();
2756
3110
  server.unref();
2757
3111
  server.on("error", reject);
2758
3112
  server.listen(options, () => {
2759
3113
  const { port } = server.address();
2760
3114
  server.close(() => {
2761
- resolve2(port);
3115
+ resolve3(port);
2762
3116
  });
2763
3117
  });
2764
3118
  });
@@ -2830,7 +3184,7 @@ var require_is_port_reachable = __commonJS({
2830
3184
  "use strict";
2831
3185
  var net = require("net");
2832
3186
  module2.exports = async (port, { timeout = 1e3, host } = {}) => {
2833
- const promise = new Promise((resolve2, reject) => {
3187
+ const promise = new Promise((resolve3, reject) => {
2834
3188
  const socket = new net.Socket();
2835
3189
  const onError = () => {
2836
3190
  socket.destroy();
@@ -2841,7 +3195,7 @@ var require_is_port_reachable = __commonJS({
2841
3195
  socket.once("timeout", onError);
2842
3196
  socket.connect(port, host, () => {
2843
3197
  socket.end();
2844
- resolve2();
3198
+ resolve3();
2845
3199
  });
2846
3200
  });
2847
3201
  try {
@@ -2872,7 +3226,7 @@ var import_fs10 = __toESM(require("fs"));
2872
3226
  var import_path12 = require("path");
2873
3227
 
2874
3228
  // src/package-versions.ts
2875
- var VERCEL_RUNTIME_VERSION = "0.7.0";
3229
+ var VERCEL_RUNTIME_VERSION = "0.9.0";
2876
3230
  var VERCEL_WORKERS_VERSION = "0.0.12";
2877
3231
 
2878
3232
  // src/index.ts
@@ -2887,8 +3241,10 @@ var import_python_analysis2 = require("@vercel/python-analysis");
2887
3241
 
2888
3242
  // src/utils.ts
2889
3243
  var import_fs2 = __toESM(require("fs"));
3244
+ var import_os2 = __toESM(require("os"));
2890
3245
  var import_path3 = require("path");
2891
3246
  var import_build_utils2 = require("@vercel/build-utils");
3247
+ var detectLibc = __toESM(require_detect_libc());
2892
3248
  var import_execa2 = __toESM(require_execa());
2893
3249
 
2894
3250
  // src/uv.ts
@@ -3269,6 +3625,41 @@ async function runPyprojectScript(workPath, scriptNames, env, useUserVirtualEnv
3269
3625
  }
3270
3626
  return false;
3271
3627
  }
3628
+ var ARCH_MAP = {
3629
+ x64: "x86_64",
3630
+ arm64: "aarch64",
3631
+ ia32: "i686",
3632
+ arm: "armv7l",
3633
+ ppc64: "ppc64le",
3634
+ s390x: "s390x"
3635
+ };
3636
+ function detectPlatform() {
3637
+ const arch = import_os2.default.arch();
3638
+ const archName = ARCH_MAP[arch] || arch;
3639
+ const libcFamily = detectLibc.familySync();
3640
+ const libcVersion = detectLibc.versionSync();
3641
+ let osName;
3642
+ let osMajor;
3643
+ let osMinor;
3644
+ if (libcFamily === detectLibc.MUSL) {
3645
+ osName = "musllinux";
3646
+ } else {
3647
+ osName = "manylinux";
3648
+ }
3649
+ if (libcVersion) {
3650
+ const parts = libcVersion.split(".");
3651
+ osMajor = parseInt(parts[0], 10);
3652
+ osMinor = parseInt(parts[1], 10) || 0;
3653
+ } else if (libcFamily === detectLibc.GLIBC) {
3654
+ osMajor = 2;
3655
+ osMinor = 17;
3656
+ } else {
3657
+ osMajor = 2;
3658
+ osMinor = 17;
3659
+ }
3660
+ const libc = libcFamily === detectLibc.MUSL ? "musl" : "gnu";
3661
+ return { osName, archName, osMajor, osMinor, os: "linux", libc };
3662
+ }
3272
3663
 
3273
3664
  // src/version.ts
3274
3665
  var import_path4 = require("path");
@@ -3340,13 +3731,14 @@ function versionLessOrEqual(a, b) {
3340
3731
  return a.minor <= b.minor;
3341
3732
  }
3342
3733
  function toPythonBuild(opt) {
3734
+ const platform = detectPlatform();
3343
3735
  return {
3344
3736
  version: { major: opt.major, minor: opt.minor },
3345
3737
  implementation: "cpython",
3346
3738
  variant: "default",
3347
- os: "linux",
3348
- architecture: "x86_64",
3349
- libc: "gnu"
3739
+ os: platform.os,
3740
+ architecture: platform.archName,
3741
+ libc: platform.libc
3350
3742
  };
3351
3743
  }
3352
3744
  function getAvailablePythonBuilds() {
@@ -3817,8 +4209,7 @@ var import_path6 = require("path");
3817
4209
  var import_build_utils5 = require("@vercel/build-utils");
3818
4210
  var import_python_analysis3 = require("@vercel/python-analysis");
3819
4211
  var readFile = (0, import_util.promisify)(import_fs4.default.readFile);
3820
- var LAMBDA_SIZE_THRESHOLD_BYTES = 249 * 1024 * 1024;
3821
- var LAMBDA_PACKING_TARGET_BYTES = 245 * 1024 * 1024;
4212
+ var LAMBDA_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
3822
4213
  var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
3823
4214
  var PythonDependencyExternalizer = class {
3824
4215
  constructor(options) {
@@ -3832,7 +4223,8 @@ var PythonDependencyExternalizer = class {
3832
4223
  this.uvLockPath = options.uvLockPath;
3833
4224
  this.uvProjectDir = options.uvProjectDir;
3834
4225
  this.projectName = options.projectName;
3835
- this.noBuildCheckFailed = options.noBuildCheckFailed;
4226
+ this.pythonMajor = options.pythonMajor;
4227
+ this.pythonMinor = options.pythonMinor;
3836
4228
  this.pythonPath = options.pythonPath;
3837
4229
  this.hasCustomCommand = options.hasCustomCommand;
3838
4230
  this.alwaysBundlePackages = options.alwaysBundlePackages ?? [];
@@ -3921,17 +4313,6 @@ To resolve this, either:
3921
4313
  action: "Learn More"
3922
4314
  });
3923
4315
  }
3924
- if (this.noBuildCheckFailed) {
3925
- throw new import_build_utils5.NowBuildError({
3926
- code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3927
- message: `Bundle size exceeds the Lambda limit and requires runtime dependency installation, but some packages in your uv.lock file do not have pre-built binary wheels available.
3928
- Runtime dependency installation requires all public packages to have binary wheels.
3929
-
3930
- To fix this, either:
3931
- 1. Regenerate your lock file with: uv lock --upgrade --no-build, or
3932
- 2. Switch the problematic packages to ones that have pre-built wheels available`
3933
- });
3934
- }
3935
4316
  let lockContent;
3936
4317
  try {
3937
4318
  lockContent = await readFile(this.uvLockPath, "utf8");
@@ -3982,10 +4363,30 @@ ${error.fileContent}`
3982
4363
  (0, import_build_utils5.debug)(
3983
4364
  `Package classification: ${classification.privatePackages.length} private, ${classification.publicPackages.length} public`
3984
4365
  );
3985
- if (classification.publicPackages.length === 0) {
4366
+ const forceBundledDueToWheels = await this.findPackagesWithoutCompatibleWheels(
4367
+ lockFile,
4368
+ classification.publicPackages
4369
+ );
4370
+ if (forceBundledDueToWheels.length > 0) {
4371
+ console.log(
4372
+ `Force-bundling ${forceBundledDueToWheels.length} package(s) without compatible wheels: ` + forceBundledDueToWheels.join(", ")
4373
+ );
4374
+ }
4375
+ const forceBundledSet = new Set(
4376
+ forceBundledDueToWheels.map(import_python_analysis3.normalizePackageName)
4377
+ );
4378
+ const externalizablePublic = classification.publicPackages.filter(
4379
+ (name) => !forceBundledSet.has((0, import_python_analysis3.normalizePackageName)(name))
4380
+ );
4381
+ if (externalizablePublic.length === 0) {
3986
4382
  throw new import_build_utils5.NowBuildError({
3987
4383
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3988
- message: "Bundle size exceeds limit but no public packages found for runtime installation."
4384
+ message: `Bundle size exceeds the Lambda limit and requires runtime dependency installation, but no public packages have compatible pre-built wheels for the Lambda platform.
4385
+ Runtime dependency installation requires packages to have binary wheels.
4386
+
4387
+ To fix this, either:
4388
+ 1. Regenerate your lock file with: uv lock --upgrade, or
4389
+ 2. Switch the problematic packages to ones that have pre-built wheels available`
3989
4390
  });
3990
4391
  }
3991
4392
  const packageSizes = await calculatePerPackageSizes(this.venvPath);
@@ -3993,7 +4394,8 @@ ${error.fileContent}`
3993
4394
  ...classification.privatePackages,
3994
4395
  "vercel-runtime",
3995
4396
  "vercel_runtime",
3996
- ...this.alwaysBundlePackages
4397
+ ...this.alwaysBundlePackages,
4398
+ ...forceBundledDueToWheels
3997
4399
  ];
3998
4400
  const alwaysBundledFiles = await mirrorPackagesIntoVendor({
3999
4401
  venvPath: this.venvPath,
@@ -4015,13 +4417,16 @@ ${error.fileContent}`
4015
4417
  runtimeToolingOverhead = 50 * 1024 * 1024;
4016
4418
  }
4017
4419
  }
4018
- const remainingCapacity = LAMBDA_PACKING_TARGET_BYTES - fixedOverhead - runtimeToolingOverhead;
4420
+ const remainingCapacity = LAMBDA_SIZE_THRESHOLD_BYTES - fixedOverhead - runtimeToolingOverhead;
4019
4421
  (0, import_build_utils5.debug)(
4020
4422
  `Fixed overhead: ${(fixedOverhead / (1024 * 1024)).toFixed(2)} MB, runtime tooling: ${(runtimeToolingOverhead / (1024 * 1024)).toFixed(2)} MB, remaining capacity for public packages: ${(remainingCapacity / (1024 * 1024)).toFixed(2)} MB`
4021
4423
  );
4424
+ const externalizableSet = new Set(
4425
+ externalizablePublic.map(import_python_analysis3.normalizePackageName)
4426
+ );
4022
4427
  const publicPackageSizes = new Map(
4023
4428
  [...packageSizes].filter(
4024
- ([name]) => classification.publicPackages.includes(name)
4429
+ ([name]) => externalizableSet.has((0, import_python_analysis3.normalizePackageName)(name))
4025
4430
  )
4026
4431
  );
4027
4432
  const bundledPublic = lambdaKnapsack(publicPackageSizes, remainingCapacity);
@@ -4037,7 +4442,8 @@ ${error.fileContent}`
4037
4442
  const bundledPackagesForConfig = [
4038
4443
  ...classification.privatePackages,
4039
4444
  ...bundledPublic,
4040
- ...this.alwaysBundlePackages
4445
+ ...this.alwaysBundlePackages,
4446
+ ...forceBundledDueToWheels
4041
4447
  ];
4042
4448
  const projectDirRel = (0, import_path6.relative)(this.workPath, this.uvProjectDir);
4043
4449
  const uvLockRel = (0, import_path6.relative)(this.workPath, this.uvLockPath);
@@ -4092,6 +4498,60 @@ ${error.fileContent}`
4092
4498
  });
4093
4499
  }
4094
4500
  }
4501
+ /**
4502
+ * Identify public packages that have no compatible wheel for the Lambda platform.
4503
+ * These packages must be force-bundled because `uv sync --no-build` at cold start
4504
+ * will refuse to build from source.
4505
+ */
4506
+ async findPackagesWithoutCompatibleWheels(lockFile, publicPackageNames) {
4507
+ const platform = detectPlatform();
4508
+ const publicSet = new Set(publicPackageNames.map(import_python_analysis3.normalizePackageName));
4509
+ const packageWheels = /* @__PURE__ */ new Map();
4510
+ for (const pkg of lockFile.packages) {
4511
+ const normalized = (0, import_python_analysis3.normalizePackageName)(pkg.name);
4512
+ if (publicSet.has(normalized) && pkg.wheels.length > 0) {
4513
+ packageWheels.set(normalized, pkg.wheels);
4514
+ }
4515
+ }
4516
+ const incompatible = [];
4517
+ for (const name of publicPackageNames) {
4518
+ const normalized = (0, import_python_analysis3.normalizePackageName)(name);
4519
+ const wheels = packageWheels.get(normalized);
4520
+ if (!wheels || wheels.length === 0) {
4521
+ incompatible.push(name);
4522
+ continue;
4523
+ }
4524
+ let hasCompatible = false;
4525
+ for (const wheel of wheels) {
4526
+ const filename = wheel.url.split("/").pop();
4527
+ if (!filename || !filename.endsWith(".whl"))
4528
+ continue;
4529
+ try {
4530
+ const compatible = await (0, import_python_analysis3.isWheelCompatible)(
4531
+ filename,
4532
+ this.pythonMajor,
4533
+ this.pythonMinor,
4534
+ platform.osName,
4535
+ platform.archName,
4536
+ platform.osMajor,
4537
+ platform.osMinor
4538
+ );
4539
+ if (compatible) {
4540
+ hasCompatible = true;
4541
+ break;
4542
+ }
4543
+ } catch (err) {
4544
+ (0, import_build_utils5.debug)(
4545
+ `Failed to check wheel compatibility for ${filename}: ${err instanceof Error ? err.message : String(err)}`
4546
+ );
4547
+ }
4548
+ }
4549
+ if (!hasCompatible) {
4550
+ incompatible.push(name);
4551
+ }
4552
+ }
4553
+ return incompatible;
4554
+ }
4095
4555
  };
4096
4556
  async function mirrorPackagesIntoVendor({
4097
4557
  venvPath,
@@ -4349,7 +4809,7 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint)
4349
4809
 
4350
4810
  // src/start-dev-server.ts
4351
4811
  var import_python_analysis4 = require("@vercel/python-analysis");
4352
- var DEV_SERVER_STARTUP_TIMEOUT = 1e4;
4812
+ var DEV_SERVER_STARTUP_TIMEOUT = 5 * 6e4;
4353
4813
  function silenceNodeWarnings() {
4354
4814
  const original = process.emitWarning.bind(
4355
4815
  process
@@ -4390,7 +4850,7 @@ function createLogListener(callback, stream) {
4390
4850
  };
4391
4851
  }
4392
4852
  function sleep(ms) {
4393
- return new Promise((resolve2) => setTimeout(resolve2, ms));
4853
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
4394
4854
  }
4395
4855
  async function checkForPort(port, timeout) {
4396
4856
  const start = Date.now();
@@ -4520,7 +4980,7 @@ async function runSync({
4520
4980
  (0, import_build_utils8.debug)(`Unknown manifest type: ${manifestType}`);
4521
4981
  return;
4522
4982
  }
4523
- await new Promise((resolve2, reject) => {
4983
+ await new Promise((resolve3, reject) => {
4524
4984
  (0, import_build_utils8.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
4525
4985
  const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
4526
4986
  cwd: projectDir,
@@ -4544,7 +5004,7 @@ async function runSync({
4544
5004
  child.on("error", reject);
4545
5005
  child.on("exit", (code, signal) => {
4546
5006
  if (code === 0) {
4547
- resolve2();
5007
+ resolve3();
4548
5008
  } else {
4549
5009
  reject(
4550
5010
  new Error(
@@ -4555,6 +5015,7 @@ async function runSync({
4555
5015
  });
4556
5016
  });
4557
5017
  }
5018
+ var PENDING_RUNTIME_INSTALLS = /* @__PURE__ */ new Map();
4558
5019
  async function installVercelRuntime({
4559
5020
  workPath,
4560
5021
  uvPath,
@@ -4564,6 +5025,31 @@ async function installVercelRuntime({
4564
5025
  onStderr
4565
5026
  }) {
4566
5027
  const targetDir = (0, import_path8.join)(workPath, ".vercel", "python");
5028
+ let pending = PENDING_RUNTIME_INSTALLS.get(targetDir);
5029
+ if (!pending) {
5030
+ pending = doInstallVercelRuntime({
5031
+ targetDir,
5032
+ workPath,
5033
+ uvPath,
5034
+ pythonBin,
5035
+ env,
5036
+ onStdout,
5037
+ onStderr
5038
+ });
5039
+ PENDING_RUNTIME_INSTALLS.set(targetDir, pending);
5040
+ pending.finally(() => PENDING_RUNTIME_INSTALLS.delete(targetDir));
5041
+ }
5042
+ await pending;
5043
+ }
5044
+ async function doInstallVercelRuntime({
5045
+ targetDir,
5046
+ workPath,
5047
+ uvPath,
5048
+ pythonBin,
5049
+ env,
5050
+ onStdout,
5051
+ onStderr
5052
+ }) {
4567
5053
  (0, import_fs6.mkdirSync)(targetDir, { recursive: true });
4568
5054
  const localRuntimeDir = (0, import_path8.join)(
4569
5055
  __dirname,
@@ -4592,7 +5078,7 @@ async function installVercelRuntime({
4592
5078
  );
4593
5079
  const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
4594
5080
  const spawnArgs = [...pip.prefix, "--target", targetDir, runtimeDep];
4595
- await new Promise((resolve2, reject) => {
5081
+ await new Promise((resolve3, reject) => {
4596
5082
  const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
4597
5083
  cwd: workPath,
4598
5084
  env: getProtectedUvEnv(env),
@@ -4615,7 +5101,7 @@ async function installVercelRuntime({
4615
5101
  child.on("error", reject);
4616
5102
  child.on("exit", (code, signal) => {
4617
5103
  if (code === 0) {
4618
- resolve2();
5104
+ resolve3();
4619
5105
  } else {
4620
5106
  reject(
4621
5107
  new Error(
@@ -4667,9 +5153,9 @@ function installGlobalCleanupHandlers() {
4667
5153
  killAll();
4668
5154
  });
4669
5155
  }
4670
- function createDevShim(workPath, entry, modulePath) {
5156
+ function createDevShim(workPath, entry, modulePath, serviceName, framework) {
4671
5157
  try {
4672
- const vercelPythonDir = (0, import_path8.join)(workPath, ".vercel", "python");
5158
+ const vercelPythonDir = serviceName ? (0, import_path8.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path8.join)(workPath, ".vercel", "python");
4673
5159
  (0, import_fs6.mkdirSync)(vercelPythonDir, { recursive: true });
4674
5160
  let qualifiedModule = modulePath;
4675
5161
  let extraPythonPath;
@@ -4687,10 +5173,14 @@ function createDevShim(workPath, entry, modulePath) {
4687
5173
  `${DEV_SHIM_MODULE}.py`
4688
5174
  );
4689
5175
  const template = (0, import_fs6.readFileSync)(templatePath, "utf8");
4690
- const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs);
5176
+ const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs).replace(/__VC_DEV_FRAMEWORK__/g, framework);
4691
5177
  (0, import_fs6.writeFileSync)(shimPath, shimSource, "utf8");
4692
5178
  (0, import_build_utils8.debug)(`Prepared Python dev shim at ${shimPath}`);
4693
- return { module: DEV_SHIM_MODULE, extraPythonPath };
5179
+ return {
5180
+ module: DEV_SHIM_MODULE,
5181
+ extraPythonPath,
5182
+ shimDir: vercelPythonDir
5183
+ };
4694
5184
  } catch (err) {
4695
5185
  (0, import_build_utils8.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
4696
5186
  return null;
@@ -4721,7 +5211,8 @@ var startDevServer = async (opts) => {
4721
5211
  onStderr
4722
5212
  } = opts;
4723
5213
  const framework = config?.framework;
4724
- const serverKey = `${workPath}::${framework}`;
5214
+ const serviceName = typeof meta.serviceName === "string" ? meta.serviceName : void 0;
5215
+ const serverKey = serviceName ? `${workPath}::${framework}::${serviceName}` : `${workPath}::${framework}`;
4725
5216
  const existing = PERSISTENT_SERVERS.get(serverKey);
4726
5217
  if (existing) {
4727
5218
  return {
@@ -4749,30 +5240,37 @@ var startDevServer = async (opts) => {
4749
5240
  if (!restoreWarnings)
4750
5241
  restoreWarnings = silenceNodeWarnings();
4751
5242
  installGlobalCleanupHandlers();
4752
- const detected = await detectPythonEntrypoint(
4753
- framework,
4754
- workPath,
4755
- rawEntrypoint
4756
- );
4757
5243
  const env = { ...process.env, ...meta.env || {} };
4758
- let entry = detected?.entrypoint;
4759
- if (!entry) {
4760
- const hookResult = await runFrameworkHook(framework, {
4761
- pythonEnv: env,
4762
- projectDir: (0, import_path8.join)(workPath, detected?.baseDir ?? ""),
4763
- entrypoint: rawEntrypoint,
4764
- detected: detected ?? void 0
4765
- });
4766
- entry = hookResult?.entrypoint;
4767
- }
4768
- if (!entry) {
4769
- const searched = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
4770
- throw new import_build_utils8.NowBuildError({
4771
- code: "PYTHON_ENTRYPOINT_NOT_FOUND",
4772
- message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searched}.`,
4773
- link: `https://vercel.com/docs/frameworks/backend/${framework?.toLowerCase()}#exporting-the-${framework?.toLowerCase()}-application`,
4774
- action: "Learn More"
4775
- });
5244
+ const serviceType = env.VERCEL_SERVICE_TYPE;
5245
+ let entry;
5246
+ if ((serviceType === "cron" || serviceType === "worker") && rawEntrypoint?.endsWith(".py")) {
5247
+ entry = rawEntrypoint;
5248
+ } else {
5249
+ const detected = await detectPythonEntrypoint(
5250
+ framework,
5251
+ workPath,
5252
+ rawEntrypoint
5253
+ );
5254
+ entry = detected?.entrypoint;
5255
+ if (!entry) {
5256
+ const hookResult = await runFrameworkHook(framework, {
5257
+ pythonEnv: env,
5258
+ projectDir: (0, import_path8.join)(workPath, detected?.baseDir ?? ""),
5259
+ workPath,
5260
+ entrypoint: rawEntrypoint,
5261
+ detected: detected ?? void 0
5262
+ });
5263
+ entry = hookResult?.entrypoint;
5264
+ }
5265
+ if (!entry) {
5266
+ const searched = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
5267
+ throw new import_build_utils8.NowBuildError({
5268
+ code: "PYTHON_ENTRYPOINT_NOT_FOUND",
5269
+ message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searched}.`,
5270
+ link: `https://vercel.com/docs/frameworks/backend/${framework?.toLowerCase()}#exporting-the-${framework?.toLowerCase()}-application`,
5271
+ action: "Learn More"
5272
+ });
5273
+ }
4776
5274
  }
4777
5275
  const modulePath = entry.replace(/\.py$/i, "").replace(/[\\/]/g, ".");
4778
5276
  let childProcess = null;
@@ -4781,8 +5279,8 @@ var startDevServer = async (opts) => {
4781
5279
  let resolveChildReady;
4782
5280
  let rejectChildReady;
4783
5281
  const childReady = new Promise(
4784
- (resolve2, reject) => {
4785
- resolveChildReady = resolve2;
5282
+ (resolve3, reject) => {
5283
+ resolveChildReady = resolve3;
4786
5284
  rejectChildReady = reject;
4787
5285
  }
4788
5286
  );
@@ -4870,10 +5368,23 @@ If you are using a virtual environment, activate it before running "vercel dev",
4870
5368
  });
4871
5369
  const port = typeof meta.port === "number" ? meta.port : await (0, import_get_port.default)();
4872
5370
  env.PORT = `${port}`;
4873
- const devShim = createDevShim(workPath, entry, modulePath);
5371
+ if (config.handlerFunction && typeof config?.handlerFunction === "string") {
5372
+ env.__VC_HANDLER_FUNC_NAME = config.handlerFunction;
5373
+ }
5374
+ if (entry) {
5375
+ env.__VC_HANDLER_ENTRYPOINT_ABS = (0, import_path8.join)(workPath, entry);
5376
+ }
5377
+ const devShim = createDevShim(
5378
+ workPath,
5379
+ entry,
5380
+ modulePath,
5381
+ serviceName,
5382
+ framework
5383
+ );
4874
5384
  if (devShim) {
4875
- const vercelPythonDir = (0, import_path8.join)(workPath, ".vercel", "python");
4876
- const pathParts = [vercelPythonDir];
5385
+ const shimDir = devShim.shimDir || (0, import_path8.join)(workPath, ".vercel", "python");
5386
+ const runtimeDir = (0, import_path8.join)(workPath, ".vercel", "python");
5387
+ const pathParts = shimDir !== runtimeDir ? [shimDir, runtimeDir] : [shimDir];
4877
5388
  if (devShim.extraPythonPath) {
4878
5389
  pathParts.push(devShim.extraPythonPath);
4879
5390
  }
@@ -5034,7 +5545,8 @@ var DUMMY_SCHEMA_NAME = "_prisma_dummy.prisma";
5034
5545
  var LAMBDA_ROOT2 = "/var/task";
5035
5546
  var RUNTIME_OPENSSL_VERSION = "3.2";
5036
5547
  function getLambdaBinaryTarget() {
5037
- return process.arch === "arm64" ? "linux-arm64-openssl-3.0.x" : "rhel-openssl-3.0.x";
5548
+ const platform = detectPlatform();
5549
+ return platform.archName === "aarch64" ? "linux-arm64-openssl-3.0.x" : "rhel-openssl-3.0.x";
5038
5550
  }
5039
5551
  function buildDummySchema(generatedDir) {
5040
5552
  const lambdaTarget = getLambdaBinaryTarget();
@@ -5403,24 +5915,109 @@ async function runQuirks(ctx) {
5403
5915
  }
5404
5916
 
5405
5917
  // src/django.ts
5406
- var import_fs9 = require("fs");
5918
+ var import_fs9 = __toESM(require("fs"));
5407
5919
  var import_path11 = require("path");
5408
5920
  var import_execa5 = __toESM(require_execa());
5409
5921
  var import_build_utils12 = require("@vercel/build-utils");
5410
5922
  var scriptPath = (0, import_path11.join)(__dirname, "..", "templates", "vc_django_settings.py");
5411
- var script = (0, import_fs9.readFileSync)(scriptPath, "utf-8");
5923
+ var script = import_fs9.default.readFileSync(scriptPath, "utf-8");
5412
5924
  async function getDjangoSettings(projectDir, env) {
5413
5925
  try {
5414
5926
  const { stdout } = await (0, import_execa5.default)("python", ["-c", script], {
5415
5927
  env,
5416
5928
  cwd: projectDir
5417
5929
  });
5418
- return JSON.parse(stdout);
5930
+ const parsed = JSON.parse(stdout);
5931
+ if (!parsed)
5932
+ return null;
5933
+ return {
5934
+ settingsModule: parsed.settings_module,
5935
+ djangoSettings: parsed.django_settings
5936
+ };
5419
5937
  } catch (err) {
5420
5938
  (0, import_build_utils12.debug)(`Django hook: failed to discover settings from manage.py: ${err}`);
5421
5939
  return null;
5422
5940
  }
5423
5941
  }
5942
+ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir, settingsModule, djangoSettings) {
5943
+ const pythonPath = getVenvPythonBin(venvPath);
5944
+ const storages = djangoSettings["STORAGES"];
5945
+ const storageBackend = storages?.staticfiles?.BACKEND ?? djangoSettings["STATICFILES_STORAGE"] ?? "django.contrib.staticfiles.storage.StaticFilesStorage";
5946
+ const staticUrl = djangoSettings["STATIC_URL"] ?? "/static/";
5947
+ const staticRoot = djangoSettings["STATIC_ROOT"] != null ? String(djangoSettings["STATIC_ROOT"]) : null;
5948
+ const whitenoiseUseFinders = djangoSettings["WHITENOISE_USE_FINDERS"] === true;
5949
+ const installedApps = djangoSettings["INSTALLED_APPS"] ?? [];
5950
+ const staticfilesDirs = djangoSettings["STATICFILES_DIRS"] ?? [];
5951
+ const staticSourceDirs = [
5952
+ ...installedApps.map((app) => (0, import_path11.join)(workPath, ...app.split("."), "static")),
5953
+ // TODO: Deal with optional prefixes in STATICFILES_DIRS.
5954
+ ...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
5955
+ ].filter((d) => import_fs9.default.existsSync(d));
5956
+ if (storageBackend.startsWith("storages.backends.")) {
5957
+ console.log(
5958
+ "django-storages detected \u2014 running collectstatic with original settings"
5959
+ );
5960
+ await (0, import_execa5.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
5961
+ env: { ...env, DJANGO_SETTINGS_MODULE: settingsModule },
5962
+ cwd: workPath
5963
+ });
5964
+ return {
5965
+ staticSourceDirs,
5966
+ staticRoot: staticRoot ? (0, import_path11.resolve)(workPath, staticRoot) : null,
5967
+ manifestRelPath: null
5968
+ };
5969
+ }
5970
+ if (!staticRoot && !whitenoiseUseFinders) {
5971
+ console.log(
5972
+ "No collectstatic strategy configured \u2014 skipping collectstatic"
5973
+ );
5974
+ return null;
5975
+ }
5976
+ const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
5977
+ const staticOutputDir = (0, import_path11.join)(outputStaticDir, staticUrlPath);
5978
+ await import_fs9.default.promises.mkdir(staticOutputDir, { recursive: true });
5979
+ const shimPath = (0, import_path11.join)(workPath, "_vercel_collectstatic_settings.py");
5980
+ const shimLines = [
5981
+ `from ${settingsModule} import *`,
5982
+ `STATIC_ROOT = ${JSON.stringify(staticOutputDir)}`
5983
+ ];
5984
+ if (whitenoiseUseFinders) {
5985
+ shimLines.push(`WHITENOISE_USE_FINDERS = False`);
5986
+ }
5987
+ await import_fs9.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
5988
+ try {
5989
+ console.log("Running collectstatic...");
5990
+ await (0, import_execa5.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
5991
+ env: {
5992
+ ...env,
5993
+ DJANGO_SETTINGS_MODULE: "_vercel_collectstatic_settings"
5994
+ },
5995
+ cwd: workPath
5996
+ });
5997
+ } finally {
5998
+ await import_fs9.default.promises.unlink(shimPath).catch(() => {
5999
+ });
6000
+ }
6001
+ const MANIFEST_STORAGE_BACKENDS = [
6002
+ "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
6003
+ "whitenoise.storage.CompressedManifestStaticFilesStorage"
6004
+ ];
6005
+ let manifestRelPath = null;
6006
+ if (MANIFEST_STORAGE_BACKENDS.includes(storageBackend) && staticRoot) {
6007
+ const manifestSrc = (0, import_path11.join)(staticOutputDir, "staticfiles.json");
6008
+ const resolvedStaticRoot = (0, import_path11.resolve)(workPath, staticRoot);
6009
+ const manifestDest = (0, import_path11.join)(resolvedStaticRoot, "staticfiles.json");
6010
+ await import_fs9.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
6011
+ await import_fs9.default.promises.copyFile(manifestSrc, manifestDest);
6012
+ manifestRelPath = (0, import_path11.relative)(workPath, manifestDest);
6013
+ (0, import_build_utils12.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
6014
+ }
6015
+ return {
6016
+ staticSourceDirs,
6017
+ staticRoot: staticRoot ? (0, import_path11.resolve)(workPath, staticRoot) : null,
6018
+ manifestRelPath
6019
+ };
6020
+ }
5424
6021
 
5425
6022
  // src/index.ts
5426
6023
  var import_python_analysis7 = require("@vercel/python-analysis");
@@ -5431,30 +6028,50 @@ async function runFrameworkHook(framework, ctx) {
5431
6028
  return hook?.(ctx);
5432
6029
  }
5433
6030
  var frameworkHooks = {
5434
- django: async ({ pythonEnv, projectDir, detected }) => {
6031
+ django: async ({
6032
+ pythonEnv,
6033
+ projectDir,
6034
+ workPath,
6035
+ venvPath,
6036
+ detected
6037
+ }) => {
5435
6038
  if (detected?.baseDir === void 0) {
5436
6039
  (0, import_build_utils13.debug)("Django hook: no manage.py detected, skipping");
5437
6040
  return;
5438
6041
  }
5439
- const settings = await getDjangoSettings(projectDir, pythonEnv);
5440
- (0, import_build_utils13.debug)(`Django settings: ${JSON.stringify(settings)}`);
5441
- if (!settings)
6042
+ const settingsResult = await getDjangoSettings(projectDir, pythonEnv);
6043
+ (0, import_build_utils13.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
6044
+ if (!settingsResult)
5442
6045
  return;
6046
+ const { djangoSettings, settingsModule } = settingsResult;
6047
+ let entrypoint;
5443
6048
  const baseDir = detected?.baseDir ?? "";
5444
- const asgiApp = settings["ASGI_APPLICATION"];
6049
+ const asgiApp = djangoSettings["ASGI_APPLICATION"];
5445
6050
  if (typeof asgiApp === "string") {
5446
6051
  const rel = `${asgiApp.split(".").slice(0, -1).join("/")}.py`;
5447
- const entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
6052
+ entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
5448
6053
  (0, import_build_utils13.debug)(`Django hook: ASGI entrypoint: ${entrypoint}`);
5449
- return { entrypoint };
6054
+ } else {
6055
+ const wsgiApp = djangoSettings["WSGI_APPLICATION"];
6056
+ if (typeof wsgiApp === "string") {
6057
+ const rel = `${wsgiApp.split(".").slice(0, -1).join("/")}.py`;
6058
+ entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
6059
+ (0, import_build_utils13.debug)(`Django hook: WSGI entrypoint: ${entrypoint}`);
6060
+ }
5450
6061
  }
5451
- const wsgiApp = settings["WSGI_APPLICATION"];
5452
- if (typeof wsgiApp === "string") {
5453
- const rel = `${wsgiApp.split(".").slice(0, -1).join("/")}.py`;
5454
- const entrypoint = baseDir ? `${baseDir}/${rel}` : rel;
5455
- (0, import_build_utils13.debug)(`Django hook: WSGI entrypoint: ${entrypoint}`);
5456
- return { entrypoint };
6062
+ let djangoStatic = null;
6063
+ if (venvPath) {
6064
+ const outputStaticDir = (0, import_path12.join)(workPath, ".vercel", "output", "static");
6065
+ djangoStatic = await runDjangoCollectStatic(
6066
+ venvPath,
6067
+ workPath,
6068
+ pythonEnv,
6069
+ outputStaticDir,
6070
+ settingsModule,
6071
+ djangoSettings
6072
+ );
5457
6073
  }
6074
+ return { entrypoint, djangoStatic };
5458
6075
  }
5459
6076
  };
5460
6077
  async function downloadFilesInWorkPath({
@@ -5615,7 +6232,6 @@ var build = async ({
5615
6232
  let uvLockPath = null;
5616
6233
  let uvProjectDir = null;
5617
6234
  let projectName;
5618
- let noBuildCheckFailed = false;
5619
6235
  await builderSpan.child(import_build_utils13.BUILDER_INSTALLER_STEP, {
5620
6236
  installCommand: projectInstallCommand || void 0
5621
6237
  }).trace(async () => {
@@ -5654,22 +6270,6 @@ var build = async ({
5654
6270
  uvLockPath = lockPath;
5655
6271
  uvProjectDir = projectDir;
5656
6272
  projectName = pythonPackage?.manifest?.data?.project?.name;
5657
- if (lockFileProvidedByUser) {
5658
- try {
5659
- await uv.sync({
5660
- venvPath,
5661
- projectDir,
5662
- frozen: true,
5663
- noBuild: true,
5664
- noInstallProject: true
5665
- });
5666
- } catch (err) {
5667
- noBuildCheckFailed = true;
5668
- (0, import_build_utils13.debug)(
5669
- `--no-build check failed: ${err instanceof Error ? err.message : String(err)}`
5670
- );
5671
- }
5672
- }
5673
6273
  await uv.sync({
5674
6274
  venvPath,
5675
6275
  projectDir,
@@ -5702,6 +6302,8 @@ var build = async ({
5702
6302
  const hookResult = await runFrameworkHook(framework, {
5703
6303
  pythonEnv,
5704
6304
  projectDir: (0, import_path12.join)(workPath, entryDirectory),
6305
+ workPath,
6306
+ venvPath,
5705
6307
  entrypoint,
5706
6308
  detected
5707
6309
  });
@@ -5712,6 +6314,7 @@ var build = async ({
5712
6314
  if (entrypointNotFound) {
5713
6315
  throw entrypointNotFound;
5714
6316
  }
6317
+ const djangoStatic = hookResult?.djangoStatic ?? null;
5715
6318
  const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
5716
6319
  (0, import_build_utils13.debug)(`Installing ${runtimeDep}`);
5717
6320
  await uv.pip({
@@ -5808,6 +6411,18 @@ from vercel_runtime.vc_init import vc_handler
5808
6411
  "**/yarn.lock",
5809
6412
  "**/package-lock.json"
5810
6413
  ];
6414
+ if (djangoStatic) {
6415
+ const dirsToExclude = [
6416
+ ...djangoStatic.staticSourceDirs,
6417
+ ...djangoStatic.staticRoot ? [djangoStatic.staticRoot] : []
6418
+ ];
6419
+ for (const absDir of dirsToExclude) {
6420
+ const rel = (0, import_path12.relative)(workPath, absDir);
6421
+ if (!rel.startsWith("..")) {
6422
+ predefinedExcludes.push(`${rel}/**`);
6423
+ }
6424
+ }
6425
+ }
5811
6426
  const lambdaEnv = {};
5812
6427
  lambdaEnv.PYTHONPATH = vendorDir;
5813
6428
  Object.assign(lambdaEnv, quirksResult.env);
@@ -5816,6 +6431,11 @@ from vercel_runtime.vc_init import vc_handler
5816
6431
  ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
5817
6432
  };
5818
6433
  const files = await (0, import_build_utils13.glob)("**", globOptions);
6434
+ if (djangoStatic?.manifestRelPath) {
6435
+ files[djangoStatic.manifestRelPath] = new import_build_utils13.FileFsRef({
6436
+ fsPath: (0, import_path12.join)(workPath, djangoStatic.manifestRelPath)
6437
+ });
6438
+ }
5819
6439
  const depExternalizer = new PythonDependencyExternalizer({
5820
6440
  venvPath,
5821
6441
  vendorDir,
@@ -5823,7 +6443,8 @@ from vercel_runtime.vc_init import vc_handler
5823
6443
  uvLockPath,
5824
6444
  uvProjectDir,
5825
6445
  projectName,
5826
- noBuildCheckFailed,
6446
+ pythonMajor: pythonVersion.major,
6447
+ pythonMinor: pythonVersion.minor,
5827
6448
  pythonPath: pythonVersion.pythonPath,
5828
6449
  hasCustomCommand,
5829
6450
  alwaysBundlePackages: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.22.1",
3
+ "version": "6.24.0",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -15,7 +15,7 @@
15
15
  "directory": "packages/python"
16
16
  },
17
17
  "dependencies": {
18
- "@vercel/python-analysis": "0.9.1"
18
+ "@vercel/python-analysis": "0.10.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@renovatebot/pep440": "4.2.1",
@@ -25,19 +25,20 @@
25
25
  "@types/node": "20.11.0",
26
26
  "@types/which": "3.0.0",
27
27
  "cross-env": "7.0.3",
28
+ "detect-libc": "2.1.2",
28
29
  "execa": "^1.0.0",
29
30
  "fs-extra": "11.1.1",
31
+ "get-port": "5.1.1",
32
+ "is-port-reachable": "3.1.0",
30
33
  "jest-junit": "16.0.0",
31
34
  "minimatch": "10.1.1",
32
35
  "pip-requirements-js": "1.0.2",
33
36
  "smol-toml": "1.5.2",
34
37
  "vitest": "2.1.4",
35
38
  "which": "3.0.0",
36
- "get-port": "5.1.1",
37
- "is-port-reachable": "3.1.0",
38
- "@vercel/build-utils": "13.8.0",
39
39
  "@vercel/error-utils": "2.0.3",
40
- "@vercel/python-runtime": "0.7.0"
40
+ "@vercel/python-runtime": "0.9.0",
41
+ "@vercel/build-utils": "13.8.1"
41
42
  },
42
43
  "scripts": {
43
44
  "build": "node ../../utils/build-builder.mjs",
@@ -33,4 +33,12 @@ else:
33
33
 
34
34
  mod = importlib.import_module(settings_module)
35
35
  settings = {k: getattr(mod, k) for k in dir(mod) if k.isupper()}
36
- print(json.dumps(settings, default=str))
36
+ print(
37
+ json.dumps(
38
+ {
39
+ "settings_module": settings_module,
40
+ "django_settings": settings,
41
+ },
42
+ default=str,
43
+ )
44
+ )
@@ -6,6 +6,7 @@ os.environ.update(
6
6
  {
7
7
  "VERCEL_DEV_MODULE_NAME": "__VC_DEV_MODULE_NAME__",
8
8
  "VERCEL_DEV_ENTRY_ABS": "__VC_DEV_ENTRY_ABS__",
9
+ "VERCEL_DEV_FRAMEWORK": "__VC_DEV_FRAMEWORK__",
9
10
  }
10
11
  )
11
12