@vercel/python 6.0.7 → 6.0.8

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 +224 -102
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var require_windows = __commonJS({
48
48
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
49
49
  module2.exports = isexe;
50
50
  isexe.sync = sync;
51
- var fs5 = require("fs");
51
+ var fs6 = require("fs");
52
52
  function checkPathExt(path, options) {
53
53
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
54
54
  if (!pathext) {
@@ -73,12 +73,12 @@ var require_windows = __commonJS({
73
73
  return checkPathExt(path, options);
74
74
  }
75
75
  function isexe(path, options, cb) {
76
- fs5.stat(path, function(er, stat) {
76
+ fs6.stat(path, function(er, stat) {
77
77
  cb(er, er ? false : checkStat(stat, path, options));
78
78
  });
79
79
  }
80
80
  function sync(path, options) {
81
- return checkStat(fs5.statSync(path), path, options);
81
+ return checkStat(fs6.statSync(path), path, options);
82
82
  }
83
83
  }
84
84
  });
@@ -88,14 +88,14 @@ var require_mode = __commonJS({
88
88
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
89
89
  module2.exports = isexe;
90
90
  isexe.sync = sync;
91
- var fs5 = require("fs");
91
+ var fs6 = require("fs");
92
92
  function isexe(path, options, cb) {
93
- fs5.stat(path, function(er, stat) {
93
+ fs6.stat(path, function(er, stat) {
94
94
  cb(er, er ? false : checkStat(stat, options));
95
95
  });
96
96
  }
97
97
  function sync(path, options) {
98
- return checkStat(fs5.statSync(path), options);
98
+ return checkStat(fs6.statSync(path), options);
99
99
  }
100
100
  function checkStat(stat, options) {
101
101
  return stat.isFile() && checkMode(stat, options);
@@ -119,7 +119,7 @@ var require_mode = __commonJS({
119
119
  // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
120
120
  var require_isexe = __commonJS({
121
121
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
122
- var fs5 = require("fs");
122
+ var fs6 = require("fs");
123
123
  var core;
124
124
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
125
125
  core = require_windows();
@@ -395,7 +395,7 @@ var require_shebang_command = __commonJS({
395
395
  var require_readShebang = __commonJS({
396
396
  "../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
397
397
  "use strict";
398
- var fs5 = require("fs");
398
+ var fs6 = require("fs");
399
399
  var shebangCommand = require_shebang_command();
400
400
  function readShebang(command) {
401
401
  const size = 150;
@@ -408,9 +408,9 @@ var require_readShebang = __commonJS({
408
408
  }
409
409
  let fd;
410
410
  try {
411
- fd = fs5.openSync(command, "r");
412
- fs5.readSync(fd, buffer, 0, size, 0);
413
- fs5.closeSync(fd);
411
+ fd = fs6.openSync(command, "r");
412
+ fs6.readSync(fd, buffer, 0, size, 0);
413
+ fs6.closeSync(fd);
414
414
  } catch (e) {
415
415
  }
416
416
  return shebangCommand(buffer.toString());
@@ -423,15 +423,15 @@ var require_readShebang = __commonJS({
423
423
  var require_semver = __commonJS({
424
424
  "../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js"(exports, module2) {
425
425
  exports = module2.exports = SemVer;
426
- var debug5;
426
+ var debug6;
427
427
  if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
428
- debug5 = function() {
428
+ debug6 = function() {
429
429
  var args = Array.prototype.slice.call(arguments, 0);
430
430
  args.unshift("SEMVER");
431
431
  console.log.apply(console, args);
432
432
  };
433
433
  } else {
434
- debug5 = function() {
434
+ debug6 = function() {
435
435
  };
436
436
  }
437
437
  exports.SEMVER_SPEC_VERSION = "2.0.0";
@@ -540,7 +540,7 @@ var require_semver = __commonJS({
540
540
  var STAR = R++;
541
541
  src[STAR] = "(<|>)?=?\\s*\\*";
542
542
  for (i = 0; i < R; i++) {
543
- debug5(i, src[i]);
543
+ debug6(i, src[i]);
544
544
  if (!re[i]) {
545
545
  re[i] = new RegExp(src[i]);
546
546
  safeRe[i] = new RegExp(makeSafeRe(src[i]));
@@ -607,7 +607,7 @@ var require_semver = __commonJS({
607
607
  if (!(this instanceof SemVer)) {
608
608
  return new SemVer(version2, options);
609
609
  }
610
- debug5("SemVer", version2, options);
610
+ debug6("SemVer", version2, options);
611
611
  this.options = options;
612
612
  this.loose = !!options.loose;
613
613
  var m = version2.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
@@ -654,7 +654,7 @@ var require_semver = __commonJS({
654
654
  return this.version;
655
655
  };
656
656
  SemVer.prototype.compare = function(other) {
657
- debug5("SemVer.compare", this.version, this.options, other);
657
+ debug6("SemVer.compare", this.version, this.options, other);
658
658
  if (!(other instanceof SemVer)) {
659
659
  other = new SemVer(other, this.options);
660
660
  }
@@ -681,7 +681,7 @@ var require_semver = __commonJS({
681
681
  do {
682
682
  var a = this.prerelease[i2];
683
683
  var b = other.prerelease[i2];
684
- debug5("prerelease compare", i2, a, b);
684
+ debug6("prerelease compare", i2, a, b);
685
685
  if (a === void 0 && b === void 0) {
686
686
  return 0;
687
687
  } else if (b === void 0) {
@@ -935,7 +935,7 @@ var require_semver = __commonJS({
935
935
  return new Comparator(comp, options);
936
936
  }
937
937
  comp = comp.trim().split(/\s+/).join(" ");
938
- debug5("comparator", comp, options);
938
+ debug6("comparator", comp, options);
939
939
  this.options = options;
940
940
  this.loose = !!options.loose;
941
941
  this.parse(comp);
@@ -944,7 +944,7 @@ var require_semver = __commonJS({
944
944
  } else {
945
945
  this.value = this.operator + this.semver.version;
946
946
  }
947
- debug5("comp", this);
947
+ debug6("comp", this);
948
948
  }
949
949
  var ANY = {};
950
950
  Comparator.prototype.parse = function(comp) {
@@ -967,7 +967,7 @@ var require_semver = __commonJS({
967
967
  return this.value;
968
968
  };
969
969
  Comparator.prototype.test = function(version2) {
970
- debug5("Comparator.test", version2, this.options.loose);
970
+ debug6("Comparator.test", version2, this.options.loose);
971
971
  if (this.semver === ANY) {
972
972
  return true;
973
973
  }
@@ -1050,9 +1050,9 @@ var require_semver = __commonJS({
1050
1050
  var loose = this.options.loose;
1051
1051
  var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
1052
1052
  range = range.replace(hr, hyphenReplace);
1053
- debug5("hyphen replace", range);
1053
+ debug6("hyphen replace", range);
1054
1054
  range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
1055
- debug5("comparator trim", range, safeRe[COMPARATORTRIM]);
1055
+ debug6("comparator trim", range, safeRe[COMPARATORTRIM]);
1056
1056
  range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
1057
1057
  range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
1058
1058
  var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
@@ -1092,15 +1092,15 @@ var require_semver = __commonJS({
1092
1092
  });
1093
1093
  }
1094
1094
  function parseComparator(comp, options) {
1095
- debug5("comp", comp, options);
1095
+ debug6("comp", comp, options);
1096
1096
  comp = replaceCarets(comp, options);
1097
- debug5("caret", comp);
1097
+ debug6("caret", comp);
1098
1098
  comp = replaceTildes(comp, options);
1099
- debug5("tildes", comp);
1099
+ debug6("tildes", comp);
1100
1100
  comp = replaceXRanges(comp, options);
1101
- debug5("xrange", comp);
1101
+ debug6("xrange", comp);
1102
1102
  comp = replaceStars(comp, options);
1103
- debug5("stars", comp);
1103
+ debug6("stars", comp);
1104
1104
  return comp;
1105
1105
  }
1106
1106
  function isX(id) {
@@ -1114,7 +1114,7 @@ var require_semver = __commonJS({
1114
1114
  function replaceTilde(comp, options) {
1115
1115
  var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
1116
1116
  return comp.replace(r, function(_, M, m, p, pr) {
1117
- debug5("tilde", comp, _, M, m, p, pr);
1117
+ debug6("tilde", comp, _, M, m, p, pr);
1118
1118
  var ret;
1119
1119
  if (isX(M)) {
1120
1120
  ret = "";
@@ -1123,12 +1123,12 @@ var require_semver = __commonJS({
1123
1123
  } else if (isX(p)) {
1124
1124
  ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
1125
1125
  } else if (pr) {
1126
- debug5("replaceTilde pr", pr);
1126
+ debug6("replaceTilde pr", pr);
1127
1127
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
1128
1128
  } else {
1129
1129
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
1130
1130
  }
1131
- debug5("tilde return", ret);
1131
+ debug6("tilde return", ret);
1132
1132
  return ret;
1133
1133
  });
1134
1134
  }
@@ -1138,10 +1138,10 @@ var require_semver = __commonJS({
1138
1138
  }).join(" ");
1139
1139
  }
1140
1140
  function replaceCaret(comp, options) {
1141
- debug5("caret", comp, options);
1141
+ debug6("caret", comp, options);
1142
1142
  var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
1143
1143
  return comp.replace(r, function(_, M, m, p, pr) {
1144
- debug5("caret", comp, _, M, m, p, pr);
1144
+ debug6("caret", comp, _, M, m, p, pr);
1145
1145
  var ret;
1146
1146
  if (isX(M)) {
1147
1147
  ret = "";
@@ -1154,7 +1154,7 @@ var require_semver = __commonJS({
1154
1154
  ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
1155
1155
  }
1156
1156
  } else if (pr) {
1157
- debug5("replaceCaret pr", pr);
1157
+ debug6("replaceCaret pr", pr);
1158
1158
  if (M === "0") {
1159
1159
  if (m === "0") {
1160
1160
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
@@ -1165,7 +1165,7 @@ var require_semver = __commonJS({
1165
1165
  ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
1166
1166
  }
1167
1167
  } else {
1168
- debug5("no pr");
1168
+ debug6("no pr");
1169
1169
  if (M === "0") {
1170
1170
  if (m === "0") {
1171
1171
  ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
@@ -1176,12 +1176,12 @@ var require_semver = __commonJS({
1176
1176
  ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
1177
1177
  }
1178
1178
  }
1179
- debug5("caret return", ret);
1179
+ debug6("caret return", ret);
1180
1180
  return ret;
1181
1181
  });
1182
1182
  }
1183
1183
  function replaceXRanges(comp, options) {
1184
- debug5("replaceXRanges", comp, options);
1184
+ debug6("replaceXRanges", comp, options);
1185
1185
  return comp.split(/\s+/).map(function(comp2) {
1186
1186
  return replaceXRange(comp2, options);
1187
1187
  }).join(" ");
@@ -1190,7 +1190,7 @@ var require_semver = __commonJS({
1190
1190
  comp = comp.trim();
1191
1191
  var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
1192
1192
  return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
1193
- debug5("xRange", comp, ret, gtlt, M, m, p, pr);
1193
+ debug6("xRange", comp, ret, gtlt, M, m, p, pr);
1194
1194
  var xM = isX(M);
1195
1195
  var xm = xM || isX(m);
1196
1196
  var xp = xm || isX(p);
@@ -1233,12 +1233,12 @@ var require_semver = __commonJS({
1233
1233
  } else if (xp) {
1234
1234
  ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
1235
1235
  }
1236
- debug5("xRange return", ret);
1236
+ debug6("xRange return", ret);
1237
1237
  return ret;
1238
1238
  });
1239
1239
  }
1240
1240
  function replaceStars(comp, options) {
1241
- debug5("replaceStars", comp, options);
1241
+ debug6("replaceStars", comp, options);
1242
1242
  return comp.trim().replace(safeRe[STAR], "");
1243
1243
  }
1244
1244
  function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
@@ -1286,7 +1286,7 @@ var require_semver = __commonJS({
1286
1286
  }
1287
1287
  if (version2.prerelease.length && !options.includePrerelease) {
1288
1288
  for (i2 = 0; i2 < set.length; i2++) {
1289
- debug5(set[i2].semver);
1289
+ debug6(set[i2].semver);
1290
1290
  if (set[i2].semver === ANY) {
1291
1291
  continue;
1292
1292
  }
@@ -1895,9 +1895,9 @@ var require_pump = __commonJS({
1895
1895
  "../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
1896
1896
  var once = require_once();
1897
1897
  var eos = require_end_of_stream();
1898
- var fs5;
1898
+ var fs6;
1899
1899
  try {
1900
- fs5 = require("fs");
1900
+ fs6 = require("fs");
1901
1901
  } catch (e) {
1902
1902
  }
1903
1903
  var noop = function() {
@@ -1909,9 +1909,9 @@ var require_pump = __commonJS({
1909
1909
  var isFS = function(stream) {
1910
1910
  if (!ancient)
1911
1911
  return false;
1912
- if (!fs5)
1912
+ if (!fs6)
1913
1913
  return false;
1914
- return (stream instanceof (fs5.ReadStream || noop) || stream instanceof (fs5.WriteStream || noop)) && isFn(stream.close);
1914
+ return (stream instanceof (fs6.ReadStream || noop) || stream instanceof (fs6.WriteStream || noop)) && isFn(stream.close);
1915
1915
  };
1916
1916
  var isRequest = function(stream) {
1917
1917
  return stream.setHeader && isFn(stream.abort);
@@ -2651,7 +2651,7 @@ ${stderr}${stdout}`;
2651
2651
  var require_lib = __commonJS({
2652
2652
  "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
2653
2653
  var isexe = require_isexe();
2654
- var { join: join6, delimiter, sep, posix } = require("path");
2654
+ var { join: join7, delimiter, sep, posix } = require("path");
2655
2655
  var isWindows = process.platform === "win32";
2656
2656
  var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
2657
2657
  var rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -2680,7 +2680,7 @@ var require_lib = __commonJS({
2680
2680
  var getPathPart = (raw, cmd) => {
2681
2681
  const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
2682
2682
  const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
2683
- return prefix + join6(pathPart, cmd);
2683
+ return prefix + join7(pathPart, cmd);
2684
2684
  };
2685
2685
  var which3 = async (cmd, opt = {}) => {
2686
2686
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
@@ -2748,10 +2748,10 @@ __export(src_exports, {
2748
2748
  version: () => version
2749
2749
  });
2750
2750
  module.exports = __toCommonJS(src_exports);
2751
- var import_fs5 = __toESM(require("fs"));
2751
+ var import_fs6 = __toESM(require("fs"));
2752
2752
  var import_util = require("util");
2753
- var import_path5 = require("path");
2754
- var import_build_utils7 = require("@vercel/build-utils");
2753
+ var import_path6 = require("path");
2754
+ var import_build_utils8 = require("@vercel/build-utils");
2755
2755
 
2756
2756
  // src/install.ts
2757
2757
  var import_execa = __toESM(require_execa());
@@ -3071,7 +3071,7 @@ async function exportRequirementsFromPipfile({
3071
3071
  }
3072
3072
 
3073
3073
  // src/index.ts
3074
- var import_build_utils8 = require("@vercel/build-utils");
3074
+ var import_build_utils9 = require("@vercel/build-utils");
3075
3075
 
3076
3076
  // src/version.ts
3077
3077
  var import_build_utils2 = require("@vercel/build-utils");
@@ -3835,9 +3835,118 @@ If you are using a virtual environment, activate it before running "vercel dev",
3835
3835
  }
3836
3836
  };
3837
3837
 
3838
+ // src/uv-workspace.ts
3839
+ var import_fs5 = __toESM(require("fs"));
3840
+ var import_os2 = __toESM(require("os"));
3841
+ var import_path5 = require("path");
3842
+ var import_build_utils7 = require("@vercel/build-utils");
3843
+ function getDependencyName(spec) {
3844
+ const match = spec.match(/^[A-Za-z0-9_.-]+/);
3845
+ return match ? match[0] : null;
3846
+ }
3847
+ async function installUvWorkspaceDependencies({
3848
+ repoRootPath,
3849
+ pyprojectDir,
3850
+ pythonPath,
3851
+ pipPath,
3852
+ uvPath,
3853
+ workPath,
3854
+ vendorBaseDir,
3855
+ meta
3856
+ }) {
3857
+ if (!repoRootPath || !pyprojectDir) {
3858
+ return;
3859
+ }
3860
+ let rootPyproject = null;
3861
+ try {
3862
+ rootPyproject = await (0, import_build_utils7.readConfigFile)(
3863
+ (0, import_path5.join)(repoRootPath, "pyproject.toml")
3864
+ );
3865
+ } catch (err) {
3866
+ (0, import_build_utils7.debug)("Failed to parse workspace root pyproject.toml", err);
3867
+ }
3868
+ const uvTool = rootPyproject?.tool?.uv;
3869
+ const workspaceCfg = uvTool?.workspace;
3870
+ const sourcesCfg = uvTool?.sources;
3871
+ if (!workspaceCfg || !sourcesCfg) {
3872
+ return;
3873
+ }
3874
+ const workspaceSourceNames = new Set(
3875
+ Object.entries(sourcesCfg).filter(([, src]) => src && src.workspace).map(([name]) => name)
3876
+ );
3877
+ if (!workspaceSourceNames.size) {
3878
+ return;
3879
+ }
3880
+ let appPyproject = null;
3881
+ try {
3882
+ appPyproject = await (0, import_build_utils7.readConfigFile)(
3883
+ (0, import_path5.join)(pyprojectDir, "pyproject.toml")
3884
+ );
3885
+ } catch (err) {
3886
+ (0, import_build_utils7.debug)("Failed to parse app pyproject.toml for workspace deps", err);
3887
+ }
3888
+ const appDeps = appPyproject?.project?.dependencies ?? [];
3889
+ const workspaceDepsForApp = /* @__PURE__ */ new Set();
3890
+ for (const spec of appDeps) {
3891
+ const name = getDependencyName(spec);
3892
+ if (name && workspaceSourceNames.has(name)) {
3893
+ workspaceDepsForApp.add(name);
3894
+ }
3895
+ }
3896
+ if (!workspaceDepsForApp.size) {
3897
+ return;
3898
+ }
3899
+ const members = workspaceCfg.members ?? [];
3900
+ const nameToDir = /* @__PURE__ */ new Map();
3901
+ for (const member of members) {
3902
+ const memberDir = (0, import_path5.join)(repoRootPath, member);
3903
+ let memberPyproject = null;
3904
+ try {
3905
+ memberPyproject = await (0, import_build_utils7.readConfigFile)(
3906
+ (0, import_path5.join)(memberDir, "pyproject.toml")
3907
+ );
3908
+ } catch (err) {
3909
+ (0, import_build_utils7.debug)("Failed to parse workspace member pyproject.toml", err);
3910
+ continue;
3911
+ }
3912
+ const projectName = memberPyproject?.project?.name;
3913
+ if (projectName) {
3914
+ nameToDir.set(projectName, memberDir);
3915
+ }
3916
+ }
3917
+ const requirementLines = [];
3918
+ for (const name of workspaceDepsForApp) {
3919
+ const dir = nameToDir.get(name);
3920
+ if (!dir) {
3921
+ (0, import_build_utils7.debug)(
3922
+ `uv workspace dependency "${name}" declared but corresponding member directory not found`
3923
+ );
3924
+ continue;
3925
+ }
3926
+ requirementLines.push(dir);
3927
+ }
3928
+ if (!requirementLines.length) {
3929
+ return;
3930
+ }
3931
+ const tmpDir = await import_fs5.default.promises.mkdtemp(
3932
+ (0, import_path5.join)(import_os2.default.tmpdir(), "vercel-uv-workspace-")
3933
+ );
3934
+ const reqPath = (0, import_path5.join)(tmpDir, "requirements.workspace.txt");
3935
+ await import_fs5.default.promises.writeFile(reqPath, requirementLines.join("\n"));
3936
+ await installRequirementsFile({
3937
+ pythonPath,
3938
+ pipPath,
3939
+ uvPath,
3940
+ filePath: reqPath,
3941
+ workPath,
3942
+ targetDir: vendorBaseDir,
3943
+ meta
3944
+ });
3945
+ }
3946
+
3838
3947
  // src/index.ts
3839
- var readFile = (0, import_util.promisify)(import_fs5.default.readFile);
3840
- var writeFile = (0, import_util.promisify)(import_fs5.default.writeFile);
3948
+ var readFile = (0, import_util.promisify)(import_fs6.default.readFile);
3949
+ var writeFile = (0, import_util.promisify)(import_fs6.default.writeFile);
3841
3950
  var version = 3;
3842
3951
  function findDir({
3843
3952
  file,
@@ -3845,8 +3954,8 @@ function findDir({
3845
3954
  workPath,
3846
3955
  fsFiles
3847
3956
  }) {
3848
- if (fsFiles[(0, import_path5.join)(entryDirectory, file)]) {
3849
- return (0, import_path5.join)(workPath, entryDirectory);
3957
+ if (fsFiles[(0, import_path6.join)(entryDirectory, file)]) {
3958
+ return (0, import_path6.join)(workPath, entryDirectory);
3850
3959
  }
3851
3960
  if (fsFiles[file]) {
3852
3961
  return workPath;
@@ -3859,19 +3968,20 @@ async function downloadFilesInWorkPath({
3859
3968
  files,
3860
3969
  meta = {}
3861
3970
  }) {
3862
- (0, import_build_utils7.debug)("Downloading user files...");
3863
- let downloadedFiles = await (0, import_build_utils7.download)(files, workPath, meta);
3971
+ (0, import_build_utils8.debug)("Downloading user files...");
3972
+ let downloadedFiles = await (0, import_build_utils8.download)(files, workPath, meta);
3864
3973
  if (meta.isDev) {
3865
- const { devCacheDir = (0, import_path5.join)(workPath, ".now", "cache") } = meta;
3866
- const destCache = (0, import_path5.join)(devCacheDir, (0, import_path5.basename)(entrypoint, ".py"));
3867
- await (0, import_build_utils7.download)(downloadedFiles, destCache);
3868
- downloadedFiles = await (0, import_build_utils7.glob)("**", destCache);
3974
+ const { devCacheDir = (0, import_path6.join)(workPath, ".now", "cache") } = meta;
3975
+ const destCache = (0, import_path6.join)(devCacheDir, (0, import_path6.basename)(entrypoint, ".py"));
3976
+ await (0, import_build_utils8.download)(downloadedFiles, destCache);
3977
+ downloadedFiles = await (0, import_build_utils8.glob)("**", destCache);
3869
3978
  workPath = destCache;
3870
3979
  }
3871
3980
  return workPath;
3872
3981
  }
3873
3982
  var build = async ({
3874
3983
  workPath,
3984
+ repoRootPath,
3875
3985
  files: originalFiles,
3876
3986
  entrypoint,
3877
3987
  meta = {},
@@ -3886,7 +3996,7 @@ var build = async ({
3886
3996
  });
3887
3997
  try {
3888
3998
  if (meta.isDev) {
3889
- const setupCfg = (0, import_path5.join)(workPath, "setup.cfg");
3999
+ const setupCfg = (0, import_path6.join)(workPath, "setup.cfg");
3890
4000
  await writeFile(setupCfg, "[install]\nprefix=\n");
3891
4001
  }
3892
4002
  } catch (err) {
@@ -3899,8 +4009,8 @@ var build = async ({
3899
4009
  lockfileVersion,
3900
4010
  packageJsonPackageManager,
3901
4011
  turboSupportsCorepackHome
3902
- } = await (0, import_build_utils7.scanParentDirs)(workPath, true);
3903
- const spawnEnv = (0, import_build_utils7.getEnvForPackageManager)({
4012
+ } = await (0, import_build_utils8.scanParentDirs)(workPath, true);
4013
+ const spawnEnv = (0, import_build_utils8.getEnvForPackageManager)({
3904
4014
  cliType,
3905
4015
  lockfileVersion,
3906
4016
  packageJsonPackageManager,
@@ -3912,7 +4022,7 @@ var build = async ({
3912
4022
  if (typeof installCommand === "string") {
3913
4023
  if (installCommand.trim()) {
3914
4024
  console.log(`Running "install" command: \`${installCommand}\`...`);
3915
- await (0, import_build_utils7.execCommand)(installCommand, {
4025
+ await (0, import_build_utils8.execCommand)(installCommand, {
3916
4026
  env: spawnEnv,
3917
4027
  cwd: workPath
3918
4028
  });
@@ -3924,7 +4034,7 @@ var build = async ({
3924
4034
  config?.buildCommand;
3925
4035
  if (projectBuildCommand) {
3926
4036
  console.log(`Running "${projectBuildCommand}"`);
3927
- await (0, import_build_utils7.execCommand)(projectBuildCommand, {
4037
+ await (0, import_build_utils8.execCommand)(projectBuildCommand, {
3928
4038
  env: spawnEnv,
3929
4039
  cwd: workPath
3930
4040
  });
@@ -3936,7 +4046,7 @@ var build = async ({
3936
4046
  );
3937
4047
  }
3938
4048
  }
3939
- let fsFiles = await (0, import_build_utils7.glob)("**", workPath);
4049
+ let fsFiles = await (0, import_build_utils8.glob)("**", workPath);
3940
4050
  if ((framework === "fastapi" || framework === "flask") && (!fsFiles[entrypoint] || !entrypoint.endsWith(".py"))) {
3941
4051
  const detected = await detectPythonEntrypoint(
3942
4052
  config.framework,
@@ -3944,13 +4054,13 @@ var build = async ({
3944
4054
  entrypoint
3945
4055
  );
3946
4056
  if (detected) {
3947
- (0, import_build_utils7.debug)(
4057
+ (0, import_build_utils8.debug)(
3948
4058
  `Resolved Python entrypoint to "${detected}" (configured "${entrypoint}" not found).`
3949
4059
  );
3950
4060
  entrypoint = detected;
3951
4061
  } else {
3952
4062
  const searchedList = framework === "fastapi" ? FASTAPI_CANDIDATE_ENTRYPOINTS.join(", ") : FLASK_CANDIDATE_ENTRYPOINTS.join(", ");
3953
- throw new import_build_utils7.NowBuildError({
4063
+ throw new import_build_utils8.NowBuildError({
3954
4064
  code: `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`,
3955
4065
  message: `No ${framework} entrypoint found. Define a valid application entrypoint in one of the following locations: ${searchedList} or add an 'app' script in pyproject.toml.`,
3956
4066
  link: `https://vercel.com/docs/frameworks/backend/${framework}#exporting-the-${framework}-application`,
@@ -3958,8 +4068,8 @@ var build = async ({
3958
4068
  });
3959
4069
  }
3960
4070
  }
3961
- const entryDirectory = (0, import_path5.dirname)(entrypoint);
3962
- const hasReqLocal = !!fsFiles[(0, import_path5.join)(entryDirectory, "requirements.txt")];
4071
+ const entryDirectory = (0, import_path6.dirname)(entrypoint);
4072
+ const hasReqLocal = !!fsFiles[(0, import_path6.join)(entryDirectory, "requirements.txt")];
3963
4073
  const hasReqGlobal = !!fsFiles["requirements.txt"];
3964
4074
  const uvLockDir = findDir({
3965
4075
  file: "uv.lock",
@@ -3973,31 +4083,31 @@ var build = async ({
3973
4083
  workPath,
3974
4084
  fsFiles
3975
4085
  });
3976
- const pipfileLockDir = fsFiles[(0, import_path5.join)(entryDirectory, "Pipfile.lock")] ? (0, import_path5.join)(workPath, entryDirectory) : fsFiles["Pipfile.lock"] ? workPath : null;
3977
- const pipfileDir = fsFiles[(0, import_path5.join)(entryDirectory, "Pipfile")] ? (0, import_path5.join)(workPath, entryDirectory) : fsFiles["Pipfile"] ? workPath : null;
4086
+ const pipfileLockDir = fsFiles[(0, import_path6.join)(entryDirectory, "Pipfile.lock")] ? (0, import_path6.join)(workPath, entryDirectory) : fsFiles["Pipfile.lock"] ? workPath : null;
4087
+ const pipfileDir = fsFiles[(0, import_path6.join)(entryDirectory, "Pipfile")] ? (0, import_path6.join)(workPath, entryDirectory) : fsFiles["Pipfile"] ? workPath : null;
3978
4088
  let declaredPythonVersion;
3979
4089
  if (pyprojectDir) {
3980
4090
  let requiresPython;
3981
4091
  try {
3982
- const pyproject = await (0, import_build_utils8.readConfigFile)((0, import_path5.join)(pyprojectDir, "pyproject.toml"));
4092
+ const pyproject = await (0, import_build_utils9.readConfigFile)((0, import_path6.join)(pyprojectDir, "pyproject.toml"));
3983
4093
  requiresPython = pyproject?.project?.["requires-python"];
3984
4094
  } catch (err) {
3985
- (0, import_build_utils7.debug)("Failed to parse pyproject.toml", err);
4095
+ (0, import_build_utils8.debug)("Failed to parse pyproject.toml", err);
3986
4096
  }
3987
4097
  if (typeof requiresPython === "string" && requiresPython.trim()) {
3988
4098
  declaredPythonVersion = {
3989
4099
  version: requiresPython.trim(),
3990
4100
  source: "pyproject.toml"
3991
4101
  };
3992
- (0, import_build_utils7.debug)(`Found requires-python "${requiresPython}" in pyproject.toml`);
4102
+ (0, import_build_utils8.debug)(`Found requires-python "${requiresPython}" in pyproject.toml`);
3993
4103
  }
3994
4104
  } else if (pipfileLockDir) {
3995
4105
  let lock = {};
3996
4106
  try {
3997
- const json = await readFile((0, import_path5.join)(pipfileLockDir, "Pipfile.lock"), "utf8");
4107
+ const json = await readFile((0, import_path6.join)(pipfileLockDir, "Pipfile.lock"), "utf8");
3998
4108
  lock = JSON.parse(json);
3999
4109
  } catch (err) {
4000
- throw new import_build_utils7.NowBuildError({
4110
+ throw new import_build_utils8.NowBuildError({
4001
4111
  code: "INVALID_PIPFILE_LOCK",
4002
4112
  message: "Unable to parse Pipfile.lock"
4003
4113
  });
@@ -4005,16 +4115,16 @@ var build = async ({
4005
4115
  const pyFromLock = lock?._meta?.requires?.python_version;
4006
4116
  if (pyFromLock) {
4007
4117
  declaredPythonVersion = { version: pyFromLock, source: "Pipfile.lock" };
4008
- (0, import_build_utils7.debug)(`Found Python version ${pyFromLock} in Pipfile.lock`);
4118
+ (0, import_build_utils8.debug)(`Found Python version ${pyFromLock} in Pipfile.lock`);
4009
4119
  }
4010
4120
  }
4011
4121
  const pythonVersion = getSupportedPythonVersion({
4012
4122
  isDev: meta.isDev,
4013
4123
  declaredPythonVersion
4014
4124
  });
4015
- fsFiles = await (0, import_build_utils7.glob)("**", workPath);
4016
- const requirementsTxt = (0, import_path5.join)(entryDirectory, "requirements.txt");
4017
- const vendorBaseDir = (0, import_path5.join)(
4125
+ fsFiles = await (0, import_build_utils8.glob)("**", workPath);
4126
+ const requirementsTxt = (0, import_path6.join)(entryDirectory, "requirements.txt");
4127
+ const vendorBaseDir = (0, import_path6.join)(
4018
4128
  workPath,
4019
4129
  ".vercel",
4020
4130
  "python",
@@ -4022,7 +4132,7 @@ var build = async ({
4022
4132
  entryDirectory
4023
4133
  );
4024
4134
  try {
4025
- await import_fs5.default.promises.mkdir(vendorBaseDir, { recursive: true });
4135
+ await import_fs6.default.promises.mkdir(vendorBaseDir, { recursive: true });
4026
4136
  } catch (err) {
4027
4137
  console.log("Failed to create vendor cache directory");
4028
4138
  throw err;
@@ -4057,7 +4167,7 @@ var build = async ({
4057
4167
  `uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
4058
4168
  );
4059
4169
  }
4060
- (0, import_build_utils7.debug)("Failed to install uv", err);
4170
+ (0, import_build_utils8.debug)("Failed to install uv", err);
4061
4171
  }
4062
4172
  await installRequirement({
4063
4173
  pythonPath: pythonVersion.pythonPath,
@@ -4083,7 +4193,7 @@ var build = async ({
4083
4193
  }
4084
4194
  let installedFromProjectFiles = false;
4085
4195
  if (uvLockDir) {
4086
- (0, import_build_utils7.debug)('Found "uv.lock"');
4196
+ (0, import_build_utils8.debug)('Found "uv.lock"');
4087
4197
  if (pyprojectDir) {
4088
4198
  const exportedReq = await exportRequirementsFromUv(pyprojectDir, uvPath, {
4089
4199
  locked: true
@@ -4099,10 +4209,10 @@ var build = async ({
4099
4209
  });
4100
4210
  installedFromProjectFiles = true;
4101
4211
  } else {
4102
- (0, import_build_utils7.debug)('Skipping uv export because "pyproject.toml" was not found');
4212
+ (0, import_build_utils8.debug)('Skipping uv export because "pyproject.toml" was not found');
4103
4213
  }
4104
4214
  } else if (pyprojectDir) {
4105
- (0, import_build_utils7.debug)('Found "pyproject.toml"');
4215
+ (0, import_build_utils8.debug)('Found "pyproject.toml"');
4106
4216
  if (hasReqLocal || hasReqGlobal) {
4107
4217
  console.log(
4108
4218
  "Detected both pyproject.toml and requirements.txt but no lockfile; using pyproject.toml"
@@ -4122,9 +4232,9 @@ var build = async ({
4122
4232
  });
4123
4233
  installedFromProjectFiles = true;
4124
4234
  } else if (pipfileLockDir || pipfileDir) {
4125
- (0, import_build_utils7.debug)(`Found ${pipfileLockDir ? '"Pipfile.lock"' : '"Pipfile"'}`);
4235
+ (0, import_build_utils8.debug)(`Found ${pipfileLockDir ? '"Pipfile.lock"' : '"Pipfile"'}`);
4126
4236
  if (hasReqLocal || hasReqGlobal) {
4127
- (0, import_build_utils7.debug)('Skipping Pipfile export because "requirements.txt" exists');
4237
+ (0, import_build_utils8.debug)('Skipping Pipfile export because "requirements.txt" exists');
4128
4238
  } else {
4129
4239
  const exportedReq = await exportRequirementsFromPipfile({
4130
4240
  pythonPath: pythonVersion.pythonPath,
@@ -4146,7 +4256,7 @@ var build = async ({
4146
4256
  }
4147
4257
  }
4148
4258
  if (!installedFromProjectFiles && fsFiles[requirementsTxt]) {
4149
- (0, import_build_utils7.debug)('Found local "requirements.txt"');
4259
+ (0, import_build_utils8.debug)('Found local "requirements.txt"');
4150
4260
  const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
4151
4261
  await installRequirementsFile({
4152
4262
  pythonPath: pythonVersion.pythonPath,
@@ -4158,7 +4268,7 @@ var build = async ({
4158
4268
  meta
4159
4269
  });
4160
4270
  } else if (!installedFromProjectFiles && fsFiles["requirements.txt"]) {
4161
- (0, import_build_utils7.debug)('Found global "requirements.txt"');
4271
+ (0, import_build_utils8.debug)('Found global "requirements.txt"');
4162
4272
  const requirementsTxtPath = fsFiles["requirements.txt"].fsPath;
4163
4273
  await installRequirementsFile({
4164
4274
  pythonPath: pythonVersion.pythonPath,
@@ -4170,14 +4280,26 @@ var build = async ({
4170
4280
  meta
4171
4281
  });
4172
4282
  }
4173
- const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
4283
+ if (pyprojectDir && repoRootPath) {
4284
+ await installUvWorkspaceDependencies({
4285
+ repoRootPath,
4286
+ pyprojectDir,
4287
+ pythonPath: pythonVersion.pythonPath,
4288
+ pipPath: pythonVersion.pipPath,
4289
+ uvPath,
4290
+ workPath,
4291
+ vendorBaseDir,
4292
+ meta
4293
+ });
4294
+ }
4295
+ const originalPyPath = (0, import_path6.join)(__dirname, "..", "vc_init.py");
4174
4296
  const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
4175
- (0, import_build_utils7.debug)("Entrypoint is", entrypoint);
4297
+ (0, import_build_utils8.debug)("Entrypoint is", entrypoint);
4176
4298
  const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
4177
4299
  const vendorDir = resolveVendorDir();
4178
4300
  const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
4179
4301
  const entrypointWithSuffix = `${entrypoint}${suffix}`;
4180
- (0, import_build_utils7.debug)("Entrypoint with suffix is", entrypointWithSuffix);
4302
+ (0, import_build_utils8.debug)("Entrypoint with suffix is", entrypointWithSuffix);
4181
4303
  const handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix).replace(/__VC_HANDLER_VENDOR_DIR/g, vendorDir);
4182
4304
  const predefinedExcludes = [
4183
4305
  ".git/**",
@@ -4203,11 +4325,11 @@ var build = async ({
4203
4325
  cwd: workPath,
4204
4326
  ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
4205
4327
  };
4206
- const files = await (0, import_build_utils7.glob)("**", globOptions);
4328
+ const files = await (0, import_build_utils8.glob)("**", globOptions);
4207
4329
  try {
4208
- const cachedVendorAbs = (0, import_path5.join)(vendorBaseDir, resolveVendorDir());
4209
- if (import_fs5.default.existsSync(cachedVendorAbs)) {
4210
- const vendorFiles = await (0, import_build_utils7.glob)("**", cachedVendorAbs, resolveVendorDir());
4330
+ const cachedVendorAbs = (0, import_path6.join)(vendorBaseDir, resolveVendorDir());
4331
+ if (import_fs6.default.existsSync(cachedVendorAbs)) {
4332
+ const vendorFiles = await (0, import_build_utils8.glob)("**", cachedVendorAbs, resolveVendorDir());
4211
4333
  for (const [p, f] of Object.entries(vendorFiles)) {
4212
4334
  files[p] = f;
4213
4335
  }
@@ -4217,12 +4339,12 @@ var build = async ({
4217
4339
  throw err;
4218
4340
  }
4219
4341
  const handlerPyFilename = "vc__handler__python";
4220
- files[`${handlerPyFilename}.py`] = new import_build_utils7.FileBlob({ data: handlerPyContents });
4342
+ files[`${handlerPyFilename}.py`] = new import_build_utils8.FileBlob({ data: handlerPyContents });
4221
4343
  if (config.framework === "fasthtml") {
4222
4344
  const { SESSKEY = "" } = process.env;
4223
- files[".sesskey"] = new import_build_utils7.FileBlob({ data: `"${SESSKEY}"` });
4345
+ files[".sesskey"] = new import_build_utils8.FileBlob({ data: `"${SESSKEY}"` });
4224
4346
  }
4225
- const output = new import_build_utils7.Lambda({
4347
+ const output = new import_build_utils8.Lambda({
4226
4348
  files,
4227
4349
  handler: `${handlerPyFilename}.vc_handler`,
4228
4350
  runtime: pythonVersion.runtime,
@@ -4258,7 +4380,7 @@ var defaultShouldServe = ({
4258
4380
  if (entrypoint === requestPath && hasProp(files, entrypoint)) {
4259
4381
  return true;
4260
4382
  }
4261
- const { dir, name } = (0, import_path5.parse)(entrypoint);
4383
+ const { dir, name } = (0, import_path6.parse)(entrypoint);
4262
4384
  if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) {
4263
4385
  return true;
4264
4386
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.0.7",
3
+ "version": "6.0.8",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",