@vercel/python 32.0.2 → 32.1.0-snapshot-3c6877870fc7

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 +39 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -5055,7 +5055,7 @@ var import_fs22 = __toESM(require("fs"));
5055
5055
  var import_path23 = require("path");
5056
5056
 
5057
5057
  // src/package-versions.ts
5058
- var VERCEL_RUNTIME_VERSION = "0.25.1";
5058
+ var VERCEL_RUNTIME_VERSION = "0.26.0";
5059
5059
  var VERCEL_WORKERS_VERSION = "0.0.25";
5060
5060
 
5061
5061
  // src/conditional-vendoring.ts
@@ -6045,6 +6045,27 @@ async function runPyprojectScript(workPath, scriptNames, env, useUserVirtualEnv
6045
6045
  }
6046
6046
  return false;
6047
6047
  }
6048
+ var ASYNC_LIBRARIES = ["asyncio", "trio"];
6049
+ async function getPyprojectAsyncLibrary(workPath) {
6050
+ const pyprojectPath = (0, import_path4.join)(workPath, "pyproject.toml");
6051
+ if (!import_fs3.default.existsSync(pyprojectPath)) {
6052
+ return void 0;
6053
+ }
6054
+ const pyproject = await (0, import_build_utils3.readConfigFile)(pyprojectPath);
6055
+ const asyncLibrary = pyproject?.tool?.vercel?.async_library;
6056
+ if (asyncLibrary === void 0) {
6057
+ return void 0;
6058
+ }
6059
+ if (!ASYNC_LIBRARIES.some((library) => library === asyncLibrary)) {
6060
+ throw new import_build_utils3.NowBuildError({
6061
+ code: "PYTHON_INVALID_ASYNC_LIBRARY",
6062
+ message: `"tool.vercel.async_library" must be one of ${ASYNC_LIBRARIES.map(
6063
+ (library) => `"${library}"`
6064
+ ).join(", ")}, got ${JSON.stringify(asyncLibrary)}`
6065
+ });
6066
+ }
6067
+ return asyncLibrary;
6068
+ }
6048
6069
 
6049
6070
  // src/version.ts
6050
6071
  var import_path5 = require("path");
@@ -11481,6 +11502,12 @@ If you are using a virtual environment, activate it before running "vercel dev",
11481
11502
  delete env.VERCEL_APSCHEDULER_SUBSCRIBERS;
11482
11503
  delete env.VERCEL_APSCHEDULER_PREVIEW_IDLE_TIMEOUT_SECONDS;
11483
11504
  }
11505
+ const asyncLibrary = await getPyprojectAsyncLibrary(workPath);
11506
+ if (asyncLibrary) {
11507
+ env.__VC_ASYNC_LIBRARY = asyncLibrary;
11508
+ } else {
11509
+ delete env.__VC_ASYNC_LIBRARY;
11510
+ }
11484
11511
  if (legacyProject) {
11485
11512
  await installInjectedDevPackage(
11486
11513
  {
@@ -14434,6 +14461,8 @@ var build = async ({
14434
14461
  });
14435
14462
  }
14436
14463
  const vendorDir = resolveVendorDir();
14464
+ const asyncLibrary = await getPyprojectAsyncLibrary(workPath);
14465
+ const asyncLibraryTrampolineEnv = asyncLibrary ? [`"__VC_ASYNC_LIBRARY": "${asyncLibrary}"`] : [];
14437
14466
  let crons;
14438
14467
  let runtimeTrampoline;
14439
14468
  if (entrypoint) {
@@ -14463,7 +14492,7 @@ var build = async ({
14463
14492
  env: pythonEnv,
14464
14493
  workPath
14465
14494
  });
14466
- const extraTrampolineEnv = [];
14495
+ const extraTrampolineEnv = [...asyncLibraryTrampolineEnv];
14467
14496
  if (crons?.length) {
14468
14497
  const json = JSON.stringify(buildCronRouteTable(crons));
14469
14498
  (0, import_assert.default)(!json.includes("\\"), `backslash in cron route table: ${json}`);
@@ -14574,6 +14603,12 @@ var build = async ({
14574
14603
  },
14575
14604
  largeFunctionLabel: entrypoint ?? rawEntrypoint
14576
14605
  });
14606
+ if (asyncLibrary === "trio" && installedDistributions.getInstalledVersion("trio") === null) {
14607
+ throw new import_build_utils26.NowBuildError({
14608
+ code: "PYTHON_ASYNC_LIBRARY_NOT_INSTALLED",
14609
+ message: `"tool.vercel.async_library" is "trio", but "trio" is not installed. Add "trio" to your project's dependencies.`
14610
+ });
14611
+ }
14577
14612
  if (pycachePrefix) {
14578
14613
  lambdaEnv.PYTHONPYCACHEPREFIX = pycachePrefix;
14579
14614
  }
@@ -14777,7 +14812,8 @@ var build = async ({
14777
14812
  ),
14778
14813
  entrypoint: GENERATED_SCHEDULE_HANDLER_PATH,
14779
14814
  vendorDir,
14780
- variableName: "app"
14815
+ variableName: "app",
14816
+ extraEnv: asyncLibraryTrampolineEnv
14781
14817
  })
14782
14818
  });
14783
14819
  const output2 = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "32.0.2",
3
+ "version": "32.1.0-snapshot-3c6877870fc7",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -38,8 +38,8 @@
38
38
  "vitest": "4.1.10",
39
39
  "which": "3.0.0",
40
40
  "@vercel/build-utils": "15.4.2",
41
- "@vercel/error-utils": "2.2.1",
42
- "@vercel/python-runtime": "0.25.1"
41
+ "@vercel/python-runtime": "0.26.0",
42
+ "@vercel/error-utils": "2.2.1"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "node ../../utils/build-builder.mjs",