@vercel/python 6.30.0 → 6.30.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 +103 -79
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -3225,19 +3225,19 @@ __export(src_exports, {
3225
3225
  });
3226
3226
  module.exports = __toCommonJS(src_exports);
3227
3227
  var import_child_process3 = require("child_process");
3228
- var import_fs11 = __toESM(require("fs"));
3228
+ var import_fs12 = __toESM(require("fs"));
3229
3229
  var import_path13 = require("path");
3230
3230
 
3231
3231
  // src/package-versions.ts
3232
3232
  var VERCEL_RUNTIME_VERSION = "0.12.0";
3233
- var VERCEL_WORKERS_VERSION = "0.0.15";
3233
+ var VERCEL_WORKERS_VERSION = "0.0.16";
3234
3234
 
3235
3235
  // src/index.ts
3236
3236
  var import_build_utils15 = require("@vercel/build-utils");
3237
3237
 
3238
3238
  // src/install.ts
3239
3239
  var import_execa3 = __toESM(require_execa());
3240
- var import_fs3 = __toESM(require("fs"));
3240
+ var import_fs4 = __toESM(require("fs"));
3241
3241
  var import_path5 = require("path");
3242
3242
  var import_build_utils4 = require("@vercel/build-utils");
3243
3243
  var import_python_analysis2 = require("@vercel/python-analysis");
@@ -3265,8 +3265,14 @@ var UV_PYTHON_DOWNLOADS_MODE = "automatic";
3265
3265
  var UV_CACHE_DIR_SUBPATH = [".vercel", "python", "cache", "uv"];
3266
3266
  var isWin = process.platform === "win32";
3267
3267
  var uvExec = isWin ? "uv.exe" : "uv";
3268
+ var KNOWN_UV_PATH = "/usr/local/bin/uv";
3269
+ function findUvOnBuildImage(knownPath = KNOWN_UV_PATH) {
3270
+ if (!process.env.VERCEL_BUILD_IMAGE)
3271
+ return null;
3272
+ return import_fs.default.existsSync(knownPath) ? knownPath : null;
3273
+ }
3268
3274
  function findUvInPath() {
3269
- return import_which.default.sync("uv", { nothrow: true });
3275
+ return findUvOnBuildImage() ?? import_which.default.sync("uv", { nothrow: true });
3270
3276
  }
3271
3277
  function getUvCacheDir(workPath) {
3272
3278
  return (0, import_path.join)(workPath, ...UV_CACHE_DIR_SUBPATH);
@@ -3448,6 +3454,9 @@ async function getUserScriptsDir(pythonPath) {
3448
3454
  }
3449
3455
  }
3450
3456
  async function findUvBinary(pythonPath) {
3457
+ const buildImageUv = findUvOnBuildImage();
3458
+ if (buildImageUv)
3459
+ return buildImageUv;
3451
3460
  const found = import_which.default.sync("uv", { nothrow: true });
3452
3461
  if (found)
3453
3462
  return found;
@@ -3729,6 +3738,7 @@ function detectPlatform() {
3729
3738
 
3730
3739
  // src/version.ts
3731
3740
  var import_path4 = require("path");
3741
+ var import_fs3 = require("fs");
3732
3742
  var import_build_utils3 = require("@vercel/build-utils");
3733
3743
  var import_python_analysis = require("@vercel/python-analysis");
3734
3744
  function pythonVersionString(pv) {
@@ -3932,10 +3942,24 @@ function isDiscontinued({ discontinueDate }) {
3932
3942
  return discontinueDate !== void 0 && discontinueDate.getTime() <= today;
3933
3943
  }
3934
3944
  var installedPythonsCache = null;
3945
+ function getInstalledPythonsFromFilesystem(basePath = UV_PYTHON_PATH_PREFIX) {
3946
+ const result = /* @__PURE__ */ new Set();
3947
+ for (const opt of allOptions) {
3948
+ const binPath = (0, import_path4.join)(basePath, "bin", `python${opt.major}.${opt.minor}`);
3949
+ if ((0, import_fs3.existsSync)(binPath)) {
3950
+ result.add(pythonVersionString(opt));
3951
+ }
3952
+ }
3953
+ return result;
3954
+ }
3935
3955
  function getInstalledPythons() {
3936
3956
  if (installedPythonsCache !== null) {
3937
3957
  return installedPythonsCache;
3938
3958
  }
3959
+ if (process.env.VERCEL_BUILD_IMAGE) {
3960
+ installedPythonsCache = getInstalledPythonsFromFilesystem();
3961
+ return installedPythonsCache;
3962
+ }
3939
3963
  const uvPath = findUvInPath();
3940
3964
  if (!uvPath) {
3941
3965
  throw new import_build_utils3.NowBuildError({
@@ -3966,9 +3990,9 @@ async function restoreCachedLock(cachedLockPath, projectDir) {
3966
3990
  if (!cachedLockPath)
3967
3991
  return;
3968
3992
  const targetLockPath = (0, import_path5.join)(projectDir, "uv.lock");
3969
- if (import_fs3.default.existsSync(cachedLockPath) && !import_fs3.default.existsSync(targetLockPath)) {
3993
+ if (import_fs4.default.existsSync(cachedLockPath) && !import_fs4.default.existsSync(targetLockPath)) {
3970
3994
  (0, import_build_utils4.debug)("Restoring cached uv.lock");
3971
- await import_fs3.default.promises.copyFile(cachedLockPath, targetLockPath);
3995
+ await import_fs4.default.promises.copyFile(cachedLockPath, targetLockPath);
3972
3996
  }
3973
3997
  }
3974
3998
  var makeDependencyCheckCode = (dependency) => `
@@ -4115,7 +4139,7 @@ async function ensureUvProject({
4115
4139
  lockPath = (0, import_path5.join)(rootDir, lockFile.path);
4116
4140
  projectDir = (0, import_path5.dirname)(lockPath);
4117
4141
  pyprojectPath = (0, import_path5.join)(projectDir, "pyproject.toml");
4118
- if (!import_fs3.default.existsSync(pyprojectPath)) {
4142
+ if (!import_fs4.default.existsSync(pyprojectPath)) {
4119
4143
  throw new Error(
4120
4144
  `Expected "pyproject.toml" next to "${lockFile.kind}" in "${projectDir}"`
4121
4145
  );
@@ -4142,7 +4166,7 @@ async function ensureUvProject({
4142
4166
  }
4143
4167
  const content = (0, import_python_analysis2.stringifyManifest)(manifest.data);
4144
4168
  pyprojectPath = (0, import_path5.join)(projectDir, "pyproject.toml");
4145
- await import_fs3.default.promises.writeFile(pyprojectPath, content);
4169
+ await import_fs4.default.promises.writeFile(pyprojectPath, content);
4146
4170
  }
4147
4171
  const workspaceLockFile = pythonPackage.workspaceLockFile;
4148
4172
  if (workspaceLockFile) {
@@ -4169,7 +4193,7 @@ async function ensureUvProject({
4169
4193
  dependencies: []
4170
4194
  });
4171
4195
  const content = (0, import_python_analysis2.stringifyManifest)(minimalManifest);
4172
- await import_fs3.default.promises.writeFile(pyprojectPath, content);
4196
+ await import_fs4.default.promises.writeFile(pyprojectPath, content);
4173
4197
  await restoreCachedLock(cachedLockPath, projectDir);
4174
4198
  await uv.lock({
4175
4199
  projectDir,
@@ -4177,7 +4201,7 @@ async function ensureUvProject({
4177
4201
  ...requireBinaryWheels ? { noBuild: true, upgrade: true } : {}
4178
4202
  });
4179
4203
  }
4180
- const resolvedLockPath = lockPath && import_fs3.default.existsSync(lockPath) ? lockPath : (0, import_path5.join)(projectDir, "uv.lock");
4204
+ const resolvedLockPath = lockPath && import_fs4.default.existsSync(lockPath) ? lockPath : (0, import_path5.join)(projectDir, "uv.lock");
4181
4205
  return {
4182
4206
  projectDir,
4183
4207
  pyprojectPath,
@@ -4278,12 +4302,12 @@ async function installRequirementsFile({
4278
4302
  }
4279
4303
 
4280
4304
  // src/dependency-externalizer.ts
4281
- var import_fs4 = __toESM(require("fs"));
4305
+ var import_fs5 = __toESM(require("fs"));
4282
4306
  var import_util = require("util");
4283
4307
  var import_path6 = require("path");
4284
4308
  var import_build_utils5 = require("@vercel/build-utils");
4285
4309
  var import_python_analysis3 = require("@vercel/python-analysis");
4286
- var readFile = (0, import_util.promisify)(import_fs4.default.readFile);
4310
+ var readFile = (0, import_util.promisify)(import_fs5.default.readFile);
4287
4311
  var LAMBDA_SIZE_THRESHOLD_BYTES = 245 * 1024 * 1024;
4288
4312
  var LAMBDA_EPHEMERAL_STORAGE_BYTES = 500 * 1024 * 1024;
4289
4313
  var PythonDependencyExternalizer = class {
@@ -4486,7 +4510,7 @@ To fix this, either:
4486
4510
  if (process.env.VERCEL_BUILD_IMAGE) {
4487
4511
  try {
4488
4512
  const uvBinaryPath = await getUvBinaryForBundling(this.pythonPath);
4489
- const uvStats = await import_fs4.default.promises.stat(uvBinaryPath);
4513
+ const uvStats = await import_fs5.default.promises.stat(uvBinaryPath);
4490
4514
  runtimeToolingOverhead = uvStats.size;
4491
4515
  } catch {
4492
4516
  runtimeToolingOverhead = 50 * 1024 * 1024;
@@ -4498,8 +4522,8 @@ To fix this, either:
4498
4522
  const isOutsideWorkPath = projectDirRel.startsWith("..") || uvLockRel.startsWith("..");
4499
4523
  if (isOutsideWorkPath) {
4500
4524
  const pyprojectPath = (0, import_path6.join)(this.uvProjectDir, "pyproject.toml");
4501
- const pyprojectStats = await import_fs4.default.promises.stat(pyprojectPath).catch(() => null);
4502
- const uvLockStats = await import_fs4.default.promises.stat(this.uvLockPath).catch(() => null);
4525
+ const pyprojectStats = await import_fs5.default.promises.stat(pyprojectPath).catch(() => null);
4526
+ const uvLockStats = await import_fs5.default.promises.stat(this.uvLockPath).catch(() => null);
4503
4527
  if (pyprojectStats)
4504
4528
  runtimeToolingOverhead += pyprojectStats.size;
4505
4529
  if (uvLockStats)
@@ -4554,9 +4578,9 @@ To fix this, either:
4554
4578
  const uvBinaryPath = await getUvBinaryForBundling(this.pythonPath);
4555
4579
  const uvBundleDir = (0, import_path6.join)(this.workPath, UV_BUNDLE_DIR);
4556
4580
  const uvLocalPath = (0, import_path6.join)(uvBundleDir, "uv");
4557
- await import_fs4.default.promises.mkdir(uvBundleDir, { recursive: true });
4558
- await import_fs4.default.promises.copyFile(uvBinaryPath, uvLocalPath);
4559
- await import_fs4.default.promises.chmod(uvLocalPath, 493);
4581
+ await import_fs5.default.promises.mkdir(uvBundleDir, { recursive: true });
4582
+ await import_fs5.default.promises.copyFile(uvBinaryPath, uvLocalPath);
4583
+ await import_fs5.default.promises.chmod(uvLocalPath, 493);
4560
4584
  const uvBundlePath = `${UV_BUNDLE_DIR}/uv`;
4561
4585
  files[uvBundlePath] = new import_build_utils5.FileFsRef({
4562
4586
  fsPath: uvLocalPath,
@@ -4729,7 +4753,7 @@ async function mirrorPackagesIntoVendor({
4729
4753
  const includeSet = includePackages ? new Set(includePackages.map(import_python_analysis3.normalizePackageName)) : null;
4730
4754
  const sitePackageDirs = await getVenvSitePackagesDirs(venvPath);
4731
4755
  for (const dir of sitePackageDirs) {
4732
- if (!import_fs4.default.existsSync(dir))
4756
+ if (!import_fs5.default.existsSync(dir))
4733
4757
  continue;
4734
4758
  const resolvedDir = (0, import_path6.resolve)(dir);
4735
4759
  const dirPrefix = resolvedDir + import_path6.sep;
@@ -4746,7 +4770,7 @@ async function mirrorPackagesIntoVendor({
4746
4770
  continue;
4747
4771
  }
4748
4772
  const srcFsPath = (0, import_path6.join)(dir, filePath);
4749
- if (!import_fs4.default.existsSync(srcFsPath)) {
4773
+ if (!import_fs5.default.existsSync(srcFsPath)) {
4750
4774
  continue;
4751
4775
  }
4752
4776
  const bundlePath = (0, import_path6.join)(vendorDirName, filePath).replace(/\\/g, "/");
@@ -4765,7 +4789,7 @@ async function calculateBundleSize(files) {
4765
4789
  const file = files[filePath];
4766
4790
  if ("fsPath" in file && file.fsPath) {
4767
4791
  try {
4768
- const stats = await import_fs4.default.promises.stat(file.fsPath);
4792
+ const stats = await import_fs5.default.promises.stat(file.fsPath);
4769
4793
  totalSize += stats.size;
4770
4794
  } catch (err) {
4771
4795
  console.warn(
@@ -4798,7 +4822,7 @@ async function calculatePerPackageSizes(venvPath) {
4798
4822
  const sizes = /* @__PURE__ */ new Map();
4799
4823
  const sitePackageDirs = await getVenvSitePackagesDirs(venvPath);
4800
4824
  for (const dir of sitePackageDirs) {
4801
- if (!import_fs4.default.existsSync(dir))
4825
+ if (!import_fs5.default.existsSync(dir))
4802
4826
  continue;
4803
4827
  const resolvedDir = (0, import_path6.resolve)(dir);
4804
4828
  const dirPrefix = resolvedDir + import_path6.sep;
@@ -4814,7 +4838,7 @@ async function calculatePerPackageSizes(venvPath) {
4814
4838
  continue;
4815
4839
  }
4816
4840
  try {
4817
- const stats = await import_fs4.default.promises.stat((0, import_path6.join)(dir, filePath));
4841
+ const stats = await import_fs5.default.promises.stat((0, import_path6.join)(dir, filePath));
4818
4842
  totalSize += stats.size;
4819
4843
  } catch {
4820
4844
  }
@@ -4826,7 +4850,7 @@ async function calculatePerPackageSizes(venvPath) {
4826
4850
  }
4827
4851
 
4828
4852
  // src/diagnostics.ts
4829
- var import_fs5 = __toESM(require("fs"));
4853
+ var import_fs6 = __toESM(require("fs"));
4830
4854
  var import_path7 = require("path");
4831
4855
  var import_build_utils6 = require("@vercel/build-utils");
4832
4856
  var import_python_analysis4 = require("@vercel/python-analysis");
@@ -4943,7 +4967,7 @@ async function generateProjectManifest({
4943
4967
  const directEntries = [];
4944
4968
  const transitiveEntries = [];
4945
4969
  {
4946
- const content = await import_fs5.default.promises.readFile(uvLockPath, "utf-8");
4970
+ const content = await import_fs6.default.promises.readFile(uvLockPath, "utf-8");
4947
4971
  const uvLock = (0, import_python_analysis4.parseUvLock)(content, uvLockPath);
4948
4972
  const projectName = project?.name;
4949
4973
  const excludeSet = new Set(
@@ -5047,15 +5071,15 @@ async function generateProjectManifest({
5047
5071
  ]
5048
5072
  };
5049
5073
  const outPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
5050
- await import_fs5.default.promises.mkdir((0, import_path7.dirname)(outPath), { recursive: true });
5051
- await import_fs5.default.promises.writeFile(outPath, JSON.stringify(manifest, null, 2));
5074
+ await import_fs6.default.promises.mkdir((0, import_path7.dirname)(outPath), { recursive: true });
5075
+ await import_fs6.default.promises.writeFile(outPath, JSON.stringify(manifest, null, 2));
5052
5076
  }
5053
5077
  var diagnostics = async ({
5054
5078
  workPath
5055
5079
  }) => {
5056
5080
  try {
5057
5081
  const manifestPath = (0, import_path7.join)(workPath, DIAGNOSTICS_PATH);
5058
- const data = await import_fs5.default.promises.readFile(manifestPath, "utf-8");
5082
+ const data = await import_fs6.default.promises.readFile(manifestPath, "utf-8");
5059
5083
  return {
5060
5084
  [MANIFEST_FILENAME]: new import_build_utils6.FileBlob({ data })
5061
5085
  };
@@ -5069,14 +5093,14 @@ var diagnostics = async ({
5069
5093
 
5070
5094
  // src/start-dev-server.ts
5071
5095
  var import_child_process2 = require("child_process");
5072
- var import_fs7 = require("fs");
5096
+ var import_fs8 = require("fs");
5073
5097
  var import_path9 = require("path");
5074
5098
  var import_build_utils10 = require("@vercel/build-utils");
5075
5099
  var import_get_port = __toESM(require_get_port());
5076
5100
  var import_is_port_reachable = __toESM(require_is_port_reachable());
5077
5101
 
5078
5102
  // src/entrypoint.ts
5079
- var import_fs6 = __toESM(require("fs"));
5103
+ var import_fs7 = __toESM(require("fs"));
5080
5104
  var import_path8 = require("path");
5081
5105
  var import_build_utils7 = require("@vercel/build-utils");
5082
5106
  var import_build_utils8 = require("@vercel/build-utils");
@@ -5103,7 +5127,7 @@ function getCandidateEntrypointsInDirs(dirs) {
5103
5127
  }
5104
5128
  async function fileExists(filePath) {
5105
5129
  try {
5106
- const stat = await import_fs6.default.promises.stat(filePath);
5130
+ const stat = await import_fs7.default.promises.stat(filePath);
5107
5131
  return stat.isFile();
5108
5132
  } catch {
5109
5133
  return false;
@@ -5113,7 +5137,7 @@ async function checkEntrypoint(workPath, relPath) {
5113
5137
  const absPath = (0, import_path8.join)(workPath, relPath);
5114
5138
  if (!await fileExists(absPath))
5115
5139
  return null;
5116
- const content = await import_fs6.default.promises.readFile(absPath, "utf-8");
5140
+ const content = await import_fs7.default.promises.readFile(absPath, "utf-8");
5117
5141
  return (0, import_python_analysis5.findAppOrHandler)(content);
5118
5142
  }
5119
5143
  async function getPyprojectEntrypoint(workPath) {
@@ -5151,7 +5175,7 @@ async function findValidEntrypoint(workPath, candidates) {
5151
5175
  async function checkDjangoManage(workPath) {
5152
5176
  const managePath = (0, import_path8.join)(workPath, "manage.py");
5153
5177
  try {
5154
- const content = await import_fs6.default.promises.readFile(managePath, "utf-8");
5178
+ const content = await import_fs7.default.promises.readFile(managePath, "utf-8");
5155
5179
  if (!content.includes("DJANGO_SETTINGS_MODULE"))
5156
5180
  return false;
5157
5181
  (0, import_build_utils8.debug)(`Found Django manage.py with DJANGO_SETTINGS_MODULE at ${workPath}`);
@@ -5162,7 +5186,7 @@ async function checkDjangoManage(workPath) {
5162
5186
  }
5163
5187
  async function getSubdirectories(workPath) {
5164
5188
  try {
5165
- const entries = await import_fs6.default.promises.readdir(workPath, {
5189
+ const entries = await import_fs7.default.promises.readdir(workPath, {
5166
5190
  withFileTypes: true
5167
5191
  });
5168
5192
  return entries.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
@@ -5336,10 +5360,10 @@ async function syncDependencies({
5336
5360
  }
5337
5361
  if (manifest?.origin && manifestType === "pyproject.toml") {
5338
5362
  const syncDir = (0, import_path9.join)(workPath, ".vercel", "python", "sync");
5339
- (0, import_fs7.mkdirSync)(syncDir, { recursive: true });
5363
+ (0, import_fs8.mkdirSync)(syncDir, { recursive: true });
5340
5364
  const tempPyproject = (0, import_path9.join)(syncDir, "pyproject.toml");
5341
5365
  const content = (0, import_python_analysis6.stringifyManifest)(manifest.data);
5342
- (0, import_fs7.writeFileSync)(tempPyproject, content, "utf8");
5366
+ (0, import_fs8.writeFileSync)(tempPyproject, content, "utf8");
5343
5367
  manifestPath = tempPyproject;
5344
5368
  (0, import_build_utils10.debug)(
5345
5369
  `Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
@@ -5492,7 +5516,7 @@ async function doInstallVercelRuntime({
5492
5516
  onStdout,
5493
5517
  onStderr
5494
5518
  }) {
5495
- (0, import_fs7.mkdirSync)(targetDir, { recursive: true });
5519
+ (0, import_fs8.mkdirSync)(targetDir, { recursive: true });
5496
5520
  const localRuntimeDir = (0, import_path9.join)(
5497
5521
  __dirname,
5498
5522
  "..",
@@ -5501,14 +5525,14 @@ async function doInstallVercelRuntime({
5501
5525
  "python",
5502
5526
  "vercel-runtime"
5503
5527
  );
5504
- const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localRuntimeDir, "pyproject.toml"));
5528
+ const isLocalDev = (0, import_fs8.existsSync)((0, import_path9.join)(localRuntimeDir, "pyproject.toml"));
5505
5529
  const runtimeDep = env.VERCEL_RUNTIME_PYTHON || (isLocalDev ? localRuntimeDir : `vercel-runtime==${VERCEL_RUNTIME_VERSION}`);
5506
5530
  if (!isLocalDev && !env.VERCEL_RUNTIME_PYTHON) {
5507
5531
  const distInfo = (0, import_path9.join)(
5508
5532
  targetDir,
5509
5533
  `vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
5510
5534
  );
5511
- if ((0, import_fs7.existsSync)(distInfo)) {
5535
+ if ((0, import_fs8.existsSync)(distInfo)) {
5512
5536
  (0, import_build_utils10.debug)(
5513
5537
  `vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
5514
5538
  );
@@ -5588,7 +5612,7 @@ async function doInstallVercelWorkers({
5588
5612
  onStdout,
5589
5613
  onStderr
5590
5614
  }) {
5591
- (0, import_fs7.mkdirSync)(targetDir, { recursive: true });
5615
+ (0, import_fs8.mkdirSync)(targetDir, { recursive: true });
5592
5616
  const localWorkersDir = (0, import_path9.join)(
5593
5617
  __dirname,
5594
5618
  "..",
@@ -5597,14 +5621,14 @@ async function doInstallVercelWorkers({
5597
5621
  "python",
5598
5622
  "vercel-workers"
5599
5623
  );
5600
- const isLocalDev = (0, import_fs7.existsSync)((0, import_path9.join)(localWorkersDir, "pyproject.toml"));
5624
+ const isLocalDev = (0, import_fs8.existsSync)((0, import_path9.join)(localWorkersDir, "pyproject.toml"));
5601
5625
  const workersDep = env.VERCEL_WORKERS_PYTHON || (isLocalDev ? localWorkersDir : `vercel-workers==${VERCEL_WORKERS_VERSION}`);
5602
5626
  if (!isLocalDev && !env.VERCEL_WORKERS_PYTHON) {
5603
5627
  const distInfo = (0, import_path9.join)(
5604
5628
  targetDir,
5605
5629
  `vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
5606
5630
  );
5607
- if ((0, import_fs7.existsSync)(distInfo)) {
5631
+ if ((0, import_fs8.existsSync)(distInfo)) {
5608
5632
  (0, import_build_utils10.debug)(
5609
5633
  `vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
5610
5634
  );
@@ -5694,10 +5718,10 @@ function installGlobalCleanupHandlers() {
5694
5718
  function createDevShim(workPath, entry, modulePath, serviceName, framework, variableName) {
5695
5719
  try {
5696
5720
  const vercelPythonDir = serviceName ? (0, import_path9.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path9.join)(workPath, ".vercel", "python");
5697
- (0, import_fs7.mkdirSync)(vercelPythonDir, { recursive: true });
5721
+ (0, import_fs8.mkdirSync)(vercelPythonDir, { recursive: true });
5698
5722
  let qualifiedModule = modulePath;
5699
5723
  let extraPythonPath;
5700
- if ((0, import_fs7.existsSync)((0, import_path9.join)(workPath, "__init__.py"))) {
5724
+ if ((0, import_fs8.existsSync)((0, import_path9.join)(workPath, "__init__.py"))) {
5701
5725
  const pkgName = (0, import_path9.basename)(workPath);
5702
5726
  qualifiedModule = `${pkgName}.${modulePath}`;
5703
5727
  extraPythonPath = (0, import_path9.dirname)(workPath);
@@ -5710,9 +5734,9 @@ function createDevShim(workPath, entry, modulePath, serviceName, framework, vari
5710
5734
  "templates",
5711
5735
  `${DEV_SHIM_MODULE}.py`
5712
5736
  );
5713
- const template = (0, import_fs7.readFileSync)(templatePath, "utf8");
5737
+ const template = (0, import_fs8.readFileSync)(templatePath, "utf8");
5714
5738
  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);
5715
- (0, import_fs7.writeFileSync)(shimPath, shimSource, "utf8");
5739
+ (0, import_fs8.writeFileSync)(shimPath, shimSource, "utf8");
5716
5740
  (0, import_build_utils10.debug)(`Prepared Python dev shim at ${shimPath}`);
5717
5741
  return {
5718
5742
  module: DEV_SHIM_MODULE,
@@ -6019,7 +6043,7 @@ var matplotlibQuirk = {
6019
6043
  };
6020
6044
 
6021
6045
  // src/quirks/litellm.ts
6022
- var import_fs8 = __toESM(require("fs"));
6046
+ var import_fs9 = __toESM(require("fs"));
6023
6047
  var import_path10 = require("path");
6024
6048
  var import_build_utils11 = require("@vercel/build-utils");
6025
6049
  var LAMBDA_ROOT = "/var/task";
@@ -6033,7 +6057,7 @@ async function findConfigFile(workPath) {
6033
6057
  for (const name of CONFIG_CANDIDATES) {
6034
6058
  const candidate = (0, import_path10.join)(workPath, name);
6035
6059
  try {
6036
- await import_fs8.default.promises.access(candidate);
6060
+ await import_fs9.default.promises.access(candidate);
6037
6061
  return name;
6038
6062
  } catch {
6039
6063
  }
@@ -6055,7 +6079,7 @@ var litellmQuirk = {
6055
6079
  "schema.prisma"
6056
6080
  );
6057
6081
  try {
6058
- await import_fs8.default.promises.access(schemaPath);
6082
+ await import_fs9.default.promises.access(schemaPath);
6059
6083
  (0, import_build_utils11.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
6060
6084
  buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
6061
6085
  break;
@@ -6082,7 +6106,7 @@ var litellmQuirk = {
6082
6106
  };
6083
6107
 
6084
6108
  // src/quirks/prisma.ts
6085
- var import_fs9 = __toESM(require("fs"));
6109
+ var import_fs10 = __toESM(require("fs"));
6086
6110
  var import_path11 = require("path");
6087
6111
  var import_execa4 = __toESM(require_execa());
6088
6112
  var import_build_utils12 = require("@vercel/build-utils");
@@ -6125,7 +6149,7 @@ async function findUserSchema(workPath) {
6125
6149
  if (envPath) {
6126
6150
  const resolved = (0, import_path11.isAbsolute)(envPath) ? envPath : (0, import_path11.join)(workPath, envPath);
6127
6151
  try {
6128
- await import_fs9.default.promises.access(resolved);
6152
+ await import_fs10.default.promises.access(resolved);
6129
6153
  return resolved;
6130
6154
  } catch {
6131
6155
  (0, import_build_utils12.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
@@ -6138,7 +6162,7 @@ async function findUserSchema(workPath) {
6138
6162
  ];
6139
6163
  for (const candidate of candidates) {
6140
6164
  try {
6141
- await import_fs9.default.promises.access(candidate);
6165
+ await import_fs10.default.promises.access(candidate);
6142
6166
  return candidate;
6143
6167
  } catch {
6144
6168
  }
@@ -6149,7 +6173,7 @@ async function collectFiles(dir, base) {
6149
6173
  const result = [];
6150
6174
  let entries;
6151
6175
  try {
6152
- entries = await import_fs9.default.promises.readdir(dir, { withFileTypes: true });
6176
+ entries = await import_fs10.default.promises.readdir(dir, { withFileTypes: true });
6153
6177
  } catch {
6154
6178
  return result;
6155
6179
  }
@@ -6174,7 +6198,7 @@ async function cleanCacheArtifacts(cacheDir, extras = []) {
6174
6198
  ];
6175
6199
  for (const p of paths) {
6176
6200
  try {
6177
- await import_fs9.default.promises.rm(p, { recursive: true, force: true });
6201
+ await import_fs10.default.promises.rm(p, { recursive: true, force: true });
6178
6202
  } catch (err) {
6179
6203
  console.warn(
6180
6204
  `could not clean up ${p}: ${err instanceof Error ? err.message : String(err)}`
@@ -6208,7 +6232,7 @@ var prismaQuirk = {
6208
6232
  let sitePackages;
6209
6233
  for (const dir of sitePackagesDirs) {
6210
6234
  try {
6211
- await import_fs9.default.promises.access((0, import_path11.join)(dir, "prisma"));
6235
+ await import_fs10.default.promises.access((0, import_path11.join)(dir, "prisma"));
6212
6236
  sitePackages = dir;
6213
6237
  break;
6214
6238
  } catch {
@@ -6221,14 +6245,14 @@ var prismaQuirk = {
6221
6245
  return {};
6222
6246
  }
6223
6247
  const cacheDir = (0, import_path11.join)(sitePackages, "prisma", "__bincache__");
6224
- await import_fs9.default.promises.mkdir(cacheDir, { recursive: true });
6248
+ await import_fs10.default.promises.mkdir(cacheDir, { recursive: true });
6225
6249
  const generateEnv = {
6226
6250
  ...pythonEnv,
6227
6251
  PRISMA_BINARY_CACHE_DIR: cacheDir
6228
6252
  };
6229
6253
  const generatedDir = (0, import_path11.join)(workPath, "_prisma_generated");
6230
6254
  const dummySchemaPath = (0, import_path11.join)(workPath, DUMMY_SCHEMA_NAME);
6231
- await import_fs9.default.promises.writeFile(
6255
+ await import_fs10.default.promises.writeFile(
6232
6256
  dummySchemaPath,
6233
6257
  buildDummySchema(generatedDir)
6234
6258
  );
@@ -6259,18 +6283,18 @@ var prismaQuirk = {
6259
6283
  const nodeModulesDir = (0, import_path11.join)(cacheDir, "node_modules", "prisma");
6260
6284
  let engineCopied = false;
6261
6285
  try {
6262
- const entries = await import_fs9.default.promises.readdir(nodeModulesDir);
6286
+ const entries = await import_fs10.default.promises.readdir(nodeModulesDir);
6263
6287
  for (const entry of entries) {
6264
6288
  if (!entry.startsWith(srcBinaryPrefix))
6265
6289
  continue;
6266
6290
  const srcPath = (0, import_path11.join)(nodeModulesDir, entry);
6267
6291
  const destPath = (0, import_path11.join)(cacheDir, runtimeName);
6268
6292
  try {
6269
- await import_fs9.default.promises.access(destPath);
6293
+ await import_fs10.default.promises.access(destPath);
6270
6294
  (0, import_build_utils12.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
6271
6295
  } catch {
6272
6296
  (0, import_build_utils12.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
6273
- await import_fs9.default.promises.copyFile(srcPath, destPath);
6297
+ await import_fs10.default.promises.copyFile(srcPath, destPath);
6274
6298
  }
6275
6299
  engineCopied = true;
6276
6300
  }
@@ -6288,15 +6312,15 @@ var prismaQuirk = {
6288
6312
  });
6289
6313
  }
6290
6314
  const shimPath = (0, import_path11.join)(cacheDir, "openssl");
6291
- await import_fs9.default.promises.writeFile(
6315
+ await import_fs10.default.promises.writeFile(
6292
6316
  shimPath,
6293
6317
  `#!/bin/sh
6294
6318
  echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIME_OPENSSL_VERSION}.0)"
6295
6319
  `
6296
6320
  );
6297
- await import_fs9.default.promises.chmod(shimPath, 493);
6321
+ await import_fs10.default.promises.chmod(shimPath, 493);
6298
6322
  for (const p of [generatedDir, dummySchemaPath]) {
6299
- await import_fs9.default.promises.rm(p, { recursive: true, force: true });
6323
+ await import_fs10.default.promises.rm(p, { recursive: true, force: true });
6300
6324
  }
6301
6325
  await cleanCacheArtifacts(cacheDir);
6302
6326
  const generateMode = (process.env.VERCEL_PRISMA_GENERATE_CLIENT ?? "auto").toLowerCase();
@@ -6469,12 +6493,12 @@ async function runQuirks(ctx) {
6469
6493
  }
6470
6494
 
6471
6495
  // src/django.ts
6472
- var import_fs10 = __toESM(require("fs"));
6496
+ var import_fs11 = __toESM(require("fs"));
6473
6497
  var import_path12 = require("path");
6474
6498
  var import_execa5 = __toESM(require_execa());
6475
6499
  var import_build_utils14 = require("@vercel/build-utils");
6476
6500
  var scriptPath = (0, import_path12.join)(__dirname, "..", "templates", "vc_django_settings.py");
6477
- var script = import_fs10.default.readFileSync(scriptPath, "utf-8");
6501
+ var script = import_fs11.default.readFileSync(scriptPath, "utf-8");
6478
6502
  async function getDjangoSettings(projectDir, env) {
6479
6503
  const { stdout } = await (0, import_execa5.default)("python", ["-c", script], {
6480
6504
  env,
@@ -6505,7 +6529,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6505
6529
  ...installedApps.map((app) => (0, import_path12.join)(workPath, ...app.split("."), "static")),
6506
6530
  // TODO: Deal with optional prefixes in STATICFILES_DIRS.
6507
6531
  ...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
6508
- ].filter((d) => import_fs10.default.existsSync(d));
6532
+ ].filter((d) => import_fs11.default.existsSync(d));
6509
6533
  if (storageBackend.startsWith("storages.backends.")) {
6510
6534
  console.log(
6511
6535
  "django-storages detected \u2014 running collectstatic with original settings"
@@ -6529,7 +6553,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6529
6553
  }
6530
6554
  const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
6531
6555
  const staticOutputDir = (0, import_path12.join)(outputStaticDir, staticUrlPath);
6532
- await import_fs10.default.promises.mkdir(staticOutputDir, { recursive: true });
6556
+ await import_fs11.default.promises.mkdir(staticOutputDir, { recursive: true });
6533
6557
  const shimPath = (0, import_path12.join)(workPath, "_vercel_collectstatic_settings.py");
6534
6558
  const shimLines = [
6535
6559
  `from ${settingsModule} import *`,
@@ -6538,7 +6562,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6538
6562
  if (whitenoiseUseFinders) {
6539
6563
  shimLines.push(`WHITENOISE_USE_FINDERS = False`);
6540
6564
  }
6541
- await import_fs10.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
6565
+ await import_fs11.default.promises.writeFile(shimPath, shimLines.join("\n") + "\n");
6542
6566
  try {
6543
6567
  console.log("Running collectstatic...");
6544
6568
  await (0, import_execa5.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
@@ -6549,7 +6573,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6549
6573
  cwd: workPath
6550
6574
  });
6551
6575
  } finally {
6552
- await import_fs10.default.promises.unlink(shimPath).catch(() => {
6576
+ await import_fs11.default.promises.unlink(shimPath).catch(() => {
6553
6577
  });
6554
6578
  }
6555
6579
  const MANIFEST_STORAGE_BACKENDS = [
@@ -6561,8 +6585,8 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6561
6585
  const manifestSrc = (0, import_path12.join)(staticOutputDir, "staticfiles.json");
6562
6586
  const resolvedStaticRoot = (0, import_path12.resolve)(workPath, staticRoot);
6563
6587
  const manifestDest = (0, import_path12.join)(resolvedStaticRoot, "staticfiles.json");
6564
- await import_fs10.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
6565
- await import_fs10.default.promises.copyFile(manifestSrc, manifestDest);
6588
+ await import_fs11.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
6589
+ await import_fs11.default.promises.copyFile(manifestSrc, manifestDest);
6566
6590
  manifestRelPath = (0, import_path12.relative)(workPath, manifestDest);
6567
6591
  (0, import_build_utils14.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
6568
6592
  }
@@ -6576,7 +6600,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
6576
6600
 
6577
6601
  // src/index.ts
6578
6602
  var import_python_analysis9 = require("@vercel/python-analysis");
6579
- var writeFile = import_fs11.default.promises.writeFile;
6603
+ var writeFile = import_fs12.default.promises.writeFile;
6580
6604
  var version = -1;
6581
6605
  async function runFrameworkHook(framework, ctx) {
6582
6606
  const hook = framework ? frameworkHooks[framework] : void 0;
@@ -6749,8 +6773,8 @@ var build = async ({
6749
6773
  }
6750
6774
  const venvPath = service?.name ? (0, import_path13.join)(workPath, ".vercel", "python", "services", service.name, ".venv") : (0, import_path13.join)(workPath, ".vercel", "python", ".venv");
6751
6775
  const uvCacheDir = getUvCacheDir(workPath);
6752
- const hasCachedVenv = import_fs11.default.existsSync((0, import_path13.join)(venvPath, "pyvenv.cfg"));
6753
- const hasCachedUv = import_fs11.default.existsSync(uvCacheDir);
6776
+ const hasCachedVenv = import_fs12.default.existsSync((0, import_path13.join)(venvPath, "pyvenv.cfg"));
6777
+ const hasCachedUv = import_fs12.default.existsSync(uvCacheDir);
6754
6778
  if (hasCachedVenv || hasCachedUv) {
6755
6779
  (0, import_build_utils15.debug)(
6756
6780
  `Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
@@ -6813,7 +6837,7 @@ var build = async ({
6813
6837
  installCommand: projectInstallCommand || void 0
6814
6838
  }).trace(async () => {
6815
6839
  if (projectInstallCommand) {
6816
- await import_fs11.default.promises.rm(venvPath, { recursive: true, force: true });
6840
+ await import_fs12.default.promises.rm(venvPath, { recursive: true, force: true });
6817
6841
  await ensureVenv({
6818
6842
  pythonVersion,
6819
6843
  venvPath,
@@ -6864,9 +6888,9 @@ var build = async ({
6864
6888
  frozen: lockFileProvidedByUser,
6865
6889
  locked: !lockFileProvidedByUser
6866
6890
  });
6867
- if (lockPath && import_fs11.default.existsSync(lockPath)) {
6868
- await import_fs11.default.promises.mkdir(uvCacheDir, { recursive: true });
6869
- await import_fs11.default.promises.copyFile(lockPath, cachedLockPath);
6891
+ if (lockPath && import_fs12.default.existsSync(lockPath)) {
6892
+ await import_fs12.default.promises.mkdir(uvCacheDir, { recursive: true });
6893
+ await import_fs12.default.promises.copyFile(lockPath, cachedLockPath);
6870
6894
  }
6871
6895
  }
6872
6896
  });
@@ -6936,7 +6960,7 @@ var build = async ({
6936
6960
  const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
6937
6961
  if (handlerFunction) {
6938
6962
  const entrypointPath = (0, import_path13.join)(workPath, entrypoint);
6939
- const source = await import_fs11.default.promises.readFile(entrypointPath, "utf-8");
6963
+ const source = await import_fs12.default.promises.readFile(entrypointPath, "utf-8");
6940
6964
  const found = await (0, import_python_analysis9.containsTopLevelCallable)(source, handlerFunction);
6941
6965
  if (!found) {
6942
6966
  throw new import_build_utils15.NowBuildError({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.30.0",
3
+ "version": "6.30.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -36,9 +36,9 @@
36
36
  "smol-toml": "1.5.2",
37
37
  "vitest": "2.1.4",
38
38
  "which": "3.0.0",
39
+ "@vercel/build-utils": "13.14.2",
39
40
  "@vercel/error-utils": "2.0.3",
40
- "@vercel/python-runtime": "0.12.0",
41
- "@vercel/build-utils": "13.14.2"
41
+ "@vercel/python-runtime": "0.12.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "node ../../utils/build-builder.mjs",