@vercel/python 6.42.0 → 6.43.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 +506 -346
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -2647,6 +2647,94 @@ ${stderr}${stdout}`;
2647
2647
  }
2648
2648
  });
2649
2649
 
2650
+ // ../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js
2651
+ var require_lib = __commonJS({
2652
+ "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
2653
+ var isexe = require_isexe();
2654
+ var { join: join13, delimiter: delimiter2, sep: sep2, posix } = require("path");
2655
+ var isWindows = process.platform === "win32";
2656
+ var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
2657
+ var rRel = new RegExp(`^\\.${rSlash.source}`);
2658
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
2659
+ var getPathInfo = (cmd, {
2660
+ path: optPath = process.env.PATH,
2661
+ pathExt: optPathExt = process.env.PATHEXT,
2662
+ delimiter: optDelimiter = delimiter2
2663
+ }) => {
2664
+ const pathEnv = cmd.match(rSlash) ? [""] : [
2665
+ // windows always checks the cwd first
2666
+ ...isWindows ? [process.cwd()] : [],
2667
+ ...(optPath || /* istanbul ignore next: very unusual */
2668
+ "").split(optDelimiter)
2669
+ ];
2670
+ if (isWindows) {
2671
+ const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
2672
+ const pathExt = pathExtExe.split(optDelimiter);
2673
+ if (cmd.includes(".") && pathExt[0] !== "") {
2674
+ pathExt.unshift("");
2675
+ }
2676
+ return { pathEnv, pathExt, pathExtExe };
2677
+ }
2678
+ return { pathEnv, pathExt: [""] };
2679
+ };
2680
+ var getPathPart = (raw, cmd) => {
2681
+ const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
2682
+ const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
2683
+ return prefix + join13(pathPart, cmd);
2684
+ };
2685
+ var which2 = async (cmd, opt = {}) => {
2686
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
2687
+ const found = [];
2688
+ for (const envPart of pathEnv) {
2689
+ const p = getPathPart(envPart, cmd);
2690
+ for (const ext of pathExt) {
2691
+ const withExt = p + ext;
2692
+ const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
2693
+ if (is) {
2694
+ if (!opt.all) {
2695
+ return withExt;
2696
+ }
2697
+ found.push(withExt);
2698
+ }
2699
+ }
2700
+ }
2701
+ if (opt.all && found.length) {
2702
+ return found;
2703
+ }
2704
+ if (opt.nothrow) {
2705
+ return null;
2706
+ }
2707
+ throw getNotFoundError(cmd);
2708
+ };
2709
+ var whichSync = (cmd, opt = {}) => {
2710
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
2711
+ const found = [];
2712
+ for (const pathEnvPart of pathEnv) {
2713
+ const p = getPathPart(pathEnvPart, cmd);
2714
+ for (const ext of pathExt) {
2715
+ const withExt = p + ext;
2716
+ const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
2717
+ if (is) {
2718
+ if (!opt.all) {
2719
+ return withExt;
2720
+ }
2721
+ found.push(withExt);
2722
+ }
2723
+ }
2724
+ }
2725
+ if (opt.all && found.length) {
2726
+ return found;
2727
+ }
2728
+ if (opt.nothrow) {
2729
+ return null;
2730
+ }
2731
+ throw getNotFoundError(cmd);
2732
+ };
2733
+ module2.exports = which2;
2734
+ which2.sync = whichSync;
2735
+ }
2736
+ });
2737
+
2650
2738
  // ../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js
2651
2739
  var require_process = __commonJS({
2652
2740
  "../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/process.js"(exports, module2) {
@@ -2780,14 +2868,14 @@ var require_detect_libc = __commonJS({
2780
2868
  }
2781
2869
  return commandOut;
2782
2870
  };
2783
- var GLIBC2 = "glibc";
2871
+ var GLIBC = "glibc";
2784
2872
  var RE_GLIBC_VERSION = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i;
2785
2873
  var MUSL2 = "musl";
2786
2874
  var isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
2787
2875
  var familyFromReport = () => {
2788
2876
  const report = getReport();
2789
2877
  if (report.header && report.header.glibcVersionRuntime) {
2790
- return GLIBC2;
2878
+ return GLIBC;
2791
2879
  }
2792
2880
  if (Array.isArray(report.sharedObjects)) {
2793
2881
  if (report.sharedObjects.some(isFileMusl)) {
@@ -2798,8 +2886,8 @@ var require_detect_libc = __commonJS({
2798
2886
  };
2799
2887
  var familyFromCommand = (out) => {
2800
2888
  const [getconf, ldd1] = out.split(/[\r\n]+/);
2801
- if (getconf && getconf.includes(GLIBC2)) {
2802
- return GLIBC2;
2889
+ if (getconf && getconf.includes(GLIBC)) {
2890
+ return GLIBC;
2803
2891
  }
2804
2892
  if (ldd1 && ldd1.includes(MUSL2)) {
2805
2893
  return MUSL2;
@@ -2811,7 +2899,7 @@ var require_detect_libc = __commonJS({
2811
2899
  if (path.includes("/ld-musl-")) {
2812
2900
  return MUSL2;
2813
2901
  } else if (path.includes("/ld-linux-")) {
2814
- return GLIBC2;
2902
+ return GLIBC;
2815
2903
  }
2816
2904
  }
2817
2905
  return null;
@@ -2822,7 +2910,7 @@ var require_detect_libc = __commonJS({
2822
2910
  return MUSL2;
2823
2911
  }
2824
2912
  if (content.includes("GNU C Library")) {
2825
- return GLIBC2;
2913
+ return GLIBC;
2826
2914
  }
2827
2915
  return null;
2828
2916
  };
@@ -2910,8 +2998,8 @@ var require_detect_libc = __commonJS({
2910
2998
  }
2911
2999
  return family2;
2912
3000
  };
2913
- var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC2;
2914
- var isNonGlibcLinuxSync = () => isLinux() && familySync2() !== GLIBC2;
3001
+ var isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
3002
+ var isNonGlibcLinuxSync = () => isLinux() && familySync2() !== GLIBC;
2915
3003
  var versionFromFilesystem = async () => {
2916
3004
  if (cachedVersionFilesystem !== void 0) {
2917
3005
  return cachedVersionFilesystem;
@@ -2952,7 +3040,7 @@ var require_detect_libc = __commonJS({
2952
3040
  var versionSuffix = (s) => s.trim().split(/\s+/)[1];
2953
3041
  var versionFromCommand = (out) => {
2954
3042
  const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
2955
- if (getconf && getconf.includes(GLIBC2)) {
3043
+ if (getconf && getconf.includes(GLIBC)) {
2956
3044
  return versionSuffix(getconf);
2957
3045
  }
2958
3046
  if (ldd1 && ldd2 && ldd1.includes(MUSL2)) {
@@ -2989,7 +3077,7 @@ var require_detect_libc = __commonJS({
2989
3077
  return version3;
2990
3078
  };
2991
3079
  module2.exports = {
2992
- GLIBC: GLIBC2,
3080
+ GLIBC,
2993
3081
  MUSL: MUSL2,
2994
3082
  family,
2995
3083
  familySync: familySync2,
@@ -3001,94 +3089,6 @@ var require_detect_libc = __commonJS({
3001
3089
  }
3002
3090
  });
3003
3091
 
3004
- // ../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js
3005
- var require_lib = __commonJS({
3006
- "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
3007
- var isexe = require_isexe();
3008
- var { join: join13, delimiter: delimiter2, sep: sep2, posix } = require("path");
3009
- var isWindows = process.platform === "win32";
3010
- var rSlash = new RegExp(`[${posix.sep}${sep2 === posix.sep ? "" : sep2}]`.replace(/(\\)/g, "\\$1"));
3011
- var rRel = new RegExp(`^\\.${rSlash.source}`);
3012
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
3013
- var getPathInfo = (cmd, {
3014
- path: optPath = process.env.PATH,
3015
- pathExt: optPathExt = process.env.PATHEXT,
3016
- delimiter: optDelimiter = delimiter2
3017
- }) => {
3018
- const pathEnv = cmd.match(rSlash) ? [""] : [
3019
- // windows always checks the cwd first
3020
- ...isWindows ? [process.cwd()] : [],
3021
- ...(optPath || /* istanbul ignore next: very unusual */
3022
- "").split(optDelimiter)
3023
- ];
3024
- if (isWindows) {
3025
- const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
3026
- const pathExt = pathExtExe.split(optDelimiter);
3027
- if (cmd.includes(".") && pathExt[0] !== "") {
3028
- pathExt.unshift("");
3029
- }
3030
- return { pathEnv, pathExt, pathExtExe };
3031
- }
3032
- return { pathEnv, pathExt: [""] };
3033
- };
3034
- var getPathPart = (raw, cmd) => {
3035
- const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
3036
- const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
3037
- return prefix + join13(pathPart, cmd);
3038
- };
3039
- var which2 = async (cmd, opt = {}) => {
3040
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
3041
- const found = [];
3042
- for (const envPart of pathEnv) {
3043
- const p = getPathPart(envPart, cmd);
3044
- for (const ext of pathExt) {
3045
- const withExt = p + ext;
3046
- const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
3047
- if (is) {
3048
- if (!opt.all) {
3049
- return withExt;
3050
- }
3051
- found.push(withExt);
3052
- }
3053
- }
3054
- }
3055
- if (opt.all && found.length) {
3056
- return found;
3057
- }
3058
- if (opt.nothrow) {
3059
- return null;
3060
- }
3061
- throw getNotFoundError(cmd);
3062
- };
3063
- var whichSync = (cmd, opt = {}) => {
3064
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
3065
- const found = [];
3066
- for (const pathEnvPart of pathEnv) {
3067
- const p = getPathPart(pathEnvPart, cmd);
3068
- for (const ext of pathExt) {
3069
- const withExt = p + ext;
3070
- const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
3071
- if (is) {
3072
- if (!opt.all) {
3073
- return withExt;
3074
- }
3075
- found.push(withExt);
3076
- }
3077
- }
3078
- }
3079
- if (opt.all && found.length) {
3080
- return found;
3081
- }
3082
- if (opt.nothrow) {
3083
- return null;
3084
- }
3085
- throw getNotFoundError(cmd);
3086
- };
3087
- module2.exports = which2;
3088
- which2.sync = whichSync;
3089
- }
3090
- });
3091
-
3092
3092
  // ../../node_modules/.pnpm/get-port@5.1.1/node_modules/get-port/index.js
3093
3093
  var require_get_port = __commonJS({
3094
3094
  "../../node_modules/.pnpm/get-port@5.1.1/node_modules/get-port/index.js"(exports, module2) {
@@ -3231,31 +3231,32 @@ var import_fs13 = __toESM(require("fs"));
3231
3231
  var import_path13 = require("path");
3232
3232
 
3233
3233
  // src/package-versions.ts
3234
- var VERCEL_RUNTIME_VERSION = "0.13.2";
3235
- var VERCEL_WORKERS_VERSION = "0.0.23";
3234
+ var VERCEL_RUNTIME_VERSION = "0.14.0";
3235
+ var VERCEL_WORKERS_VERSION = "0.0.24";
3236
3236
 
3237
3237
  // src/index.ts
3238
- var import_build_utils16 = require("@vercel/build-utils");
3238
+ var import_build_utils17 = require("@vercel/build-utils");
3239
3239
 
3240
3240
  // src/install.ts
3241
3241
  var import_execa3 = __toESM(require_execa());
3242
3242
  var import_fs4 = __toESM(require("fs"));
3243
3243
  var import_path5 = require("path");
3244
- var import_build_utils4 = require("@vercel/build-utils");
3244
+ var import_build_utils5 = require("@vercel/build-utils");
3245
3245
  var import_python_analysis2 = require("@vercel/python-analysis");
3246
3246
 
3247
3247
  // src/utils.ts
3248
3248
  var import_fs2 = __toESM(require("fs"));
3249
- var import_os2 = __toESM(require("os"));
3250
3249
  var import_path3 = require("path");
3251
3250
  var import_build_utils2 = require("@vercel/build-utils");
3252
- var detectLibc = __toESM(require_detect_libc());
3253
3251
  var import_execa2 = __toESM(require_execa());
3254
3252
 
3255
3253
  // src/uv.ts
3254
+ var import_crypto = require("crypto");
3256
3255
  var import_child_process = require("child_process");
3257
3256
  var import_path = require("path");
3258
3257
  var import_path2 = require("path");
3258
+ var import_stream = require("stream");
3259
+ var import_promises = require("stream/promises");
3259
3260
  var import_execa = __toESM(require_execa());
3260
3261
  var import_fs = __toESM(require("fs"));
3261
3262
  var import_os = __toESM(require("os"));
@@ -3265,6 +3266,7 @@ var UV_VERSION = "0.10.11";
3265
3266
  var UV_PYTHON_PATH_PREFIX = "/uv/python/";
3266
3267
  var UV_PYTHON_DOWNLOADS_MODE = "automatic";
3267
3268
  var UV_CACHE_DIR_SUBPATH = [".vercel", "python", "cache", "uv"];
3269
+ var UV_BINARY_CHECKSUM = "5a360b0de092ddf4131f5313d0411b48c4e95e8107e40c3f8f2e9fcb636b3583";
3268
3270
  var isWin = process.platform === "win32";
3269
3271
  var uvExec = isWin ? "uv.exe" : "uv";
3270
3272
  var KNOWN_UV_PATH = "/usr/local/bin/uv";
@@ -3294,9 +3296,14 @@ var UvRunner = class {
3294
3296
  listInstalledPythons() {
3295
3297
  let output;
3296
3298
  try {
3297
- output = (0, import_child_process.execSync)(
3298
- `${this.uvPath} python list --only-installed --output-format json`,
3299
- { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }
3299
+ output = (0, import_child_process.execFileSync)(
3300
+ this.uvPath,
3301
+ ["python", "list", "--only-installed", "--output-format", "json"],
3302
+ {
3303
+ encoding: "utf8",
3304
+ stdio: ["pipe", "pipe", "pipe"],
3305
+ shell: isWin
3306
+ }
3300
3307
  );
3301
3308
  } catch (err) {
3302
3309
  throw new Error(
@@ -3330,7 +3337,15 @@ var UvRunner = class {
3330
3337
  );
3331
3338
  }
3332
3339
  async sync(options) {
3333
- const { venvPath, projectDir, locked, frozen, noBuild, noInstallProject } = options;
3340
+ const {
3341
+ venvPath,
3342
+ projectDir,
3343
+ locked,
3344
+ frozen,
3345
+ noBuild,
3346
+ noInstallProject,
3347
+ pythonPlatform
3348
+ } = options;
3334
3349
  const args = ["sync", "--active", "--no-dev", "--link-mode", "hardlink"];
3335
3350
  if (frozen) {
3336
3351
  args.push("--frozen");
@@ -3343,6 +3358,9 @@ var UvRunner = class {
3343
3358
  if (noInstallProject) {
3344
3359
  args.push("--no-install-project");
3345
3360
  }
3361
+ if (pythonPlatform) {
3362
+ args.push("--python-platform", pythonPlatform);
3363
+ }
3346
3364
  args.push("--no-editable");
3347
3365
  await this.runUvCmd(args, projectDir, venvPath);
3348
3366
  }
@@ -3555,6 +3573,98 @@ async function getUvBinaryForBundling(pythonPath) {
3555
3573
  const resolvedPath = await import_fs.default.promises.realpath(uvPath);
3556
3574
  return resolvedPath;
3557
3575
  }
3576
+ var UV_LINUX_TARGET = "x86_64-unknown-linux-gnu";
3577
+ async function downloadUvBinaryForTarget(cacheDir) {
3578
+ const destDir = (0, import_path.join)(cacheDir, `uv-${UV_VERSION}-${UV_LINUX_TARGET}`);
3579
+ const destBinary = (0, import_path.join)(destDir, "uv");
3580
+ try {
3581
+ await import_fs.default.promises.access(destBinary, import_fs.default.constants.X_OK);
3582
+ (0, import_build_utils.debug)(`Using cached uv binary at ${destBinary}`);
3583
+ return destBinary;
3584
+ } catch {
3585
+ }
3586
+ const tarballName = `uv-${UV_LINUX_TARGET}.tar.gz`;
3587
+ const url = `https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/${tarballName}`;
3588
+ (0, import_build_utils.debug)(`Downloading uv ${UV_VERSION} from ${url}`);
3589
+ console.log(
3590
+ `Downloading uv ${UV_VERSION} (linux x86_64) for runtime dependency installation...`
3591
+ );
3592
+ await import_fs.default.promises.mkdir(destDir, { recursive: true });
3593
+ const tarballPath = (0, import_path.join)(destDir, tarballName);
3594
+ await downloadUvTarball(url, tarballPath);
3595
+ const actualHash = await sha256File(tarballPath);
3596
+ if (actualHash !== UV_BINARY_CHECKSUM) {
3597
+ await import_fs.default.promises.unlink(tarballPath).catch(() => {
3598
+ });
3599
+ throw new import_build_utils.NowBuildError({
3600
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3601
+ message: `checksum mismatch for ${tarballName}: expected ${UV_BINARY_CHECKSUM}, got ${actualHash}`
3602
+ });
3603
+ }
3604
+ try {
3605
+ await (0, import_execa.default)("tar", [
3606
+ "xzf",
3607
+ tarballPath,
3608
+ "--strip-components=1",
3609
+ "-C",
3610
+ destDir
3611
+ ]);
3612
+ } catch (err) {
3613
+ throw new import_build_utils.NowBuildError({
3614
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3615
+ message: `could not extract ${tarballName}: ${err instanceof Error ? err.message : String(err)}`
3616
+ });
3617
+ }
3618
+ await import_fs.default.promises.chmod(destBinary, 493);
3619
+ await import_fs.default.promises.unlink(tarballPath).catch(() => {
3620
+ });
3621
+ (0, import_build_utils.debug)(`Downloaded uv binary to ${destBinary}`);
3622
+ return destBinary;
3623
+ }
3624
+ async function downloadUvTarball(url, dest) {
3625
+ const tmpDest = `${dest}.${process.pid}.${Date.now()}.tmp`;
3626
+ const controller = new AbortController();
3627
+ const timeout = setTimeout(() => controller.abort(), 6e4);
3628
+ try {
3629
+ const response = await fetch(url, {
3630
+ redirect: "follow",
3631
+ signal: controller.signal
3632
+ });
3633
+ if (!response.ok) {
3634
+ throw new import_build_utils.NowBuildError({
3635
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3636
+ message: `could not download ${url}: HTTP ${response.status}`
3637
+ });
3638
+ }
3639
+ if (!response.body) {
3640
+ throw new import_build_utils.NowBuildError({
3641
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3642
+ message: `could not download ${url}: response body was empty`
3643
+ });
3644
+ }
3645
+ await (0, import_promises.pipeline)(
3646
+ import_stream.Readable.fromWeb(response.body),
3647
+ import_fs.default.createWriteStream(tmpDest)
3648
+ );
3649
+ await import_fs.default.promises.rename(tmpDest, dest);
3650
+ } catch (err) {
3651
+ await import_fs.default.promises.unlink(tmpDest).catch(() => {
3652
+ });
3653
+ if (err instanceof import_build_utils.NowBuildError) {
3654
+ throw err;
3655
+ }
3656
+ throw new import_build_utils.NowBuildError({
3657
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
3658
+ message: `could not download ${url}: ${err instanceof Error ? err.message : String(err)}`
3659
+ });
3660
+ } finally {
3661
+ clearTimeout(timeout);
3662
+ }
3663
+ }
3664
+ async function sha256File(filePath) {
3665
+ const data = await import_fs.default.promises.readFile(filePath);
3666
+ return (0, import_crypto.createHash)("sha256").update(new Uint8Array(data)).digest("hex");
3667
+ }
3558
3668
 
3559
3669
  // src/utils.ts
3560
3670
  var isWin2 = process.platform === "win32";
@@ -3684,6 +3794,17 @@ async function runPyprojectScript(workPath, scriptNames, env, useUserVirtualEnv
3684
3794
  }
3685
3795
  return false;
3686
3796
  }
3797
+
3798
+ // src/version.ts
3799
+ var import_path4 = require("path");
3800
+ var import_fs3 = require("fs");
3801
+ var import_build_utils4 = require("@vercel/build-utils");
3802
+ var import_python_analysis = require("@vercel/python-analysis");
3803
+
3804
+ // src/platform-info.ts
3805
+ var import_os2 = __toESM(require("os"));
3806
+ var detectLibc = __toESM(require_detect_libc());
3807
+ var import_build_utils3 = require("@vercel/build-utils");
3687
3808
  var ARCH_MAP = {
3688
3809
  x64: "x86_64",
3689
3810
  arm64: "aarch64",
@@ -3693,58 +3814,73 @@ var ARCH_MAP = {
3693
3814
  s390x: "s390x"
3694
3815
  };
3695
3816
  function detectPlatform() {
3696
- const arch = import_os2.default.arch();
3697
- const archName = ARCH_MAP[arch] || arch;
3698
- const libcFamily = detectLibc.familySync();
3699
- const libcVersion = detectLibc.versionSync();
3700
- let osName;
3701
- let osMajor;
3702
- let osMinor;
3703
- if (libcFamily === detectLibc.MUSL) {
3704
- osName = "musllinux";
3705
- } else {
3706
- osName = "manylinux";
3707
- }
3708
- if (libcVersion) {
3709
- const parts = libcVersion.split(".");
3710
- osMajor = parseInt(parts[0], 10);
3711
- osMinor = parseInt(parts[1], 10) || 0;
3712
- } else if (libcFamily === detectLibc.GLIBC) {
3713
- osMajor = 2;
3714
- osMinor = 17;
3715
- } else {
3716
- osMajor = 2;
3717
- osMinor = 17;
3718
- }
3719
- const libc = libcFamily === detectLibc.MUSL ? "musl" : "gnu";
3720
3817
  const SYS_PLATFORM_MAP = {
3721
3818
  linux: "linux",
3722
3819
  win32: "win32",
3723
3820
  darwin: "darwin"
3724
3821
  };
3725
- const sysPlatform = SYS_PLATFORM_MAP[process.platform] || "linux";
3726
3822
  const OS_MAP = {
3727
3823
  linux: "linux",
3728
3824
  win32: "windows",
3729
3825
  darwin: "macos"
3730
3826
  };
3731
- const detectedOs = OS_MAP[process.platform] || "linux";
3732
- return {
3733
- osName,
3734
- archName,
3735
- osMajor,
3736
- osMinor,
3737
- os: detectedOs,
3738
- sysPlatform,
3739
- libc
3827
+ const arch = import_os2.default.arch();
3828
+ const libcFamily = detectLibc.familySync();
3829
+ const libcVersion = detectLibc.versionSync();
3830
+ const platform = {
3831
+ osName: "manylinux",
3832
+ archName: ARCH_MAP[arch] || arch,
3833
+ osMajor: 2,
3834
+ osMinor: 17,
3835
+ os: OS_MAP[process.platform] || "linux",
3836
+ sysPlatform: SYS_PLATFORM_MAP[process.platform] || "linux",
3837
+ libc: "gnu"
3740
3838
  };
3839
+ if (libcFamily === detectLibc.MUSL) {
3840
+ platform.osName = "musllinux";
3841
+ platform.libc = "musl";
3842
+ }
3843
+ if (libcVersion) {
3844
+ const parts = libcVersion.split(".");
3845
+ platform.osMajor = parseInt(parts[0], 10);
3846
+ platform.osMinor = parseInt(parts[1], 10) || 0;
3847
+ }
3848
+ return platform;
3849
+ }
3850
+ function validateBuildArch(arch) {
3851
+ switch (arch.toLowerCase()) {
3852
+ case "x86_64":
3853
+ return "x86_64";
3854
+ case "aarch64":
3855
+ return "aarch64";
3856
+ default:
3857
+ throw new import_build_utils3.NowBuildError({
3858
+ code: "INVALID_BUILD_ARCH",
3859
+ message: `Unrecognized VERCEL_BUILD_ARCH "${arch}". Expected "x86_64" or "aarch64".`
3860
+ });
3861
+ }
3862
+ }
3863
+ function detectTargetPlatform() {
3864
+ if (process.env.VERCEL_BUILD_IMAGE && process.platform === "linux") {
3865
+ return detectPlatform();
3866
+ }
3867
+ const arch = process.env.VERCEL_BUILD_ARCH;
3868
+ const platform = {
3869
+ osName: "manylinux",
3870
+ archName: "x86_64",
3871
+ osMajor: 2,
3872
+ osMinor: 17,
3873
+ os: "linux",
3874
+ sysPlatform: "linux",
3875
+ libc: "gnu"
3876
+ };
3877
+ if (arch) {
3878
+ platform.archName = validateBuildArch(arch);
3879
+ }
3880
+ return platform;
3741
3881
  }
3742
3882
 
3743
3883
  // src/version.ts
3744
- var import_path4 = require("path");
3745
- var import_fs3 = require("fs");
3746
- var import_build_utils3 = require("@vercel/build-utils");
3747
- var import_python_analysis = require("@vercel/python-analysis");
3748
3884
  function pythonVersionString(pv) {
3749
3885
  if (pv.major === void 0 || pv.minor === void 0)
3750
3886
  return void 0;
@@ -3794,7 +3930,7 @@ function getDefaultPythonVersion({
3794
3930
  }
3795
3931
  const selection = allOptions.find(isInstalled);
3796
3932
  if (!selection) {
3797
- throw new import_build_utils3.NowBuildError({
3933
+ throw new import_build_utils4.NowBuildError({
3798
3934
  code: "PYTHON_NOT_FOUND",
3799
3935
  link: "https://vercel.link/python-version",
3800
3936
  message: `Unable to find any supported Python versions.`
@@ -3894,7 +4030,7 @@ function resolvePythonVersion({
3894
4030
  } else if (result.notAvailable) {
3895
4031
  const npv = getPythonVersionForBuild(result.notAvailable.build);
3896
4032
  if (npv && isDiscontinued(npv)) {
3897
- throw new import_build_utils3.NowBuildError({
4033
+ throw new import_build_utils4.NowBuildError({
3898
4034
  code: "BUILD_UTILS_PYTHON_VERSION_DISCONTINUED",
3899
4035
  link: "https://vercel.link/python-version",
3900
4036
  message: `Python version "${pythonVersionString(npv)}" detected in ${source} is discontinued and must be upgraded.`
@@ -3918,7 +4054,7 @@ function resolvePythonVersion({
3918
4054
  }
3919
4055
  }
3920
4056
  if (isDiscontinued(selection)) {
3921
- throw new import_build_utils3.NowBuildError({
4057
+ throw new import_build_utils4.NowBuildError({
3922
4058
  code: "BUILD_UTILS_PYTHON_VERSION_DISCONTINUED",
3923
4059
  link: "https://vercel.link/python-version",
3924
4060
  message: `Python version "${pythonVersionString(selection)}" declared in project configuration is discontinued and must be upgraded.`
@@ -3976,7 +4112,7 @@ function getInstalledPythons() {
3976
4112
  }
3977
4113
  const uvPath = findUvInPath();
3978
4114
  if (!uvPath) {
3979
- throw new import_build_utils3.NowBuildError({
4115
+ throw new import_build_utils4.NowBuildError({
3980
4116
  code: "UV_ERROR",
3981
4117
  link: "https://vercel.link/python-version",
3982
4118
  message: "uv is required but was not found in PATH."
@@ -3994,7 +4130,7 @@ function isInstalled(pv) {
3994
4130
  return false;
3995
4131
  return installed.has(version2);
3996
4132
  } catch (err) {
3997
- throw new import_build_utils3.NowBuildError({
4133
+ throw new import_build_utils4.NowBuildError({
3998
4134
  code: "UV_ERROR",
3999
4135
  link: "https://vercel.link/python-version",
4000
4136
  message: err instanceof Error ? err.message : String(err)
@@ -4008,7 +4144,7 @@ async function restoreCachedLock(cachedLockPath, projectDir) {
4008
4144
  return;
4009
4145
  const targetLockPath = (0, import_path5.join)(projectDir, "uv.lock");
4010
4146
  if (import_fs4.default.existsSync(cachedLockPath) && !import_fs4.default.existsSync(targetLockPath)) {
4011
- (0, import_build_utils4.debug)("Restoring cached uv.lock");
4147
+ (0, import_build_utils5.debug)("Restoring cached uv.lock");
4012
4148
  await import_fs4.default.promises.copyFile(cachedLockPath, targetLockPath);
4013
4149
  }
4014
4150
  }
@@ -4075,7 +4211,7 @@ print(json.dumps(paths))
4075
4211
  return parsed.filter((p) => typeof p === "string");
4076
4212
  }
4077
4213
  } catch (err) {
4078
- (0, import_build_utils4.debug)("Failed to parse site-packages output", err);
4214
+ (0, import_build_utils5.debug)("Failed to parse site-packages output", err);
4079
4215
  }
4080
4216
  return [];
4081
4217
  }
@@ -4101,7 +4237,7 @@ async function discoverPackage({
4101
4237
  ${error.fileContent}`
4102
4238
  );
4103
4239
  }
4104
- throw new import_build_utils4.NowBuildError({
4240
+ throw new import_build_utils5.NowBuildError({
4105
4241
  code: error.code,
4106
4242
  message: error.message,
4107
4243
  link: error.link,
@@ -4240,7 +4376,7 @@ async function pipInstall(pipPath, uvPath, workPath, args, targetDir) {
4240
4376
  ...filterUnsafeUvPipArgs(args)
4241
4377
  ];
4242
4378
  const prettyUv = `${uvPath} ${uvArgs.join(" ")}`;
4243
- (0, import_build_utils4.debug)(`Running "${prettyUv}"...`);
4379
+ (0, import_build_utils5.debug)(`Running "${prettyUv}"...`);
4244
4380
  try {
4245
4381
  await (0, import_execa3.default)(uvPath, uvArgs, {
4246
4382
  cwd: workPath,
@@ -4249,7 +4385,7 @@ async function pipInstall(pipPath, uvPath, workPath, args, targetDir) {
4249
4385
  return;
4250
4386
  } catch (err) {
4251
4387
  console.log(`Failed to run "${prettyUv}", falling back to pip`);
4252
- (0, import_build_utils4.debug)(`error: ${err}`);
4388
+ (0, import_build_utils5.debug)(`error: ${err}`);
4253
4389
  }
4254
4390
  }
4255
4391
  const cmdArgs = [
@@ -4262,14 +4398,14 @@ async function pipInstall(pipPath, uvPath, workPath, args, targetDir) {
4262
4398
  ...args
4263
4399
  ];
4264
4400
  const pretty = `${pipPath} ${cmdArgs.join(" ")}`;
4265
- (0, import_build_utils4.debug)(`Running "${pretty}"...`);
4401
+ (0, import_build_utils5.debug)(`Running "${pretty}"...`);
4266
4402
  try {
4267
4403
  await (0, import_execa3.default)(pipPath, cmdArgs, {
4268
4404
  cwd: workPath
4269
4405
  });
4270
4406
  } catch (err) {
4271
4407
  console.log(`Failed to run "${pretty}"`);
4272
- (0, import_build_utils4.debug)(`error: ${err}`);
4408
+ (0, import_build_utils5.debug)(`error: ${err}`);
4273
4409
  throw err;
4274
4410
  }
4275
4411
  }
@@ -4286,7 +4422,7 @@ async function installRequirement({
4286
4422
  }) {
4287
4423
  const actualTargetDir = targetDir || workPath;
4288
4424
  if (meta.isDev && await isInstalled2(pythonPath, dependency, actualTargetDir)) {
4289
- (0, import_build_utils4.debug)(
4425
+ (0, import_build_utils5.debug)(
4290
4426
  `Skipping ${dependency} dependency installation, already installed in ${actualTargetDir}`
4291
4427
  );
4292
4428
  return;
@@ -4306,7 +4442,7 @@ async function installRequirementsFile({
4306
4442
  }) {
4307
4443
  const actualTargetDir = targetDir || workPath;
4308
4444
  if (meta.isDev && await areRequirementsInstalled(pythonPath, filePath, actualTargetDir)) {
4309
- (0, import_build_utils4.debug)(`Skipping requirements file installation, already installed`);
4445
+ (0, import_build_utils5.debug)(`Skipping requirements file installation, already installed`);
4310
4446
  return;
4311
4447
  }
4312
4448
  await pipInstall(
@@ -4322,7 +4458,7 @@ async function installRequirementsFile({
4322
4458
  var import_fs5 = __toESM(require("fs"));
4323
4459
  var import_util = require("util");
4324
4460
  var import_path6 = require("path");
4325
- var import_build_utils5 = require("@vercel/build-utils");
4461
+ var import_build_utils6 = require("@vercel/build-utils");
4326
4462
  var import_python_analysis3 = require("@vercel/python-analysis");
4327
4463
  var readFile = (0, import_util.promisify)(import_fs5.default.readFile);
4328
4464
  var LAMBDA_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
@@ -4339,14 +4475,11 @@ function shouldShowFunctionsBetaHint() {
4339
4475
  var PythonDependencyExternalizer = class {
4340
4476
  constructor(options) {
4341
4477
  // Populated by analyze()
4478
+ this.sitePackageDirs = [];
4479
+ this.distributions = /* @__PURE__ */ new Map();
4342
4480
  this.allVendorFiles = {};
4343
4481
  this.totalBundleSize = 0;
4344
4482
  this.analyzed = false;
4345
- // Resolved once at the start of analyze(). The venv is immutable
4346
- // after construction (quirks run before the bundle span) so these
4347
- // do not change between analyze() and generateBundle().
4348
- this.sitePackageDirs = null;
4349
- this.distributions = null;
4350
4483
  this.venvPath = options.venvPath;
4351
4484
  this.vendorDir = options.vendorDir;
4352
4485
  this.workPath = options.workPath;
@@ -4397,12 +4530,12 @@ var PythonDependencyExternalizer = class {
4397
4530
  this.totalBundleSize = await calculateBundleSize(tempFilesForSizing);
4398
4531
  this.analyzed = true;
4399
4532
  const totalBundleSizeMB = (this.totalBundleSize / (1024 * 1024)).toFixed(2);
4400
- (0, import_build_utils5.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
4533
+ (0, import_build_utils6.debug)(`Total bundle size: ${totalBundleSizeMB} MB`);
4401
4534
  const runtimeInstallEnabled = this.shouldEnableRuntimeInstall();
4402
4535
  const pythonOnHiveEnabled = process.env.VERCEL_PYTHON_ON_HIVE === "1" || process.env.VERCEL_PYTHON_ON_HIVE === "true";
4403
4536
  if (this.totalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES && this.hasCustomCommand && !pythonOnHiveEnabled) {
4404
4537
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
4405
- throw new import_build_utils5.NowBuildError({
4538
+ throw new import_build_utils6.NowBuildError({
4406
4539
  code: "LAMBDA_SIZE_EXCEEDED",
4407
4540
  message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the size limit (${limitMB} MB).
4408
4541
 
@@ -4420,7 +4553,7 @@ dependencies, you can:
4420
4553
  }
4421
4554
  if (pythonOnHiveEnabled && this.totalBundleSize > HIVE_LAMBDA_SIZE_BYTES) {
4422
4555
  const limitMB = (HIVE_LAMBDA_SIZE_BYTES / (1024 * 1024)).toFixed(0);
4423
- throw new import_build_utils5.NowBuildError({
4556
+ throw new import_build_utils6.NowBuildError({
4424
4557
  code: "LAMBDA_SIZE_EXCEEDED",
4425
4558
  message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the extended function size limit (${limitMB} MB).
4426
4559
 
@@ -4451,7 +4584,7 @@ application into smaller functions.`,
4451
4584
  );
4452
4585
  }
4453
4586
  if (!this.uvLockPath || !this.uvProjectDir) {
4454
- throw new import_build_utils5.NowBuildError({
4587
+ throw new import_build_utils6.NowBuildError({
4455
4588
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4456
4589
  message: "Runtime dependency installation requires a uv.lock file and project directory."
4457
4590
  });
@@ -4462,7 +4595,7 @@ application into smaller functions.`,
4462
4595
  );
4463
4596
  if (this.totalBundleSize > LAMBDA_EPHEMERAL_STORAGE_BYTES) {
4464
4597
  const ephemeralLimitMB = (LAMBDA_EPHEMERAL_STORAGE_BYTES / (1024 * 1024)).toFixed(0);
4465
- throw new import_build_utils5.NowBuildError({
4598
+ throw new import_build_utils6.NowBuildError({
4466
4599
  code: "LAMBDA_SIZE_EXCEEDED",
4467
4600
  message: shouldShowFunctionsBetaHint() ? `Total bundle size (${totalBundleSizeMB} MB) exceeds the ephemeral storage limit (${ephemeralLimitMB} MB).
4468
4601
 
@@ -4489,7 +4622,7 @@ your application into smaller functions.`,
4489
4622
  `Failed to read uv.lock file at "${this.uvLockPath}": ${String(error)}`
4490
4623
  );
4491
4624
  }
4492
- throw new import_build_utils5.NowBuildError({
4625
+ throw new import_build_utils6.NowBuildError({
4493
4626
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4494
4627
  message: `Failed to read uv.lock file at "${this.uvLockPath}"`
4495
4628
  });
@@ -4505,7 +4638,7 @@ your application into smaller functions.`,
4505
4638
  ${error.fileContent}`
4506
4639
  );
4507
4640
  }
4508
- throw new import_build_utils5.NowBuildError({
4641
+ throw new import_build_utils6.NowBuildError({
4509
4642
  code: error.code,
4510
4643
  message: error.message
4511
4644
  });
@@ -4515,7 +4648,7 @@ ${error.fileContent}`
4515
4648
  const excludePackages = [];
4516
4649
  if (this.projectName) {
4517
4650
  excludePackages.push(this.projectName);
4518
- (0, import_build_utils5.debug)(
4651
+ (0, import_build_utils6.debug)(
4519
4652
  `Excluding project package "${this.projectName}" from runtime installation`
4520
4653
  );
4521
4654
  }
@@ -4523,7 +4656,7 @@ ${error.fileContent}`
4523
4656
  lockFile,
4524
4657
  excludePackages
4525
4658
  });
4526
- (0, import_build_utils5.debug)(
4659
+ (0, import_build_utils6.debug)(
4527
4660
  `Package classification: ${classification.privatePackages.length} private, ${classification.publicPackages.length} public`
4528
4661
  );
4529
4662
  const forceBundledDueToWheels = await this.findPackagesWithoutCompatibleWheels(
@@ -4542,7 +4675,7 @@ ${error.fileContent}`
4542
4675
  (name) => !forceBundledSet.has((0, import_python_analysis3.normalizePackageName)(name))
4543
4676
  );
4544
4677
  if (externalizablePublic.length === 0) {
4545
- throw new import_build_utils5.NowBuildError({
4678
+ throw new import_build_utils6.NowBuildError({
4546
4679
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4547
4680
  message: `Bundle size exceeds the Lambda limit and requires runtime
4548
4681
  dependency installation, but no public packages have compatible
@@ -4575,14 +4708,12 @@ To fix this, either:
4575
4708
  }
4576
4709
  const fixedOverhead = await calculateBundleSize(baseFiles);
4577
4710
  let runtimeToolingOverhead = 0;
4578
- if (process.env.VERCEL_BUILD_IMAGE) {
4579
- try {
4580
- const uvBinaryPath = await getUvBinaryForBundling(this.pythonPath);
4581
- const uvStats = await import_fs5.default.promises.stat(uvBinaryPath);
4582
- runtimeToolingOverhead = uvStats.size;
4583
- } catch {
4584
- runtimeToolingOverhead = 50 * 1024 * 1024;
4585
- }
4711
+ try {
4712
+ const uvBinaryPath = await this.resolveUvBinaryForBundling();
4713
+ const uvStats = await import_fs5.default.promises.stat(uvBinaryPath);
4714
+ runtimeToolingOverhead = uvStats.size;
4715
+ } catch {
4716
+ runtimeToolingOverhead = 50 * 1024 * 1024;
4586
4717
  }
4587
4718
  runtimeToolingOverhead += 4 * 1024;
4588
4719
  const projectDirRel = (0, import_path6.relative)(this.workPath, this.uvProjectDir);
@@ -4598,7 +4729,7 @@ To fix this, either:
4598
4729
  runtimeToolingOverhead += uvLockStats.size;
4599
4730
  }
4600
4731
  const remainingCapacity = LAMBDA_SIZE_THRESHOLD_BYTES - fixedOverhead - runtimeToolingOverhead;
4601
- (0, import_build_utils5.debug)(
4732
+ (0, import_build_utils6.debug)(
4602
4733
  `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`
4603
4734
  );
4604
4735
  const externalizableSet = new Set(
@@ -4626,10 +4757,10 @@ To fix this, either:
4626
4757
  ];
4627
4758
  if (isOutsideWorkPath) {
4628
4759
  const srcPyproject = (0, import_path6.join)(this.uvProjectDir, "pyproject.toml");
4629
- files[`${UV_BUNDLE_DIR}/pyproject.toml`] = new import_build_utils5.FileFsRef({
4760
+ files[`${UV_BUNDLE_DIR}/pyproject.toml`] = new import_build_utils6.FileFsRef({
4630
4761
  fsPath: srcPyproject
4631
4762
  });
4632
- files[`${UV_BUNDLE_DIR}/uv.lock`] = new import_build_utils5.FileFsRef({
4763
+ files[`${UV_BUNDLE_DIR}/uv.lock`] = new import_build_utils6.FileFsRef({
4633
4764
  fsPath: this.uvLockPath
4634
4765
  });
4635
4766
  }
@@ -4637,36 +4768,33 @@ To fix this, either:
4637
4768
  projectDir: isOutsideWorkPath ? UV_BUNDLE_DIR : projectDirRel,
4638
4769
  bundledPackages: bundledPackagesForConfig
4639
4770
  });
4640
- files[`${UV_BUNDLE_DIR}/_runtime_config.json`] = new import_build_utils5.FileBlob({
4771
+ files[`${UV_BUNDLE_DIR}/_runtime_config.json`] = new import_build_utils6.FileBlob({
4641
4772
  data: runtimeConfigData
4642
4773
  });
4643
- if (process.env.VERCEL_BUILD_IMAGE) {
4644
- try {
4645
- const uvBinaryPath = await getUvBinaryForBundling(this.pythonPath);
4646
- const uvBundleDir = (0, import_path6.join)(this.workPath, UV_BUNDLE_DIR);
4647
- const uvLocalPath = (0, import_path6.join)(uvBundleDir, "uv");
4648
- await import_fs5.default.promises.mkdir(uvBundleDir, { recursive: true });
4649
- await import_fs5.default.promises.copyFile(uvBinaryPath, uvLocalPath);
4650
- await import_fs5.default.promises.chmod(uvLocalPath, 493);
4651
- const uvBundlePath = `${UV_BUNDLE_DIR}/uv`;
4652
- files[uvBundlePath] = new import_build_utils5.FileFsRef({
4653
- fsPath: uvLocalPath,
4654
- mode: 33261
4655
- // Regular file + executable
4656
- });
4657
- (0, import_build_utils5.debug)(`Bundled uv binary from ${uvBinaryPath} to ${uvLocalPath}`);
4658
- } catch (err) {
4659
- throw new import_build_utils5.NowBuildError({
4660
- code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4661
- message: `Failed to bundle uv binary for runtime installation: ${err instanceof Error ? err.message : String(err)}`
4662
- });
4663
- }
4774
+ try {
4775
+ const uvBinaryPath = await this.resolveUvBinaryForBundling();
4776
+ const uvBundleDir = (0, import_path6.join)(this.workPath, UV_BUNDLE_DIR);
4777
+ const uvLocalPath = (0, import_path6.join)(uvBundleDir, "uv");
4778
+ await import_fs5.default.promises.mkdir(uvBundleDir, { recursive: true });
4779
+ await import_fs5.default.promises.copyFile(uvBinaryPath, uvLocalPath);
4780
+ await import_fs5.default.promises.chmod(uvLocalPath, 493);
4781
+ const uvBundlePath = `${UV_BUNDLE_DIR}/uv`;
4782
+ files[uvBundlePath] = new import_build_utils6.FileFsRef({
4783
+ fsPath: uvLocalPath,
4784
+ mode: 33261
4785
+ });
4786
+ (0, import_build_utils6.debug)(`Bundled uv binary from ${uvBinaryPath} to ${uvLocalPath}`);
4787
+ } catch (err) {
4788
+ throw new import_build_utils6.NowBuildError({
4789
+ code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
4790
+ message: `Failed to bundle uv binary for runtime installation: ${err instanceof Error ? err.message : String(err)}`
4791
+ });
4664
4792
  }
4665
4793
  const finalBundleSize = await calculateBundleSize(files);
4666
4794
  if (finalBundleSize > LAMBDA_SIZE_THRESHOLD_BYTES + 100 * 1024) {
4667
4795
  const finalSizeMB = (finalBundleSize / (1024 * 1024)).toFixed(2);
4668
4796
  const limitMB = (LAMBDA_SIZE_THRESHOLD_BYTES / (1024 * 1024)).toFixed(0);
4669
- throw new import_build_utils5.NowBuildError({
4797
+ throw new import_build_utils6.NowBuildError({
4670
4798
  code: "LAMBDA_SIZE_EXCEEDED",
4671
4799
  message: shouldShowFunctionsBetaHint() ? `Total bundle size (${finalSizeMB} MB) exceeds the size limit (${limitMB} MB).
4672
4800
 
@@ -4692,9 +4820,9 @@ splitting your application.`,
4692
4820
  * irrelevant.
4693
4821
  */
4694
4822
  async findPackagesWithoutCompatibleWheels(lockFile, publicPackageNames) {
4695
- const platform = detectPlatform();
4823
+ const platform = detectTargetPlatform();
4696
4824
  if (this.pythonMajor === void 0 || this.pythonMinor === void 0) {
4697
- (0, import_build_utils5.debug)("Skipping wheel compatibility check: dev mode");
4825
+ (0, import_build_utils6.debug)("Skipping wheel compatibility check: dev mode");
4698
4826
  return [];
4699
4827
  }
4700
4828
  const reachable = await getPackagesReachableOnPlatform(
@@ -4709,7 +4837,7 @@ splitting your application.`,
4709
4837
  (name) => reachable.has((0, import_python_analysis3.normalizePackageName)(name))
4710
4838
  ) : publicPackageNames;
4711
4839
  if (relevantPackages.length < publicPackageNames.length) {
4712
- (0, import_build_utils5.debug)(
4840
+ (0, import_build_utils6.debug)(
4713
4841
  `Skipping wheel check for ${publicPackageNames.length - relevantPackages.length} package(s) not reachable on the target platform`
4714
4842
  );
4715
4843
  }
@@ -4749,7 +4877,7 @@ splitting your application.`,
4749
4877
  break;
4750
4878
  }
4751
4879
  } catch (err) {
4752
- (0, import_build_utils5.debug)(
4880
+ (0, import_build_utils6.debug)(
4753
4881
  `Failed to check wheel compatibility for ${filename}: ${err instanceof Error ? err.message : String(err)}`
4754
4882
  );
4755
4883
  }
@@ -4760,6 +4888,15 @@ splitting your application.`,
4760
4888
  }
4761
4889
  return incompatible;
4762
4890
  }
4891
+ /** Resolve the uv binary for bundling (host binary on build image, downloaded on local). */
4892
+ async resolveUvBinaryForBundling() {
4893
+ if (process.env.VERCEL_BUILD_IMAGE) {
4894
+ return getUvBinaryForBundling(this.pythonPath);
4895
+ }
4896
+ return downloadUvBinaryForTarget(
4897
+ (0, import_path6.join)(this.workPath, ".vercel", "python", "cache")
4898
+ );
4899
+ }
4763
4900
  /**
4764
4901
  * Mirror packages from site-packages into the _vendor directory.
4765
4902
  *
@@ -4829,13 +4966,13 @@ splitting your application.`,
4829
4966
  );
4830
4967
  for (const result of results) {
4831
4968
  if (result) {
4832
- vendorFiles[result.bundlePath] = new import_build_utils5.FileFsRef({
4969
+ vendorFiles[result.bundlePath] = new import_build_utils6.FileFsRef({
4833
4970
  fsPath: result.srcFsPath,
4834
4971
  size: result.size
4835
4972
  });
4836
4973
  }
4837
4974
  }
4838
- (0, import_build_utils5.debug)(
4975
+ (0, import_build_utils6.debug)(
4839
4976
  `Mirrored ${Object.keys(vendorFiles).length} files` + (includePackages ? ` from ${includePackages.length} packages` : "")
4840
4977
  );
4841
4978
  return vendorFiles;
@@ -4916,13 +5053,13 @@ async function getPackagesReachableOnPlatform(lockFile, projectName, pythonMajor
4916
5053
  platformMachine
4917
5054
  );
4918
5055
  if (!compatible) {
4919
- (0, import_build_utils5.debug)(
5056
+ (0, import_build_utils6.debug)(
4920
5057
  `Skipping dependency ${dep.name}: marker "${dep.marker}" not satisfied on ${sysPlatform}`
4921
5058
  );
4922
5059
  continue;
4923
5060
  }
4924
5061
  } catch (err) {
4925
- (0, import_build_utils5.debug)(
5062
+ (0, import_build_utils6.debug)(
4926
5063
  `Failed to evaluate marker "${dep.marker}" for ${dep.name}, including conservatively: ${err instanceof Error ? err.message : String(err)}`
4927
5064
  );
4928
5065
  }
@@ -4992,7 +5129,7 @@ function lambdaKnapsack(packages, capacity) {
4992
5129
 
4993
5130
  // src/diagnostics.ts
4994
5131
  var import_fs6 = __toESM(require("fs"));
4995
- var import_build_utils6 = require("@vercel/build-utils");
5132
+ var import_build_utils7 = require("@vercel/build-utils");
4996
5133
  var import_python_analysis4 = require("@vercel/python-analysis");
4997
5134
  function isDependencyGroupInclude(entry) {
4998
5135
  return typeof entry === "object" && "include-group" in entry;
@@ -5197,7 +5334,7 @@ async function generateProjectManifest({
5197
5334
  }
5198
5335
  }
5199
5336
  const manifest = {
5200
- version: import_build_utils6.MANIFEST_VERSION,
5337
+ version: import_build_utils7.MANIFEST_VERSION,
5201
5338
  runtime: "python",
5202
5339
  ...framework ? { framework } : {},
5203
5340
  ...serviceType ? { serviceType } : {},
@@ -5211,22 +5348,22 @@ async function generateProjectManifest({
5211
5348
  ...transitiveEntries.sort((a, b) => a.name.localeCompare(b.name))
5212
5349
  ]
5213
5350
  };
5214
- await (0, import_build_utils6.writeProjectManifest)(manifest, workPath, "python");
5351
+ await (0, import_build_utils7.writeProjectManifest)(manifest, workPath, "python");
5215
5352
  }
5216
- var diagnostics = (0, import_build_utils6.createDiagnostics)("python");
5353
+ var diagnostics = (0, import_build_utils7.createDiagnostics)("python");
5217
5354
 
5218
5355
  // src/crons.ts
5219
5356
  var import_fs8 = __toESM(require("fs"));
5220
5357
  var import_path8 = require("path");
5221
5358
  var import_execa4 = __toESM(require_execa());
5222
- var import_build_utils10 = require("@vercel/build-utils");
5359
+ var import_build_utils11 = require("@vercel/build-utils");
5223
5360
 
5224
5361
  // src/entrypoint.ts
5225
5362
  var import_fs7 = __toESM(require("fs"));
5226
5363
  var import_path7 = require("path");
5227
- var import_build_utils7 = require("@vercel/build-utils");
5228
5364
  var import_build_utils8 = require("@vercel/build-utils");
5229
5365
  var import_build_utils9 = require("@vercel/build-utils");
5366
+ var import_build_utils10 = require("@vercel/build-utils");
5230
5367
  var import_python_analysis5 = require("@vercel/python-analysis");
5231
5368
  var PYTHON_ENTRYPOINT_FILENAMES = [
5232
5369
  "app",
@@ -5380,7 +5517,7 @@ async function resolveModuleAttrEntrypoint(workPath, value) {
5380
5517
  return null;
5381
5518
  }
5382
5519
  async function getVercelToolsEntrypoint(workPath) {
5383
- const pyprojectData = await (0, import_build_utils9.readConfigFile)((0, import_path7.join)(workPath, "pyproject.toml"));
5520
+ const pyprojectData = await (0, import_build_utils10.readConfigFile)((0, import_path7.join)(workPath, "pyproject.toml"));
5384
5521
  if (!pyprojectData)
5385
5522
  return null;
5386
5523
  const vercelEntrypoint = pyprojectData.tool?.vercel?.entrypoint;
@@ -5389,7 +5526,7 @@ async function getVercelToolsEntrypoint(workPath) {
5389
5526
  return resolveModuleAttrEntrypoint(workPath, vercelEntrypoint);
5390
5527
  }
5391
5528
  async function getPyprojectEntrypointWithDiagnostics(workPath) {
5392
- const pyprojectData = await (0, import_build_utils9.readConfigFile)((0, import_path7.join)(workPath, "pyproject.toml"));
5529
+ const pyprojectData = await (0, import_build_utils10.readConfigFile)((0, import_path7.join)(workPath, "pyproject.toml"));
5393
5530
  if (!pyprojectData)
5394
5531
  return { entrypoint: null };
5395
5532
  const scripts = pyprojectData.project?.scripts;
@@ -5419,7 +5556,7 @@ async function findValidEntrypoint(workPath, candidates) {
5419
5556
  const content = await import_fs7.default.promises.readFile(absPath, "utf-8");
5420
5557
  const varName = await (0, import_python_analysis5.findAppOrHandler)(content);
5421
5558
  if (varName) {
5422
- (0, import_build_utils8.debug)(`Detected Python entrypoint: ${candidate} (variable: ${varName})`);
5559
+ (0, import_build_utils9.debug)(`Detected Python entrypoint: ${candidate} (variable: ${varName})`);
5423
5560
  return {
5424
5561
  entrypoint: { entrypoint: candidate, variableName: varName },
5425
5562
  existingWithoutEntrypoint
@@ -5435,7 +5572,7 @@ async function checkDjangoManage(workPath) {
5435
5572
  const content = await import_fs7.default.promises.readFile(managePath, "utf-8");
5436
5573
  if (!content.includes("DJANGO_SETTINGS_MODULE"))
5437
5574
  return false;
5438
- (0, import_build_utils8.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
5575
+ (0, import_build_utils9.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
5439
5576
  return true;
5440
5577
  } catch {
5441
5578
  return false;
@@ -5488,7 +5625,7 @@ ${suggestion}`;
5488
5625
  const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
5489
5626
  message = `No ${displayName} entrypoint found. Set "tool.vercel.entrypoint" in pyproject.toml or define an entrypoint in one of: ${searchedList}.`;
5490
5627
  }
5491
- return new import_build_utils7.NowBuildError({ code, message, link, action });
5628
+ return new import_build_utils8.NowBuildError({ code, message, link, action });
5492
5629
  }
5493
5630
  async function detectGenericPythonEntrypoint(workPath) {
5494
5631
  try {
@@ -5501,7 +5638,7 @@ async function detectGenericPythonEntrypoint(workPath) {
5501
5638
  findDiagnostics: result
5502
5639
  };
5503
5640
  } catch {
5504
- (0, import_build_utils8.debug)("Failed to discover Python entrypoint");
5641
+ (0, import_build_utils9.debug)("Failed to discover Python entrypoint");
5505
5642
  return {
5506
5643
  detected: null,
5507
5644
  findDiagnostics: { entrypoint: null, existingWithoutEntrypoint: [] }
@@ -5536,7 +5673,7 @@ async function detectDjangoPythonEntrypoint(workPath) {
5536
5673
  findDiagnostics: result
5537
5674
  };
5538
5675
  } catch {
5539
- (0, import_build_utils8.debug)("Failed to discover Django Python entrypoint");
5676
+ (0, import_build_utils9.debug)("Failed to discover Django Python entrypoint");
5540
5677
  return emptyResult;
5541
5678
  }
5542
5679
  }
@@ -5547,7 +5684,7 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint,
5547
5684
  const entrypointExists = await fileExists((0, import_path7.join)(workPath, entrypoint));
5548
5685
  if (!entrypointExists) {
5549
5686
  return {
5550
- error: new import_build_utils7.NowBuildError({
5687
+ error: new import_build_utils8.NowBuildError({
5551
5688
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
5552
5689
  message: `Configured Python entrypoint "${entrypoint}" was not found.`,
5553
5690
  link: PYTHON_ENTRYPOINT_DOCS_URL,
@@ -5557,17 +5694,17 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint,
5557
5694
  }
5558
5695
  let varName = configEntryVar ?? await checkEntrypoint(workPath, entrypoint);
5559
5696
  if (!varName) {
5560
- const needsDynamicApp = !!service && ((0, import_build_utils7.isScheduleTriggeredService)(service) || (0, import_build_utils7.isQueueTriggeredService)(service));
5697
+ const needsDynamicApp = !!service && ((0, import_build_utils8.isScheduleTriggeredService)(service) || (0, import_build_utils8.isQueueTriggeredService)(service) || (0, import_build_utils8.isWorkflowTriggeredService)(service));
5561
5698
  if (needsDynamicApp) {
5562
5699
  varName = "app";
5563
5700
  }
5564
5701
  }
5565
5702
  if (varName) {
5566
- (0, import_build_utils8.debug)(`Using configured Python entrypoint: ${entrypoint}`);
5703
+ (0, import_build_utils9.debug)(`Using configured Python entrypoint: ${entrypoint}`);
5567
5704
  return { entrypoint: { entrypoint, variableName: varName } };
5568
5705
  } else {
5569
5706
  return {
5570
- error: new import_build_utils7.NowBuildError({
5707
+ error: new import_build_utils8.NowBuildError({
5571
5708
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
5572
5709
  message: `Could not find a top-level "app", "application", or "handler" in "${entrypoint}".`,
5573
5710
  link: PYTHON_ENTRYPOINT_DOCS_URL,
@@ -5617,7 +5754,7 @@ var detectEntrypoint = async ({
5617
5754
  workPath,
5618
5755
  framework
5619
5756
  }) => {
5620
- if (!(0, import_build_utils7.isPythonFramework)(framework))
5757
+ if (!(0, import_build_utils8.isPythonFramework)(framework))
5621
5758
  return null;
5622
5759
  const detected = await detectPythonEntrypoint(
5623
5760
  framework,
@@ -5645,13 +5782,13 @@ function buildCronRouteTable(crons) {
5645
5782
  }
5646
5783
  async function getServiceCrons(opts) {
5647
5784
  const { service, entrypoint, rawEntrypoint, handlerFunction } = opts;
5648
- const isScheduledService = !!service && (0, import_build_utils10.isScheduleTriggeredService)(service);
5785
+ const isScheduledService = !!service && (0, import_build_utils11.isScheduleTriggeredService)(service);
5649
5786
  if (!isScheduledService || !service.name || typeof service.schedule !== "string" && !Array.isArray(service.schedule)) {
5650
5787
  return void 0;
5651
5788
  }
5652
5789
  const cronEntrypoint = entrypoint || rawEntrypoint;
5653
5790
  if (!cronEntrypoint) {
5654
- throw new import_build_utils10.NowBuildError({
5791
+ throw new import_build_utils11.NowBuildError({
5655
5792
  code: "PYTHON_CRON_NO_ENTRYPOINT",
5656
5793
  message: "Cron service is missing an entrypoint."
5657
5794
  });
@@ -5666,7 +5803,7 @@ async function getServiceCrons(opts) {
5666
5803
  workPath: opts.workPath
5667
5804
  });
5668
5805
  }
5669
- const cronPath = (0, import_build_utils10.getInternalServiceCronPath)(
5806
+ const cronPath = (0, import_build_utils11.getInternalServiceCronPath)(
5670
5807
  service.name,
5671
5808
  cronEntrypoint,
5672
5809
  handlerFunction || "cron"
@@ -5690,7 +5827,7 @@ async function getServiceCronsDynamic(opts) {
5690
5827
  workPath
5691
5828
  } = opts;
5692
5829
  if (!handlerFunction) {
5693
- throw new import_build_utils10.NowBuildError({
5830
+ throw new import_build_utils11.NowBuildError({
5694
5831
  code: "PYTHON_DYNAMIC_CRON_NO_HANDLER",
5695
5832
  message: 'Dynamic cron detection requires a "module:object" entrypoint where the object has a get_crons() method.'
5696
5833
  });
@@ -5707,7 +5844,7 @@ async function getServiceCronsDynamic(opts) {
5707
5844
  `Detected ${entries.length} cron entry(s): ${entries.map((e) => `${e.module_function} (${e.schedule})`).join(", ")}`
5708
5845
  );
5709
5846
  if (entries.length === 0) {
5710
- throw new import_build_utils10.NowBuildError({
5847
+ throw new import_build_utils11.NowBuildError({
5711
5848
  code: "PYTHON_DYNAMIC_CRON_EMPTY",
5712
5849
  message: `Dynamic cron detection returned no entries. "${moduleName}.${handlerFunction}.get_crons()" returned an empty iterable.`
5713
5850
  });
@@ -5742,7 +5879,7 @@ async function detectDynamicCrons(opts) {
5742
5879
  detail = parsed2.error;
5743
5880
  } catch {
5744
5881
  }
5745
- throw new import_build_utils10.NowBuildError({
5882
+ throw new import_build_utils11.NowBuildError({
5746
5883
  code: "PYTHON_DYNAMIC_CRON_DETECTION_FAILED",
5747
5884
  message: `Failed to detect dynamic cron entries: ${detail}`
5748
5885
  });
@@ -5751,7 +5888,7 @@ async function detectDynamicCrons(opts) {
5751
5888
  try {
5752
5889
  parsed = JSON.parse(stdout);
5753
5890
  } catch {
5754
- throw new import_build_utils10.NowBuildError({
5891
+ throw new import_build_utils11.NowBuildError({
5755
5892
  code: "PYTHON_DYNAMIC_CRON_DETECTION_FAILED",
5756
5893
  message: `Dynamic cron detection returned invalid JSON: ${stdout}`
5757
5894
  });
@@ -5761,7 +5898,7 @@ async function detectDynamicCrons(opts) {
5761
5898
  function moduleColonFuncToCronPath(serviceName, moduleFunction) {
5762
5899
  const colonIdx = moduleFunction.indexOf(":");
5763
5900
  if (colonIdx === -1) {
5764
- throw new import_build_utils10.NowBuildError({
5901
+ throw new import_build_utils11.NowBuildError({
5765
5902
  code: "PYTHON_DYNAMIC_CRON_INVALID_FORMAT",
5766
5903
  message: `Dynamic cron entry must use "module:function" format, got: "${moduleFunction}"`
5767
5904
  });
@@ -5769,14 +5906,14 @@ function moduleColonFuncToCronPath(serviceName, moduleFunction) {
5769
5906
  const modulePart = moduleFunction.slice(0, colonIdx);
5770
5907
  const funcPart = moduleFunction.slice(colonIdx + 1);
5771
5908
  const entrypointPath = modulePart.replace(/\./g, "/");
5772
- return (0, import_build_utils10.getInternalServiceCronPath)(serviceName, entrypointPath, funcPart);
5909
+ return (0, import_build_utils11.getInternalServiceCronPath)(serviceName, entrypointPath, funcPart);
5773
5910
  }
5774
5911
 
5775
5912
  // src/start-dev-server.ts
5776
5913
  var import_child_process2 = require("child_process");
5777
5914
  var import_fs9 = require("fs");
5778
5915
  var import_path9 = require("path");
5779
- var import_build_utils11 = require("@vercel/build-utils");
5916
+ var import_build_utils12 = require("@vercel/build-utils");
5780
5917
  var import_get_port = __toESM(require_get_port());
5781
5918
  var import_is_port_reachable = __toESM(require_is_port_reachable());
5782
5919
  var import_python_analysis6 = require("@vercel/python-analysis");
@@ -5865,7 +6002,7 @@ async function syncDependencies({
5865
6002
  let { manifestPath } = installInfo;
5866
6003
  const manifest = pythonPackage.manifest;
5867
6004
  if (!manifestType || !manifestPath) {
5868
- (0, import_build_utils11.debug)("No Python project manifest found, skipping dependency sync");
6005
+ (0, import_build_utils12.debug)("No Python project manifest found, skipping dependency sync");
5869
6006
  return;
5870
6007
  }
5871
6008
  if (manifest?.origin && manifestType === "pyproject.toml") {
@@ -5875,7 +6012,7 @@ async function syncDependencies({
5875
6012
  const content = (0, import_python_analysis6.stringifyManifest)(manifest.data);
5876
6013
  (0, import_fs9.writeFileSync)(tempPyproject, content, "utf8");
5877
6014
  manifestPath = tempPyproject;
5878
- (0, import_build_utils11.debug)(
6015
+ (0, import_build_utils12.debug)(
5879
6016
  `Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
5880
6017
  );
5881
6018
  }
@@ -5908,7 +6045,7 @@ async function syncDependencies({
5908
6045
  for (const [channel, chunk] of captured) {
5909
6046
  (channel === "stdout" ? writeOut : writeErr)(chunk.toString());
5910
6047
  }
5911
- throw new import_build_utils11.NowBuildError({
6048
+ throw new import_build_utils12.NowBuildError({
5912
6049
  code: "PYTHON_DEPENDENCY_SYNC_FAILED",
5913
6050
  message: `Failed to install Python dependencies from ${manifestType}: ${err instanceof Error ? err.message : String(err)}`
5914
6051
  });
@@ -5930,7 +6067,7 @@ async function runSync({
5930
6067
  switch (manifestType) {
5931
6068
  case "uv.lock": {
5932
6069
  if (!uvPath) {
5933
- throw new import_build_utils11.NowBuildError({
6070
+ throw new import_build_utils12.NowBuildError({
5934
6071
  code: "PYTHON_DEPENDENCY_SYNC_FAILED",
5935
6072
  message: "uv is required to install dependencies from uv.lock.",
5936
6073
  link: "https://docs.astral.sh/uv/getting-started/installation/",
@@ -5952,11 +6089,11 @@ async function runSync({
5952
6089
  break;
5953
6090
  }
5954
6091
  default:
5955
- (0, import_build_utils11.debug)(`Unknown manifest type: ${manifestType}`);
6092
+ (0, import_build_utils12.debug)(`Unknown manifest type: ${manifestType}`);
5956
6093
  return;
5957
6094
  }
5958
6095
  await new Promise((resolve3, reject) => {
5959
- (0, import_build_utils11.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
6096
+ (0, import_build_utils12.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
5960
6097
  const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
5961
6098
  cwd: projectDir,
5962
6099
  env: getProtectedUvEnv(env),
@@ -6043,13 +6180,13 @@ async function doInstallVercelRuntime({
6043
6180
  `vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
6044
6181
  );
6045
6182
  if ((0, import_fs9.existsSync)(distInfo)) {
6046
- (0, import_build_utils11.debug)(
6183
+ (0, import_build_utils12.debug)(
6047
6184
  `vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
6048
6185
  );
6049
6186
  return;
6050
6187
  }
6051
6188
  }
6052
- (0, import_build_utils11.debug)(
6189
+ (0, import_build_utils12.debug)(
6053
6190
  `Installing vercel-runtime into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${runtimeDep})`
6054
6191
  );
6055
6192
  const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
@@ -6064,14 +6201,14 @@ async function doInstallVercelRuntime({
6064
6201
  if (onStdout) {
6065
6202
  onStdout(data);
6066
6203
  } else {
6067
- (0, import_build_utils11.debug)(data.toString());
6204
+ (0, import_build_utils12.debug)(data.toString());
6068
6205
  }
6069
6206
  });
6070
6207
  child.stderr?.on("data", (data) => {
6071
6208
  if (onStderr) {
6072
6209
  onStderr(data);
6073
6210
  } else {
6074
- (0, import_build_utils11.debug)(data.toString());
6211
+ (0, import_build_utils12.debug)(data.toString());
6075
6212
  }
6076
6213
  });
6077
6214
  child.on("error", reject);
@@ -6139,13 +6276,13 @@ async function doInstallVercelWorkers({
6139
6276
  `vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
6140
6277
  );
6141
6278
  if ((0, import_fs9.existsSync)(distInfo)) {
6142
- (0, import_build_utils11.debug)(
6279
+ (0, import_build_utils12.debug)(
6143
6280
  `vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
6144
6281
  );
6145
6282
  return;
6146
6283
  }
6147
6284
  }
6148
- (0, import_build_utils11.debug)(
6285
+ (0, import_build_utils12.debug)(
6149
6286
  `Installing vercel-workers into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${workersDep})`
6150
6287
  );
6151
6288
  const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
@@ -6160,14 +6297,14 @@ async function doInstallVercelWorkers({
6160
6297
  if (onStdout) {
6161
6298
  onStdout(data);
6162
6299
  } else {
6163
- (0, import_build_utils11.debug)(data.toString());
6300
+ (0, import_build_utils12.debug)(data.toString());
6164
6301
  }
6165
6302
  });
6166
6303
  child.stderr?.on("data", (data) => {
6167
6304
  if (onStderr) {
6168
6305
  onStderr(data);
6169
6306
  } else {
6170
- (0, import_build_utils11.debug)(data.toString());
6307
+ (0, import_build_utils12.debug)(data.toString());
6171
6308
  }
6172
6309
  });
6173
6310
  child.on("error", reject);
@@ -6197,12 +6334,12 @@ function installGlobalCleanupHandlers() {
6197
6334
  try {
6198
6335
  process.kill(info.pid, "SIGTERM");
6199
6336
  } catch (err) {
6200
- (0, import_build_utils11.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
6337
+ (0, import_build_utils12.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
6201
6338
  }
6202
6339
  try {
6203
6340
  process.kill(info.pid, "SIGKILL");
6204
6341
  } catch (err) {
6205
- (0, import_build_utils11.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
6342
+ (0, import_build_utils12.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
6206
6343
  }
6207
6344
  PERSISTENT_SERVERS.delete(key);
6208
6345
  }
@@ -6210,7 +6347,7 @@ function installGlobalCleanupHandlers() {
6210
6347
  try {
6211
6348
  restoreWarnings();
6212
6349
  } catch (err) {
6213
- (0, import_build_utils11.debug)(`Error restoring warnings: ${err}`);
6350
+ (0, import_build_utils12.debug)(`Error restoring warnings: ${err}`);
6214
6351
  }
6215
6352
  restoreWarnings = null;
6216
6353
  }
@@ -6247,21 +6384,21 @@ function createDevShim(workPath, entry, modulePath, serviceName, framework, vari
6247
6384
  const template = (0, import_fs9.readFileSync)(templatePath, "utf8");
6248
6385
  const shimSource = template.replace(/__VC_DEV_MODULE_NAME__/g, qualifiedModule).replace(/__VC_DEV_ENTRY_ABS__/g, entryAbs).replace(/__VC_DEV_FRAMEWORK__/g, framework).replace(/__VC_DEV_VARIABLE_NAME__/g, variableName);
6249
6386
  (0, import_fs9.writeFileSync)(shimPath, shimSource, "utf8");
6250
- (0, import_build_utils11.debug)(`Prepared Python dev shim at ${shimPath}`);
6387
+ (0, import_build_utils12.debug)(`Prepared Python dev shim at ${shimPath}`);
6251
6388
  return {
6252
6389
  module: DEV_SHIM_MODULE,
6253
6390
  extraPythonPath,
6254
6391
  shimDir: vercelPythonDir
6255
6392
  };
6256
6393
  } catch (err) {
6257
- (0, import_build_utils11.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
6394
+ (0, import_build_utils12.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
6258
6395
  return null;
6259
6396
  }
6260
6397
  }
6261
6398
  async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath) {
6262
6399
  const { pythonCmd, venvRoot } = useVirtualEnv(workPath, env, systemPython);
6263
6400
  if (venvRoot) {
6264
- (0, import_build_utils11.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
6401
+ (0, import_build_utils12.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
6265
6402
  return { command: pythonCmd, args: [] };
6266
6403
  }
6267
6404
  const venvPath = (0, import_path9.join)(workPath, ".venv");
@@ -6271,7 +6408,7 @@ async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath)
6271
6408
  uvPath,
6272
6409
  quiet: true
6273
6410
  });
6274
- (0, import_build_utils11.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
6411
+ (0, import_build_utils12.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
6275
6412
  const pythonBin = getVenvPythonBin(venvPath);
6276
6413
  const binDir = getVenvBinDir(venvPath);
6277
6414
  env.VIRTUAL_ENV = venvPath;
@@ -6329,7 +6466,7 @@ var startDevServer = async (opts) => {
6329
6466
  filePath: entrypoint,
6330
6467
  // Schedule-triggered services create their own "app" wrapper dynamically.
6331
6468
  // Other services use handlerFunction as the entrypoint variable name.
6332
- varName: service && (0, import_build_utils11.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
6469
+ varName: service && (0, import_build_utils12.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
6333
6470
  } : void 0,
6334
6471
  service
6335
6472
  );
@@ -6349,7 +6486,7 @@ var startDevServer = async (opts) => {
6349
6486
  if (detected?.error) {
6350
6487
  throw detected.error;
6351
6488
  }
6352
- throw new import_build_utils11.NowBuildError({
6489
+ throw new import_build_utils12.NowBuildError({
6353
6490
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
6354
6491
  message: "No Python entrypoint could be detected. Please specify an entrypoint file."
6355
6492
  });
@@ -6378,7 +6515,7 @@ var startDevServer = async (opts) => {
6378
6515
  const yellow = "\x1B[33m";
6379
6516
  const white = "\x1B[1m";
6380
6517
  const reset = "\x1B[0m";
6381
- throw new import_build_utils11.NowBuildError({
6518
+ throw new import_build_utils12.NowBuildError({
6382
6519
  code: "PYTHON_EXTERNAL_VENV_DETECTED",
6383
6520
  message: `Detected activated venv at ${yellow}${venv}${reset}, ${white}vercel dev${reset} manages virtual environments automatically.
6384
6521
  Run ${white}deactivate${reset} and try again.`
@@ -6395,11 +6532,11 @@ Run ${white}deactivate${reset} and try again.`
6395
6532
  );
6396
6533
  spawnCommand = runner.command;
6397
6534
  spawnArgsPrefix = runner.args;
6398
- (0, import_build_utils11.debug)(
6535
+ (0, import_build_utils12.debug)(
6399
6536
  `Multi-service Python runner: ${spawnCommand} ${spawnArgsPrefix.join(" ")}`
6400
6537
  );
6401
6538
  } else if (venv) {
6402
- (0, import_build_utils11.debug)(`Running in virtualenv at ${venv}`);
6539
+ (0, import_build_utils12.debug)(`Running in virtualenv at ${venv}`);
6403
6540
  } else {
6404
6541
  const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
6405
6542
  workPath,
@@ -6408,9 +6545,9 @@ Run ${white}deactivate${reset} and try again.`
6408
6545
  );
6409
6546
  spawnCommand = venvPythonCmd;
6410
6547
  if (venvRoot) {
6411
- (0, import_build_utils11.debug)(`Using virtualenv at ${venvRoot}`);
6548
+ (0, import_build_utils12.debug)(`Using virtualenv at ${venvRoot}`);
6412
6549
  } else {
6413
- (0, import_build_utils11.debug)("No virtualenv found");
6550
+ (0, import_build_utils12.debug)("No virtualenv found");
6414
6551
  try {
6415
6552
  const yellow = "\x1B[33m";
6416
6553
  const reset = "\x1B[0m";
@@ -6500,7 +6637,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
6500
6637
  const moduleToRun = devShim?.module || modulePath;
6501
6638
  const pythonArgs = ["-u", "-m", moduleToRun];
6502
6639
  const argv = [...spawnArgsPrefix, ...pythonArgs];
6503
- (0, import_build_utils11.debug)(
6640
+ (0, import_build_utils12.debug)(
6504
6641
  `Starting Python dev server (${framework}): ${spawnCommand} ${argv.join(" ")} [PORT=${port}]`
6505
6642
  );
6506
6643
  if (process.stdout.columns) {
@@ -6554,7 +6691,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
6554
6691
  };
6555
6692
 
6556
6693
  // src/quirks/index.ts
6557
- var import_build_utils14 = require("@vercel/build-utils");
6694
+ var import_build_utils15 = require("@vercel/build-utils");
6558
6695
  var import_python_analysis8 = require("@vercel/python-analysis");
6559
6696
 
6560
6697
  // src/quirks/matplotlib.ts
@@ -6570,7 +6707,7 @@ var matplotlibQuirk = {
6570
6707
  // src/quirks/litellm.ts
6571
6708
  var import_fs10 = __toESM(require("fs"));
6572
6709
  var import_path10 = require("path");
6573
- var import_build_utils12 = require("@vercel/build-utils");
6710
+ var import_build_utils13 = require("@vercel/build-utils");
6574
6711
  var LAMBDA_ROOT = "/var/task";
6575
6712
  var CONFIG_CANDIDATES = [
6576
6713
  "litellm_config.yaml",
@@ -6605,24 +6742,24 @@ var litellmQuirk = {
6605
6742
  );
6606
6743
  try {
6607
6744
  await import_fs10.default.promises.access(schemaPath);
6608
- (0, import_build_utils12.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
6745
+ (0, import_build_utils13.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
6609
6746
  buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
6610
6747
  break;
6611
6748
  } catch {
6612
6749
  }
6613
6750
  }
6614
6751
  if (!buildEnv.PRISMA_SCHEMA_PATH) {
6615
- (0, import_build_utils12.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
6752
+ (0, import_build_utils13.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
6616
6753
  }
6617
6754
  if (!process.env.CONFIG_FILE_PATH) {
6618
6755
  const configName = await findConfigFile(ctx.workPath);
6619
6756
  if (configName) {
6620
- (0, import_build_utils12.debug)(`LiteLLM quirk: found config at ${configName}`);
6757
+ (0, import_build_utils13.debug)(`LiteLLM quirk: found config at ${configName}`);
6621
6758
  buildEnv.CONFIG_FILE_PATH = (0, import_path10.join)(ctx.workPath, configName);
6622
6759
  env.CONFIG_FILE_PATH = (0, import_path10.join)(LAMBDA_ROOT, configName);
6623
6760
  }
6624
6761
  } else {
6625
- (0, import_build_utils12.debug)(
6762
+ (0, import_build_utils13.debug)(
6626
6763
  `LiteLLM quirk: CONFIG_FILE_PATH already set to ${process.env.CONFIG_FILE_PATH}`
6627
6764
  );
6628
6765
  }
@@ -6634,7 +6771,7 @@ var litellmQuirk = {
6634
6771
  var import_fs11 = __toESM(require("fs"));
6635
6772
  var import_path11 = require("path");
6636
6773
  var import_execa5 = __toESM(require_execa());
6637
- var import_build_utils13 = require("@vercel/build-utils");
6774
+ var import_build_utils14 = require("@vercel/build-utils");
6638
6775
  var import_python_analysis7 = require("@vercel/python-analysis");
6639
6776
  function execErrorMessage(err) {
6640
6777
  if (err != null && typeof err === "object" && "stderr" in err) {
@@ -6648,7 +6785,7 @@ var DUMMY_SCHEMA_NAME = "_prisma_dummy.prisma";
6648
6785
  var LAMBDA_ROOT2 = "/var/task";
6649
6786
  var RUNTIME_OPENSSL_VERSION = "3.2";
6650
6787
  function getLambdaBinaryTarget() {
6651
- const platform = detectPlatform();
6788
+ const platform = detectTargetPlatform();
6652
6789
  return platform.archName === "aarch64" ? "linux-arm64-openssl-3.0.x" : "rhel-openssl-3.0.x";
6653
6790
  }
6654
6791
  function buildDummySchema(generatedDir) {
@@ -6677,7 +6814,7 @@ async function findUserSchema(workPath) {
6677
6814
  await import_fs11.default.promises.access(resolved);
6678
6815
  return resolved;
6679
6816
  } catch {
6680
- (0, import_build_utils13.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
6817
+ (0, import_build_utils14.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
6681
6818
  return null;
6682
6819
  }
6683
6820
  }
@@ -6781,7 +6918,7 @@ var prismaQuirk = {
6781
6918
  dummySchemaPath,
6782
6919
  buildDummySchema(generatedDir)
6783
6920
  );
6784
- (0, import_build_utils13.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
6921
+ (0, import_build_utils14.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
6785
6922
  try {
6786
6923
  const dummyResult = await (0, import_execa5.default)(
6787
6924
  pythonPath,
@@ -6793,11 +6930,11 @@ var prismaQuirk = {
6793
6930
  }
6794
6931
  );
6795
6932
  if (dummyResult.stdout)
6796
- (0, import_build_utils13.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
6933
+ (0, import_build_utils14.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
6797
6934
  if (dummyResult.stderr)
6798
- (0, import_build_utils13.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
6935
+ (0, import_build_utils14.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
6799
6936
  } catch (err) {
6800
- throw new import_build_utils13.NowBuildError({
6937
+ throw new import_build_utils14.NowBuildError({
6801
6938
  code: "PRISMA_GENERATE_FAILED",
6802
6939
  message: `Prisma engine download failed during \`prisma generate\`. Check that your prisma version is compatible with this Python version.
6803
6940
  ` + execErrorMessage(err)
@@ -6816,22 +6953,22 @@ var prismaQuirk = {
6816
6953
  const destPath = (0, import_path11.join)(cacheDir, runtimeName);
6817
6954
  try {
6818
6955
  await import_fs11.default.promises.access(destPath);
6819
- (0, import_build_utils13.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
6956
+ (0, import_build_utils14.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
6820
6957
  } catch {
6821
- (0, import_build_utils13.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
6958
+ (0, import_build_utils14.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
6822
6959
  await import_fs11.default.promises.copyFile(srcPath, destPath);
6823
6960
  }
6824
6961
  engineCopied = true;
6825
6962
  }
6826
6963
  } catch (err) {
6827
- throw new import_build_utils13.NowBuildError({
6964
+ throw new import_build_utils14.NowBuildError({
6828
6965
  code: "PRISMA_ENGINE_NOT_FOUND",
6829
6966
  message: `could not read Prisma engine directory "${nodeModulesDir}". This may indicate an incompatible prisma version.
6830
6967
  ` + (err instanceof Error ? err.message : String(err))
6831
6968
  });
6832
6969
  }
6833
6970
  if (!engineCopied) {
6834
- throw new import_build_utils13.NowBuildError({
6971
+ throw new import_build_utils14.NowBuildError({
6835
6972
  code: "PRISMA_ENGINE_NOT_FOUND",
6836
6973
  message: `could not find engine binary matching "${srcBinaryPrefix}*" in "${nodeModulesDir}". This may indicate an incompatible prisma version or an unsupported platform (${process.arch}).`
6837
6974
  });
@@ -6858,14 +6995,14 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
6858
6995
  pythonEnv
6859
6996
  );
6860
6997
  if (clientAlreadyGenerated) {
6861
- (0, import_build_utils13.debug)(
6998
+ (0, import_build_utils14.debug)(
6862
6999
  "Prisma quirk: client already generated, skipping user schema generate"
6863
7000
  );
6864
7001
  shouldGenerate = false;
6865
7002
  }
6866
7003
  }
6867
7004
  if (shouldGenerate) {
6868
- (0, import_build_utils13.debug)(`Running prisma generate with user schema: ${userSchema}`);
7005
+ (0, import_build_utils14.debug)(`Running prisma generate with user schema: ${userSchema}`);
6869
7006
  try {
6870
7007
  const userResult = await (0, import_execa5.default)(
6871
7008
  pythonPath,
@@ -6877,11 +7014,11 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
6877
7014
  }
6878
7015
  );
6879
7016
  if (userResult.stdout)
6880
- (0, import_build_utils13.debug)(`prisma generate stdout: ${userResult.stdout}`);
7017
+ (0, import_build_utils14.debug)(`prisma generate stdout: ${userResult.stdout}`);
6881
7018
  if (userResult.stderr)
6882
- (0, import_build_utils13.debug)(`prisma generate stderr: ${userResult.stderr}`);
7019
+ (0, import_build_utils14.debug)(`prisma generate stderr: ${userResult.stderr}`);
6883
7020
  } catch (err) {
6884
- throw new import_build_utils13.NowBuildError({
7021
+ throw new import_build_utils14.NowBuildError({
6885
7022
  code: "PRISMA_GENERATE_FAILED",
6886
7023
  message: `\`prisma generate\` failed for schema "${userSchema}".
6887
7024
  ` + execErrorMessage(err)
@@ -6897,7 +7034,7 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
6897
7034
  );
6898
7035
  const count = await (0, import_python_analysis7.extendDistRecord)(sitePackages, "prisma", allFiles);
6899
7036
  if (count > 0) {
6900
- (0, import_build_utils13.debug)(`Appended ${count} entries to prisma RECORD`);
7037
+ (0, import_build_utils14.debug)(`Appended ${count} entries to prisma RECORD`);
6901
7038
  }
6902
7039
  } catch (err) {
6903
7040
  console.warn(
@@ -6991,13 +7128,13 @@ async function runQuirks(ctx) {
6991
7128
  (0, import_python_analysis8.normalizePackageName)(quirk.dependency)
6992
7129
  );
6993
7130
  if (!installed) {
6994
- (0, import_build_utils14.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
7131
+ (0, import_build_utils15.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
6995
7132
  }
6996
7133
  return installed;
6997
7134
  });
6998
7135
  const sorted = toposortQuirks(activated);
6999
7136
  for (const quirk of sorted) {
7000
- (0, import_build_utils14.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
7137
+ (0, import_build_utils15.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
7001
7138
  const result = await quirk.run(ctx);
7002
7139
  if (result.env) {
7003
7140
  Object.assign(mergedEnv, result.env);
@@ -7021,7 +7158,7 @@ async function runQuirks(ctx) {
7021
7158
  var import_fs12 = __toESM(require("fs"));
7022
7159
  var import_path12 = require("path");
7023
7160
  var import_execa6 = __toESM(require_execa());
7024
- var import_build_utils15 = require("@vercel/build-utils");
7161
+ var import_build_utils16 = require("@vercel/build-utils");
7025
7162
  var scriptPath2 = (0, import_path12.join)(__dirname, "..", "templates", "vc_django_settings.py");
7026
7163
  var script2 = import_fs12.default.readFileSync(scriptPath2, "utf-8");
7027
7164
  async function getDjangoSettings(projectDir, env) {
@@ -7113,7 +7250,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
7113
7250
  await import_fs12.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
7114
7251
  await import_fs12.default.promises.copyFile(manifestSrc, manifestDest);
7115
7252
  manifestRelPath = (0, import_path12.relative)(workPath, manifestDest);
7116
- (0, import_build_utils15.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
7253
+ (0, import_build_utils16.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
7117
7254
  }
7118
7255
  return {
7119
7256
  staticSourceDirs,
@@ -7141,7 +7278,7 @@ var frameworkHooks = {
7141
7278
  detected
7142
7279
  }) => {
7143
7280
  if (detected?.baseDir === void 0) {
7144
- (0, import_build_utils16.debug)("Django hook: no manage.py detected, skipping");
7281
+ (0, import_build_utils17.debug)("Django hook: no manage.py detected, skipping");
7145
7282
  return;
7146
7283
  }
7147
7284
  let settingsResult;
@@ -7155,13 +7292,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
7155
7292
  } else {
7156
7293
  detail = err?.stderr || err?.message || String(err);
7157
7294
  }
7158
- throw new import_build_utils16.NowBuildError({
7295
+ throw new import_build_utils17.NowBuildError({
7159
7296
  code: "DJANGO_SETTINGS_FAILED",
7160
7297
  message: `Failed to read Django application settings from ${projectDir}/manage.py:
7161
7298
  ${detail}`
7162
7299
  });
7163
7300
  }
7164
- (0, import_build_utils16.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
7301
+ (0, import_build_utils17.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
7165
7302
  const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
7166
7303
  if (djangoVersion) {
7167
7304
  console.log(`Django ${djangoVersion.join(".")} detected`);
@@ -7174,7 +7311,7 @@ ${detail}`
7174
7311
  const variableName = parts.at(-1);
7175
7312
  const rel = `${parts.slice(0, -1).join("/")}.py`;
7176
7313
  const ep = baseDir ? `${baseDir}/${rel}` : rel;
7177
- (0, import_build_utils16.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
7314
+ (0, import_build_utils17.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
7178
7315
  resolvedEntrypoint = { entrypoint: ep, variableName };
7179
7316
  } else {
7180
7317
  const wsgiApp = djangoSettings["WSGI_APPLICATION"];
@@ -7183,7 +7320,7 @@ ${detail}`
7183
7320
  const variableName = parts.at(-1);
7184
7321
  const rel = `${parts.slice(0, -1).join("/")}.py`;
7185
7322
  const ep = baseDir ? `${baseDir}/${rel}` : rel;
7186
- (0, import_build_utils16.debug)(
7323
+ (0, import_build_utils17.debug)(
7187
7324
  `Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
7188
7325
  );
7189
7326
  resolvedEntrypoint = { entrypoint: ep, variableName };
@@ -7211,12 +7348,12 @@ async function downloadFilesInWorkPath({
7211
7348
  files,
7212
7349
  meta = {}
7213
7350
  }) {
7214
- (0, import_build_utils16.debug)("Downloading user files...");
7215
- let downloadedFiles = await (0, import_build_utils16.download)(files, workPath, meta);
7351
+ (0, import_build_utils17.debug)("Downloading user files...");
7352
+ let downloadedFiles = await (0, import_build_utils17.download)(files, workPath, meta);
7216
7353
  if (meta.isDev && entrypoint) {
7217
7354
  const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
7218
7355
  if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
7219
- throw new import_build_utils16.NowBuildError({
7356
+ throw new import_build_utils17.NowBuildError({
7220
7357
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
7221
7358
  message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
7222
7359
  link: PYTHON_ENTRYPOINT_DOCS_URL2,
@@ -7226,12 +7363,31 @@ async function downloadFilesInWorkPath({
7226
7363
  const { devCacheDir = (0, import_path13.join)(workPath, ".now", "cache") } = meta;
7227
7364
  const cacheKey = (0, import_path13.basename)(entrypoint).replace(/\./g, "_");
7228
7365
  const destCache = (0, import_path13.join)(devCacheDir, cacheKey);
7229
- await (0, import_build_utils16.download)(downloadedFiles, destCache);
7230
- downloadedFiles = await (0, import_build_utils16.glob)("**", destCache);
7366
+ await (0, import_build_utils17.download)(downloadedFiles, destCache);
7367
+ downloadedFiles = await (0, import_build_utils17.glob)("**", destCache);
7231
7368
  workPath = destCache;
7232
7369
  }
7233
7370
  return workPath;
7234
7371
  }
7372
+ function archToUvPlatform(arch) {
7373
+ return `${validateBuildArch(arch)}-unknown-linux-gnu`;
7374
+ }
7375
+ function archToLambdaArch(arch) {
7376
+ return validateBuildArch(arch) === "aarch64" ? "arm64" : "x86_64";
7377
+ }
7378
+ function getTargetPlatform(isDev) {
7379
+ const arch = process.env.VERCEL_BUILD_ARCH;
7380
+ if (arch) {
7381
+ return {
7382
+ uvPlatform: archToUvPlatform(arch),
7383
+ architecture: archToLambdaArch(arch)
7384
+ };
7385
+ }
7386
+ if (isDev || process.env.VERCEL_BUILD_IMAGE) {
7387
+ return { uvPlatform: void 0, architecture: void 0 };
7388
+ }
7389
+ return { uvPlatform: UV_LINUX_TARGET, architecture: "x86_64" };
7390
+ }
7235
7391
  var build = async ({
7236
7392
  workPath,
7237
7393
  repoRootPath,
@@ -7244,13 +7400,14 @@ var build = async ({
7244
7400
  registerPreDeploy
7245
7401
  }) => {
7246
7402
  let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
7247
- const builderSpan = parentSpan ?? new import_build_utils16.Span({ name: "vc.builder" });
7403
+ const builderSpan = parentSpan ?? new import_build_utils17.Span({ name: "vc.builder" });
7248
7404
  const framework = config?.framework;
7249
7405
  const shouldInstallVercelWorkers = config?.hasWorkerServices === true;
7250
7406
  let spawnEnv;
7251
7407
  let projectInstallCommand;
7252
7408
  let hasCustomCommand = false;
7253
- (0, import_build_utils16.debug)(`workPath: ${workPath}`);
7409
+ const target = getTargetPlatform(meta.isDev ?? false);
7410
+ (0, import_build_utils17.debug)(`workPath: ${workPath}`);
7254
7411
  workPath = await downloadFilesInWorkPath({
7255
7412
  workPath,
7256
7413
  files: originalFiles,
@@ -7275,7 +7432,7 @@ var build = async ({
7275
7432
  filePath: entrypoint,
7276
7433
  // For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
7277
7434
  // For other services, handlerFunction is used as the entrypoint variable name.
7278
- varName: service && (0, import_build_utils16.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
7435
+ varName: service && (0, import_build_utils17.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
7279
7436
  } : void 0,
7280
7437
  service
7281
7438
  ) ?? void 0;
@@ -7331,7 +7488,7 @@ var build = async ({
7331
7488
  const hasCachedUv = import_fs13.default.existsSync(uvCacheDir);
7332
7489
  const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
7333
7490
  if (hasCachedVenv || hasCachedUv) {
7334
- (0, import_build_utils16.debug)(
7491
+ (0, import_build_utils17.debug)(
7335
7492
  `Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
7336
7493
  );
7337
7494
  }
@@ -7343,14 +7500,14 @@ var build = async ({
7343
7500
  uvCacheDir
7344
7501
  });
7345
7502
  });
7346
- if ((0, import_build_utils16.isPythonFramework)(framework)) {
7503
+ if ((0, import_build_utils17.isPythonFramework)(framework)) {
7347
7504
  const {
7348
7505
  cliType,
7349
7506
  lockfileVersion,
7350
7507
  packageJsonPackageManager,
7351
7508
  turboSupportsCorepackHome
7352
- } = await (0, import_build_utils16.scanParentDirs)(workPath, true);
7353
- spawnEnv = (0, import_build_utils16.getEnvForPackageManager)({
7509
+ } = await (0, import_build_utils17.scanParentDirs)(workPath, true);
7510
+ spawnEnv = (0, import_build_utils17.getEnvForPackageManager)({
7354
7511
  cliType,
7355
7512
  lockfileVersion,
7356
7513
  packageJsonPackageManager,
@@ -7375,7 +7532,7 @@ var build = async ({
7375
7532
  let uvLockPath = null;
7376
7533
  let uvProjectDir = null;
7377
7534
  let projectName;
7378
- await builderSpan.child(import_build_utils16.BUILDER_INSTALLER_STEP, {
7535
+ await builderSpan.child(import_build_utils17.BUILDER_INSTALLER_STEP, {
7379
7536
  installCommand: projectInstallCommand || void 0,
7380
7537
  runtime: "python",
7381
7538
  "python.cache.restored": restoredCache
@@ -7392,7 +7549,7 @@ var build = async ({
7392
7549
  console.log(
7393
7550
  `Running "install" command: \`${projectInstallCommand}\`...`
7394
7551
  );
7395
- await (0, import_build_utils16.execCommand)(projectInstallCommand, {
7552
+ await (0, import_build_utils17.execCommand)(projectInstallCommand, {
7396
7553
  env: pythonEnv,
7397
7554
  cwd: workPath
7398
7555
  });
@@ -7431,7 +7588,8 @@ var build = async ({
7431
7588
  venvPath,
7432
7589
  projectDir,
7433
7590
  frozen: lockFileProvidedByUser,
7434
- locked: !lockFileProvidedByUser
7591
+ locked: !lockFileProvidedByUser,
7592
+ pythonPlatform: target.uvPlatform
7435
7593
  });
7436
7594
  if (lockPath && import_fs13.default.existsSync(lockPath)) {
7437
7595
  await import_fs13.default.promises.mkdir(uvCacheDir, { recursive: true });
@@ -7439,15 +7597,15 @@ var build = async ({
7439
7597
  }
7440
7598
  }
7441
7599
  });
7442
- if ((0, import_build_utils16.isPythonFramework)(framework)) {
7600
+ if ((0, import_build_utils17.isPythonFramework)(framework)) {
7443
7601
  const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
7444
7602
  config?.buildCommand;
7445
- await builderSpan.child(import_build_utils16.BUILDER_COMPILE_STEP, {
7603
+ await builderSpan.child(import_build_utils17.BUILDER_COMPILE_STEP, {
7446
7604
  buildCommand: projectBuildCommand || void 0
7447
7605
  }).trace(async () => {
7448
7606
  if (projectBuildCommand) {
7449
7607
  console.log(`Running "${projectBuildCommand}"`);
7450
- await (0, import_build_utils16.execCommand)(projectBuildCommand, {
7608
+ await (0, import_build_utils17.execCommand)(projectBuildCommand, {
7451
7609
  env: pythonEnv,
7452
7610
  cwd: workPath
7453
7611
  });
@@ -7474,26 +7632,27 @@ var build = async ({
7474
7632
  }
7475
7633
  entrypoint = resolved?.entrypoint;
7476
7634
  if (!entrypoint) {
7477
- throw new import_build_utils16.NowBuildError({
7635
+ throw new import_build_utils17.NowBuildError({
7478
7636
  code: "PYTHON_ENTRYPOINT_NOT_FOUND",
7479
7637
  message: "No Python entrypoint could be detected. Please specify an entrypoint file."
7480
7638
  });
7481
7639
  }
7482
7640
  const djangoStatic = hookResult?.djangoStatic ?? null;
7483
7641
  const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
7484
- (0, import_build_utils16.debug)(`Installing ${runtimeDep}`);
7642
+ (0, import_build_utils17.debug)(`Installing ${runtimeDep}`);
7643
+ const pipPlatformArgs = target.uvPlatform ? ["--python-platform", target.uvPlatform] : [];
7485
7644
  await uv.pip({
7486
7645
  venvPath,
7487
7646
  projectDir: (0, import_path13.join)(workPath, entryDirectory),
7488
- args: ["install", "--link-mode", "copy", runtimeDep]
7647
+ args: ["install", "--link-mode", "copy", ...pipPlatformArgs, runtimeDep]
7489
7648
  });
7490
7649
  if (shouldInstallVercelWorkers) {
7491
7650
  const workersDep = baseEnv.VERCEL_WORKERS_PYTHON || `vercel-workers==${VERCEL_WORKERS_VERSION}`;
7492
- (0, import_build_utils16.debug)(`Installing ${workersDep}`);
7651
+ (0, import_build_utils17.debug)(`Installing ${workersDep}`);
7493
7652
  await uv.pip({
7494
7653
  venvPath,
7495
7654
  projectDir: (0, import_path13.join)(workPath, entryDirectory),
7496
- args: ["install", "--link-mode", "copy", workersDep]
7655
+ args: ["install", "--link-mode", "copy", ...pipPlatformArgs, workersDep]
7497
7656
  });
7498
7657
  }
7499
7658
  const quirksResult = await runQuirks({ venvPath, pythonEnv, workPath });
@@ -7505,25 +7664,25 @@ var build = async ({
7505
7664
  const capturedEnv = { ...pythonEnv };
7506
7665
  const capturedCwd = workPath;
7507
7666
  registerPreDeploy(async () => {
7508
- await builderSpan.child(import_build_utils16.BUILDER_PRE_DEPLOY_STEP, {
7667
+ await builderSpan.child(import_build_utils17.BUILDER_PRE_DEPLOY_STEP, {
7509
7668
  preDeployCommand
7510
7669
  }).trace(async () => {
7511
7670
  console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
7512
- await (0, import_build_utils16.execCommand)(preDeployCommand, {
7671
+ await (0, import_build_utils17.execCommand)(preDeployCommand, {
7513
7672
  env: capturedEnv,
7514
7673
  cwd: capturedCwd
7515
7674
  });
7516
7675
  });
7517
7676
  });
7518
7677
  }
7519
- (0, import_build_utils16.debug)("Entrypoint is", entrypoint);
7678
+ (0, import_build_utils17.debug)("Entrypoint is", entrypoint);
7520
7679
  const moduleName = entrypointToModule(entrypoint);
7521
7680
  if (handlerFunction) {
7522
7681
  const entrypointPath = (0, import_path13.join)(workPath, entrypoint);
7523
7682
  const source = await import_fs13.default.promises.readFile(entrypointPath, "utf-8");
7524
7683
  const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
7525
7684
  if (!found) {
7526
- throw new import_build_utils16.NowBuildError({
7685
+ throw new import_build_utils17.NowBuildError({
7527
7686
  code: "PYTHON_HANDLER_NOT_FOUND",
7528
7687
  message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
7529
7688
  });
@@ -7532,7 +7691,7 @@ var build = async ({
7532
7691
  const vendorDir = resolveVendorDir();
7533
7692
  const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
7534
7693
  const entrypointWithSuffix = `${entrypoint}${suffix}`;
7535
- (0, import_build_utils16.debug)("Entrypoint with suffix is", entrypointWithSuffix);
7694
+ (0, import_build_utils17.debug)("Entrypoint with suffix is", entrypointWithSuffix);
7536
7695
  const crons = await getServiceCrons({
7537
7696
  service,
7538
7697
  entrypoint,
@@ -7617,9 +7776,9 @@ from vercel_runtime.vc_init import vc_handler
7617
7776
  cwd: workPath,
7618
7777
  ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
7619
7778
  };
7620
- const files = await (0, import_build_utils16.glob)("**", globOptions);
7779
+ const files = await (0, import_build_utils17.glob)("**", globOptions);
7621
7780
  if (djangoStatic?.manifestRelPath) {
7622
- files[djangoStatic.manifestRelPath] = new import_build_utils16.FileFsRef({
7781
+ files[djangoStatic.manifestRelPath] = new import_build_utils17.FileFsRef({
7623
7782
  fsPath: (0, import_path13.join)(workPath, djangoStatic.manifestRelPath)
7624
7783
  });
7625
7784
  }
@@ -7656,15 +7815,16 @@ from vercel_runtime.vc_init import vc_handler
7656
7815
  }
7657
7816
  });
7658
7817
  const handlerPyFilename = "vc__handler__python";
7659
- files[`${handlerPyFilename}.py`] = new import_build_utils16.FileBlob({ data: runtimeTrampoline });
7818
+ files[`${handlerPyFilename}.py`] = new import_build_utils17.FileBlob({ data: runtimeTrampoline });
7660
7819
  if (config.framework === "fasthtml") {
7661
7820
  const { SESSKEY = "" } = process.env;
7662
- files[".sesskey"] = new import_build_utils16.FileBlob({ data: `"${SESSKEY}"` });
7821
+ files[".sesskey"] = new import_build_utils17.FileBlob({ data: `"${SESSKEY}"` });
7663
7822
  }
7664
- const output = new import_build_utils16.Lambda({
7823
+ const output = new import_build_utils17.Lambda({
7665
7824
  files,
7666
7825
  handler: `${handlerPyFilename}.vc_handler`,
7667
7826
  runtime: pythonVersion.runtime,
7827
+ architecture: target.architecture,
7668
7828
  environment: lambdaEnv,
7669
7829
  supportsResponseStreaming: true
7670
7830
  });
@@ -7676,19 +7836,19 @@ from vercel_runtime.vc_init import vc_handler
7676
7836
  pythonVersion,
7677
7837
  uvLockPath,
7678
7838
  framework,
7679
- serviceType: service ? (0, import_build_utils16.getReportedServiceType)(service) : void 0
7839
+ serviceType: service ? (0, import_build_utils17.getReportedServiceType)(service) : void 0
7680
7840
  });
7681
7841
  } catch (err) {
7682
- (0, import_build_utils16.debug)(
7842
+ (0, import_build_utils17.debug)(
7683
7843
  `Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
7684
7844
  );
7685
7845
  }
7686
7846
  }
7687
- if (!(0, import_build_utils16.isPythonFramework)(framework) && !service?.name) {
7847
+ if (!(0, import_build_utils17.isPythonFramework)(framework) && !service?.name) {
7688
7848
  return { resultVersion: 3, result: { output } };
7689
7849
  }
7690
7850
  const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
7691
- const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils16.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
7851
+ const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils17.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
7692
7852
  const routes = service?.name ? void 0 : [{ handle: "filesystem" }, { src: "/(.*)", dest: `/${lambdaPath}` }];
7693
7853
  return {
7694
7854
  resultVersion: 2,
@@ -7717,14 +7877,14 @@ var prepareCache = async ({
7717
7877
  }
7718
7878
  } catch {
7719
7879
  }
7720
- return (0, import_build_utils16.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
7880
+ return (0, import_build_utils17.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
7721
7881
  cwd: root,
7722
7882
  ignore
7723
7883
  });
7724
7884
  };
7725
7885
  var shouldServe = (opts) => {
7726
7886
  const framework = opts.config.framework;
7727
- if ((0, import_build_utils16.isPythonFramework)(framework)) {
7887
+ if ((0, import_build_utils17.isPythonFramework)(framework)) {
7728
7888
  const requestPath = opts.requestPath.replace(/\/$/, "");
7729
7889
  if (requestPath.startsWith("api") && opts.hasMatched) {
7730
7890
  return false;