@vercel/python 6.44.0 → 6.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +96 -180
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1890,9 +1890,9 @@ var require_end_of_stream = __commonJS({
1890
1890
  }
1891
1891
  });
1892
1892
 
1893
- // ../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js
1893
+ // ../../node_modules/.pnpm/pump@3.0.4/node_modules/pump/index.js
1894
1894
  var require_pump = __commonJS({
1895
- "../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
1895
+ "../../node_modules/.pnpm/pump@3.0.4/node_modules/pump/index.js"(exports, module2) {
1896
1896
  var once = require_once();
1897
1897
  var eos = require_end_of_stream();
1898
1898
  var fs13;
@@ -1902,7 +1902,7 @@ var require_pump = __commonJS({
1902
1902
  }
1903
1903
  var noop = function() {
1904
1904
  };
1905
- var ancient = /^v?\.0/.test(process.version);
1905
+ var ancient = typeof process === "undefined" ? false : /^v?\.0/.test(process.version);
1906
1906
  var isFn = function(fn) {
1907
1907
  return typeof fn === "function";
1908
1908
  };
@@ -3231,7 +3231,7 @@ var import_fs14 = __toESM(require("fs"));
3231
3231
  var import_path14 = require("path");
3232
3232
 
3233
3233
  // src/package-versions.ts
3234
- var VERCEL_RUNTIME_VERSION = "0.14.1";
3234
+ var VERCEL_RUNTIME_VERSION = "0.14.2";
3235
3235
  var VERCEL_WORKERS_VERSION = "0.0.24";
3236
3236
 
3237
3237
  // src/index.ts
@@ -4507,6 +4507,7 @@ async function runCompileAll({
4507
4507
  "-q",
4508
4508
  "-j",
4509
4509
  "0",
4510
+ "-f",
4510
4511
  "--invalidation-mode",
4511
4512
  "unchecked-hash",
4512
4513
  ...excludeRegex ? ["-x", excludeRegex] : [],
@@ -6355,166 +6356,47 @@ async function runSync({
6355
6356
  });
6356
6357
  });
6357
6358
  }
6358
- var PENDING_RUNTIME_INSTALLS = /* @__PURE__ */ new Map();
6359
- var PENDING_WORKERS_INSTALLS = /* @__PURE__ */ new Map();
6360
- async function installVercelRuntime({
6361
- workPath,
6362
- uvPath,
6363
- pythonBin,
6364
- env,
6365
- onStdout,
6366
- onStderr
6367
- }) {
6368
- const targetDir = (0, import_path10.join)(workPath, ".vercel", "python");
6369
- let pending = PENDING_RUNTIME_INSTALLS.get(targetDir);
6370
- if (!pending) {
6371
- pending = doInstallVercelRuntime({
6372
- targetDir,
6373
- workPath,
6374
- uvPath,
6375
- pythonBin,
6376
- env,
6377
- onStdout,
6378
- onStderr
6379
- });
6380
- PENDING_RUNTIME_INSTALLS.set(targetDir, pending);
6381
- pending.finally(() => PENDING_RUNTIME_INSTALLS.delete(targetDir));
6382
- }
6383
- await pending;
6384
- }
6385
- async function doInstallVercelRuntime({
6386
- targetDir,
6387
- workPath,
6388
- uvPath,
6389
- pythonBin,
6390
- env,
6391
- onStdout,
6392
- onStderr
6393
- }) {
6394
- (0, import_fs10.mkdirSync)(targetDir, { recursive: true });
6395
- const localRuntimeDir = (0, import_path10.join)(
6396
- __dirname,
6397
- "..",
6398
- "..",
6399
- "..",
6400
- "python",
6401
- "vercel-runtime"
6402
- );
6403
- const isLocalDev = (0, import_fs10.existsSync)((0, import_path10.join)(localRuntimeDir, "pyproject.toml"));
6404
- const runtimeDep = env.VERCEL_RUNTIME_PYTHON || (isLocalDev ? localRuntimeDir : `vercel-runtime==${VERCEL_RUNTIME_VERSION}`);
6405
- if (!isLocalDev && !env.VERCEL_RUNTIME_PYTHON) {
6406
- const distInfo = (0, import_path10.join)(
6407
- targetDir,
6408
- `vercel_runtime-${VERCEL_RUNTIME_VERSION}.dist-info`
6409
- );
6410
- if ((0, import_fs10.existsSync)(distInfo)) {
6411
- (0, import_build_utils13.debug)(
6412
- `vercel-runtime ${VERCEL_RUNTIME_VERSION} already installed, skipping`
6413
- );
6414
- return;
6415
- }
6416
- }
6417
- (0, import_build_utils13.debug)(
6418
- `Installing vercel-runtime into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${runtimeDep})`
6419
- );
6420
- const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
6421
- const spawnArgs = [...pip.prefix, "--target", targetDir, runtimeDep];
6422
- await new Promise((resolve3, reject) => {
6423
- const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
6424
- cwd: workPath,
6425
- env: getProtectedUvEnv(env),
6426
- stdio: ["inherit", "pipe", "pipe"]
6427
- });
6428
- child.stdout?.on("data", (data) => {
6429
- if (onStdout) {
6430
- onStdout(data);
6431
- } else {
6432
- (0, import_build_utils13.debug)(data.toString());
6433
- }
6434
- });
6435
- child.stderr?.on("data", (data) => {
6436
- if (onStderr) {
6437
- onStderr(data);
6438
- } else {
6439
- (0, import_build_utils13.debug)(data.toString());
6440
- }
6441
- });
6442
- child.on("error", reject);
6443
- child.on("exit", (code, signal) => {
6444
- if (code === 0) {
6445
- resolve3();
6446
- } else {
6447
- reject(
6448
- new Error(
6449
- `Installing vercel-runtime failed with code ${code}, signal ${signal}`
6450
- )
6451
- );
6452
- }
6453
- });
6454
- });
6455
- }
6456
- async function installVercelWorkers({
6457
- workPath,
6458
- uvPath,
6459
- pythonBin,
6460
- env,
6461
- onStdout,
6462
- onStderr
6463
- }) {
6464
- const targetDir = (0, import_path10.join)(workPath, ".vercel", "python");
6465
- let pending = PENDING_WORKERS_INSTALLS.get(targetDir);
6359
+ var PENDING_INSTALLS = /* @__PURE__ */ new Map();
6360
+ async function installInjectedDevPackage(pkg, opts) {
6361
+ const targetDir = (0, import_path10.join)(opts.workPath, ".vercel", "python");
6362
+ const key = `${targetDir}:${pkg.name}`;
6363
+ let pending = PENDING_INSTALLS.get(key);
6466
6364
  if (!pending) {
6467
- pending = doInstallVercelWorkers({
6468
- targetDir,
6469
- workPath,
6470
- uvPath,
6471
- pythonBin,
6472
- env,
6473
- onStdout,
6474
- onStderr
6475
- });
6476
- PENDING_WORKERS_INSTALLS.set(targetDir, pending);
6477
- pending.finally(() => PENDING_WORKERS_INSTALLS.delete(targetDir));
6365
+ pending = doInstallInjectedDevPackage(pkg, { ...opts, targetDir });
6366
+ PENDING_INSTALLS.set(key, pending);
6367
+ pending.finally(() => PENDING_INSTALLS.delete(key));
6478
6368
  }
6479
6369
  await pending;
6480
6370
  }
6481
- async function doInstallVercelWorkers({
6482
- targetDir,
6483
- workPath,
6484
- uvPath,
6485
- pythonBin,
6486
- env,
6487
- onStdout,
6488
- onStderr
6489
- }) {
6371
+ async function doInstallInjectedDevPackage(pkg, opts) {
6372
+ const { targetDir, workPath, uvPath, pythonBin, env, onStdout, onStderr } = opts;
6490
6373
  (0, import_fs10.mkdirSync)(targetDir, { recursive: true });
6491
- const localWorkersDir = (0, import_path10.join)(
6492
- __dirname,
6493
- "..",
6494
- "..",
6495
- "..",
6496
- "python",
6497
- "vercel-workers"
6498
- );
6499
- const isLocalDev = (0, import_fs10.existsSync)((0, import_path10.join)(localWorkersDir, "pyproject.toml"));
6500
- const workersDep = env.VERCEL_WORKERS_PYTHON || (isLocalDev ? localWorkersDir : `vercel-workers==${VERCEL_WORKERS_VERSION}`);
6501
- if (!isLocalDev && !env.VERCEL_WORKERS_PYTHON) {
6374
+ const localDir = (0, import_path10.join)(__dirname, "..", "..", "..", "python", pkg.name);
6375
+ const isLocalDev = (0, import_fs10.existsSync)((0, import_path10.join)(localDir, "pyproject.toml"));
6376
+ const dep = pkg.envOverride || (isLocalDev ? localDir : `${pkg.name}==${pkg.pinnedVersion}`);
6377
+ if (!isLocalDev && !pkg.envOverride) {
6378
+ const distInfoName = pkg.name.replace("-", "_");
6502
6379
  const distInfo = (0, import_path10.join)(
6503
6380
  targetDir,
6504
- `vercel_workers-${VERCEL_WORKERS_VERSION}.dist-info`
6381
+ `${distInfoName}-${pkg.pinnedVersion}.dist-info`
6505
6382
  );
6506
6383
  if ((0, import_fs10.existsSync)(distInfo)) {
6507
- (0, import_build_utils13.debug)(
6508
- `vercel-workers ${VERCEL_WORKERS_VERSION} already installed, skipping`
6509
- );
6384
+ (0, import_build_utils13.debug)(`${pkg.name} ${pkg.pinnedVersion} already installed, skipping`);
6510
6385
  return;
6511
6386
  }
6512
6387
  }
6513
6388
  (0, import_build_utils13.debug)(
6514
- `Installing vercel-workers into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${workersDep})`
6389
+ `Installing ${pkg.name} into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${dep})`
6515
6390
  );
6516
6391
  const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
6517
- const spawnArgs = [...pip.prefix, "--target", targetDir, workersDep];
6392
+ const excludeOverride = uvPath ? ["--exclude-newer-package", `${pkg.name}=false`] : [];
6393
+ const spawnArgs = [
6394
+ ...pip.prefix,
6395
+ "--target",
6396
+ targetDir,
6397
+ ...excludeOverride,
6398
+ dep
6399
+ ];
6518
6400
  await new Promise((resolve3, reject) => {
6519
6401
  const child = (0, import_child_process2.spawn)(pip.cmd, spawnArgs, {
6520
6402
  cwd: workPath,
@@ -6542,7 +6424,7 @@ async function doInstallVercelWorkers({
6542
6424
  } else {
6543
6425
  reject(
6544
6426
  new Error(
6545
- `Installing vercel-workers failed with code ${code}, signal ${signal}`
6427
+ `Installing ${pkg.name} failed with code ${code}, signal ${signal}`
6546
6428
  )
6547
6429
  );
6548
6430
  }
@@ -6789,6 +6671,14 @@ If you are using a virtual environment, activate it before running "vercel dev",
6789
6671
  }
6790
6672
  }
6791
6673
  }
6674
+ const devOpts = {
6675
+ workPath,
6676
+ uvPath,
6677
+ pythonBin: spawnCommand,
6678
+ env,
6679
+ onStdout,
6680
+ onStderr
6681
+ };
6792
6682
  if (meta.syncDependencies) {
6793
6683
  const gray = "\x1B[90m";
6794
6684
  const reset = "\x1B[0m";
@@ -6799,30 +6689,25 @@ If you are using a virtual environment, activate it before running "vercel dev",
6799
6689
  } else {
6800
6690
  console.log(syncMessage);
6801
6691
  }
6802
- await syncDependencies({
6803
- workPath,
6804
- uvPath,
6805
- pythonBin: spawnCommand,
6806
- env,
6807
- onStdout,
6808
- onStderr
6809
- });
6692
+ await syncDependencies(devOpts);
6810
6693
  }
6811
- await installVercelRuntime({
6812
- workPath,
6813
- uvPath,
6814
- pythonBin: spawnCommand,
6815
- env
6816
- });
6694
+ await installInjectedDevPackage(
6695
+ {
6696
+ name: "vercel-runtime",
6697
+ pinnedVersion: VERCEL_RUNTIME_VERSION,
6698
+ envOverride: env.VERCEL_RUNTIME_PYTHON
6699
+ },
6700
+ devOpts
6701
+ );
6817
6702
  if (hasWorkerServicesEnabled(env)) {
6818
- await installVercelWorkers({
6819
- workPath,
6820
- uvPath,
6821
- pythonBin: spawnCommand,
6822
- env,
6823
- onStdout,
6824
- onStderr
6825
- });
6703
+ await installInjectedDevPackage(
6704
+ {
6705
+ name: "vercel-workers",
6706
+ pinnedVersion: VERCEL_WORKERS_VERSION,
6707
+ envOverride: env.VERCEL_WORKERS_PYTHON
6708
+ },
6709
+ devOpts
6710
+ );
6826
6711
  }
6827
6712
  const crons = await getServiceCrons({
6828
6713
  service,
@@ -7664,6 +7549,33 @@ function getTargetPlatform(isDev) {
7664
7549
  }
7665
7550
  return { uvPlatform: UV_LINUX_TARGET, architecture: "x86_64" };
7666
7551
  }
7552
+ async function installInjectedPackage({
7553
+ name,
7554
+ pinned,
7555
+ envOverride,
7556
+ uv,
7557
+ venvPath,
7558
+ projectDir,
7559
+ pipPlatformArgs
7560
+ }) {
7561
+ const localDir = (0, import_path14.join)(__dirname, "..", "..", "..", "python", name);
7562
+ const isLocalDev = import_fs14.default.existsSync((0, import_path14.join)(localDir, "pyproject.toml"));
7563
+ const dep = envOverride || (isLocalDev ? localDir : pinned);
7564
+ const noExclude = ["--exclude-newer-package", `${name}=false`];
7565
+ (0, import_build_utils18.debug)(`Installing ${dep}`);
7566
+ await uv.pip({
7567
+ venvPath,
7568
+ projectDir,
7569
+ args: [
7570
+ "install",
7571
+ "--link-mode",
7572
+ "copy",
7573
+ ...pipPlatformArgs,
7574
+ ...noExclude,
7575
+ dep
7576
+ ]
7577
+ });
7578
+ }
7667
7579
  var build = async ({
7668
7580
  workPath,
7669
7581
  repoRootPath,
@@ -7914,21 +7826,25 @@ var build = async ({
7914
7826
  });
7915
7827
  }
7916
7828
  const djangoStatic = hookResult?.djangoStatic ?? null;
7917
- const runtimeDep = baseEnv.VERCEL_RUNTIME_PYTHON || `vercel-runtime==${VERCEL_RUNTIME_VERSION}`;
7918
- (0, import_build_utils18.debug)(`Installing ${runtimeDep}`);
7919
7829
  const pipPlatformArgs = target.uvPlatform ? ["--python-platform", target.uvPlatform] : [];
7920
- await uv.pip({
7830
+ await installInjectedPackage({
7831
+ name: "vercel-runtime",
7832
+ pinned: `vercel-runtime==${VERCEL_RUNTIME_VERSION}`,
7833
+ envOverride: baseEnv.VERCEL_RUNTIME_PYTHON,
7834
+ uv,
7921
7835
  venvPath,
7922
7836
  projectDir: (0, import_path14.join)(workPath, entryDirectory),
7923
- args: ["install", "--link-mode", "copy", ...pipPlatformArgs, runtimeDep]
7837
+ pipPlatformArgs
7924
7838
  });
7925
7839
  if (shouldInstallVercelWorkers) {
7926
- const workersDep = baseEnv.VERCEL_WORKERS_PYTHON || `vercel-workers==${VERCEL_WORKERS_VERSION}`;
7927
- (0, import_build_utils18.debug)(`Installing ${workersDep}`);
7928
- await uv.pip({
7840
+ await installInjectedPackage({
7841
+ name: "vercel-workers",
7842
+ pinned: `vercel-workers==${VERCEL_WORKERS_VERSION}`,
7843
+ envOverride: baseEnv.VERCEL_WORKERS_PYTHON,
7844
+ uv,
7929
7845
  venvPath,
7930
7846
  projectDir: (0, import_path14.join)(workPath, entryDirectory),
7931
- args: ["install", "--link-mode", "copy", ...pipPlatformArgs, workersDep]
7847
+ pipPlatformArgs
7932
7848
  });
7933
7849
  }
7934
7850
  const quirksResult = await runQuirks({ venvPath, pythonEnv, workPath });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.44.0",
3
+ "version": "6.45.0",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -34,9 +34,9 @@
34
34
  "smol-toml": "1.5.2",
35
35
  "vitest": "2.1.4",
36
36
  "which": "3.0.0",
37
- "@vercel/build-utils": "13.26.4",
38
- "@vercel/python-runtime": "0.14.1",
39
- "@vercel/error-utils": "2.1.0"
37
+ "@vercel/build-utils": "13.30.0",
38
+ "@vercel/error-utils": "2.2.0",
39
+ "@vercel/python-runtime": "0.14.2"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "node ../../utils/build-builder.mjs",