@vercel/python 14.0.0 → 14.1.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.
package/dist/index.js CHANGED
@@ -3328,9 +3328,9 @@ var require_pep440 = __commonJS({
3328
3328
  var require_lib = __commonJS({
3329
3329
  "../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
3330
3330
  var isexe = require_isexe();
3331
- var { join: join21, delimiter: delimiter2, sep: sep6, posix } = require("path");
3331
+ var { join: join21, delimiter: delimiter2, sep: sep6, posix: posix4 } = require("path");
3332
3332
  var isWindows = process.platform === "win32";
3333
- var rSlash = new RegExp(`[${posix.sep}${sep6 === posix.sep ? "" : sep6}]`.replace(/(\\)/g, "\\$1"));
3333
+ var rSlash = new RegExp(`[${posix4.sep}${sep6 === posix4.sep ? "" : sep6}]`.replace(/(\\)/g, "\\$1"));
3334
3334
  var rRel = new RegExp(`^\\.${rSlash.source}`);
3335
3335
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
3336
3336
  var getPathInfo = (cmd, {
@@ -6640,7 +6640,7 @@ minimatch.unescape = unescape;
6640
6640
  var import_path21 = require("path");
6641
6641
 
6642
6642
  // src/package-versions.ts
6643
- var VERCEL_RUNTIME_VERSION = "0.22.1";
6643
+ var VERCEL_RUNTIME_VERSION = "0.23.0";
6644
6644
  var VERCEL_WORKERS_VERSION = "0.0.25";
6645
6645
 
6646
6646
  // src/conditional-vendoring.ts
@@ -10864,6 +10864,9 @@ function installGlobalCleanupHandlers() {
10864
10864
  killAll();
10865
10865
  });
10866
10866
  }
10867
+ function escapePythonStringContents(value) {
10868
+ return JSON.stringify(value).slice(1, -1);
10869
+ }
10867
10870
  function createDevShim(workPath, entry, modulePath, serviceName, framework, variableName) {
10868
10871
  try {
10869
10872
  const vercelPythonDir = serviceName ? (0, import_path13.join)(workPath, ".vercel", "python", "services", serviceName) : (0, import_path13.join)(workPath, ".vercel", "python");
@@ -10875,7 +10878,7 @@ function createDevShim(workPath, entry, modulePath, serviceName, framework, vari
10875
10878
  qualifiedModule = `${pkgName}.${modulePath}`;
10876
10879
  extraPythonPath = (0, import_path13.dirname)(workPath);
10877
10880
  }
10878
- const entryAbs = (0, import_path13.join)(workPath, entry);
10881
+ const entryAbs = import_path13.posix.join(workPath.replace(/\\/g, "/"), entry);
10879
10882
  const shimPath = (0, import_path13.join)(vercelPythonDir, `${DEV_SHIM_MODULE}.py`);
10880
10883
  const templatePath = (0, import_path13.join)(
10881
10884
  __dirname,
@@ -10884,7 +10887,13 @@ function createDevShim(workPath, entry, modulePath, serviceName, framework, vari
10884
10887
  `${DEV_SHIM_MODULE}.py`
10885
10888
  );
10886
10889
  const template = (0, import_fs13.readFileSync)(templatePath, "utf8");
10887
- 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);
10890
+ const shimSource = template.replace(
10891
+ /__VC_DEV_MODULE_NAME__/g,
10892
+ escapePythonStringContents(qualifiedModule)
10893
+ ).replace(/__VC_DEV_ENTRY_ABS__/g, escapePythonStringContents(entryAbs)).replace(/__VC_DEV_FRAMEWORK__/g, escapePythonStringContents(framework)).replace(
10894
+ /__VC_DEV_VARIABLE_NAME__/g,
10895
+ escapePythonStringContents(variableName)
10896
+ );
10888
10897
  (0, import_fs13.writeFileSync)(shimPath, shimSource, "utf8");
10889
10898
  (0, import_build_utils15.debug)(`Prepared Python dev shim at ${shimPath}`);
10890
10899
  return {
@@ -11418,7 +11427,7 @@ var litellmQuirk = {
11418
11427
  if (configName) {
11419
11428
  (0, import_build_utils16.debug)(`LiteLLM quirk: found config at ${configName}`);
11420
11429
  buildEnv.CONFIG_FILE_PATH = (0, import_path14.join)(ctx.workPath, configName);
11421
- env.CONFIG_FILE_PATH = (0, import_path14.join)(LAMBDA_ROOT, configName);
11430
+ env.CONFIG_FILE_PATH = import_path14.posix.join(LAMBDA_ROOT, configName);
11422
11431
  }
11423
11432
  } else {
11424
11433
  (0, import_build_utils16.debug)(
@@ -11546,7 +11555,7 @@ var prismaQuirk = {
11546
11555
  async run(ctx) {
11547
11556
  const { venvPath, pythonEnv, workPath } = ctx;
11548
11557
  const pythonPath = getVenvPythonBin(venvPath);
11549
- const runtimeCacheDir = (0, import_path15.join)(
11558
+ const runtimeCacheDir = import_path15.posix.join(
11550
11559
  LAMBDA_ROOT2,
11551
11560
  resolveVendorDir(),
11552
11561
  "prisma",
@@ -14373,7 +14382,8 @@ var build = async ({
14373
14382
  ...shadowingRoutes,
14374
14383
  { handle: "filesystem" },
14375
14384
  ...queueRoutes,
14376
- ...fallbackRoutes,
14385
+ ...fallbackRoutes.length > 0 ? [{ handle: "miss" }, ...fallbackRoutes] : [],
14386
+ { handle: "rewrite" },
14377
14387
  // This route matches the resolved destination after rewrites. Copy
14378
14388
  // that path into the runtime request before dispatching the shared
14379
14389
  // framework Lambda so application routing observes the rewrite.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "14.0.0",
3
+ "version": "14.1.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -17,7 +17,7 @@
17
17
  "@vercel/python-analysis": "0.14.0"
18
18
  },
19
19
  "peerDependencies": {
20
- "@vercel/build-utils": "14.10.0"
20
+ "@vercel/build-utils": "14.10.1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@renovatebot/pep440": "4.2.1",
@@ -38,9 +38,9 @@
38
38
  "smol-toml": "1.5.2",
39
39
  "vitest": "4.1.10",
40
40
  "which": "3.0.0",
41
- "@vercel/build-utils": "14.10.0",
41
+ "@vercel/build-utils": "14.10.1",
42
42
  "@vercel/error-utils": "2.2.1",
43
- "@vercel/python-runtime": "0.22.1"
43
+ "@vercel/python-runtime": "0.23.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "node ../../utils/build-builder.mjs",
@@ -527,6 +527,9 @@ def collect(
527
527
  # app.include_router() with a frontend build.
528
528
  for ctx in _effective_low_priority_routes(route):
529
529
  if suppress_middleware_mounts and (_frontend_has_dependencies(ctx) or has_middleware):
530
+ shadow_prefix = prefix + ctx.frontend_prefix
531
+ sub_mounts = [s for s in mounts if s.urlPath.startswith(shadow_prefix.rstrip("/") + "/")]
532
+ shadow_routes.append(_subtree_shadow_route(shadow_prefix, sub_mounts))
530
533
  continue
531
534
  for r in ctx.original_route.routes:
532
535
  if m := StaticMount.from_route(
@@ -534,13 +537,22 @@ def collect(
534
537
  ):
535
538
  frontends.append(m)
536
539
 
537
- # app.frontend() builds.
540
+ # app.frontend() builds. Prepend so own frontends sort before included ones,
541
+ # matching _iter_low_priority_routes. Own wins any same-prefix tie.
542
+ own_frontends: list[StaticMount] = []
538
543
  for group in _frontend_groups(router):
539
544
  if suppress_middleware_mounts and (_frontend_has_dependencies(group) or has_middleware):
545
+ for route in group.routes:
546
+ if m := StaticMount.from_route(route, prefix, frontend=True):
547
+ shadow_prefix = m.urlPath.rstrip("/")
548
+ sub_mounts = [s for s in mounts if s.urlPath.startswith(shadow_prefix.rstrip("/") + "/")]
549
+ shadow_routes.append(_subtree_shadow_route(shadow_prefix, sub_mounts))
550
+ break
540
551
  continue
541
552
  for route in group.routes:
542
553
  if m := StaticMount.from_route(route, prefix, frontend=True):
543
- frontends.append(m)
554
+ own_frontends.append(m)
555
+ frontends = own_frontends + frontends
544
556
 
545
557
  # A frontend is low-priority: every route shadows it, and one whose prefix
546
558
  # an earlier mount owns is unreachable (Starlette dispatches to the mount