@vercel/python 6.36.1 → 6.37.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 +27 -12
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -5302,15 +5302,8 @@ async function checkEntrypoint(workPath, relPath) {
5302
5302
  const content = await import_fs8.default.promises.readFile(absPath, "utf-8");
5303
5303
  return (0, import_python_analysis5.findAppOrHandler)(content);
5304
5304
  }
5305
- async function getPyprojectEntrypoint(workPath) {
5306
- const pyprojectData = await (0, import_build_utils10.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
5307
- if (!pyprojectData)
5308
- return null;
5309
- const scripts = pyprojectData.project?.scripts;
5310
- const appScript = scripts?.app;
5311
- if (typeof appScript !== "string")
5312
- return null;
5313
- const match = appScript.match(/([A-Za-z_][\w.]*)\s*:\s*([A-Za-z_][\w]*)/);
5305
+ async function resolveModuleAttrEntrypoint(workPath, value) {
5306
+ const match = value.match(/([A-Za-z_][\w.]*)\s*:\s*([A-Za-z_][\w]*)/);
5314
5307
  if (!match)
5315
5308
  return null;
5316
5309
  const modulePath = match[1];
@@ -5324,6 +5317,25 @@ async function getPyprojectEntrypoint(workPath) {
5324
5317
  }
5325
5318
  return null;
5326
5319
  }
5320
+ async function getVercelToolsEntrypoint(workPath) {
5321
+ const pyprojectData = await (0, import_build_utils10.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
5322
+ if (!pyprojectData)
5323
+ return null;
5324
+ const vercelEntrypoint = pyprojectData.tool?.vercel?.entrypoint;
5325
+ if (typeof vercelEntrypoint !== "string")
5326
+ return null;
5327
+ return resolveModuleAttrEntrypoint(workPath, vercelEntrypoint);
5328
+ }
5329
+ async function getPyprojectScriptsEntrypoint(workPath) {
5330
+ const pyprojectData = await (0, import_build_utils10.readConfigFile)((0, import_path8.join)(workPath, "pyproject.toml"));
5331
+ if (!pyprojectData)
5332
+ return null;
5333
+ const scripts = pyprojectData.project?.scripts;
5334
+ const appScript = scripts?.app;
5335
+ if (typeof appScript !== "string")
5336
+ return null;
5337
+ return resolveModuleAttrEntrypoint(workPath, appScript);
5338
+ }
5327
5339
  async function findValidEntrypoint(workPath, candidates) {
5328
5340
  for (const candidate of candidates) {
5329
5341
  const varName = await checkEntrypoint(workPath, candidate);
@@ -5360,7 +5372,7 @@ function makeDetectError(framework) {
5360
5372
  const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(", ");
5361
5373
  return new import_build_utils8.NowBuildError({
5362
5374
  code: `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`,
5363
- message: `No ${framework} entrypoint found. Add an 'app' script in pyproject.toml or define an entrypoint in one of: ${searchedList}.`,
5375
+ message: `No ${framework} entrypoint found. Set \`tool.vercel.entrypoint\` in pyproject.toml or define an entrypoint in one of: ${searchedList}.`,
5364
5376
  link: `https://vercel.com/docs/frameworks/backend/${framework}#exporting-the-${framework}-application`,
5365
5377
  action: "Learn More"
5366
5378
  });
@@ -5424,11 +5436,14 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint,
5424
5436
  if (!framework) {
5425
5437
  return null;
5426
5438
  }
5439
+ const vercelEntry = await getVercelToolsEntrypoint(workPath);
5440
+ if (vercelEntry)
5441
+ return { entrypoint: vercelEntry };
5427
5442
  const result = framework === "django" ? await detectDjangoPythonEntrypoint(workPath) : await detectGenericPythonEntrypoint(workPath);
5428
5443
  if (result)
5429
5444
  return result;
5430
- const pyprojectEntry = await getPyprojectEntrypoint(workPath);
5431
- return pyprojectEntry ? { entrypoint: pyprojectEntry } : { error: makeDetectError(framework) };
5445
+ const scriptsEntry = await getPyprojectScriptsEntrypoint(workPath);
5446
+ return scriptsEntry ? { entrypoint: scriptsEntry } : { error: makeDetectError(framework) };
5432
5447
  }
5433
5448
 
5434
5449
  // src/start-dev-server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.36.1",
3
+ "version": "6.37.0",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -15,7 +15,7 @@
15
15
  "directory": "packages/python"
16
16
  },
17
17
  "dependencies": {
18
- "@vercel/python-analysis": "0.11.0"
18
+ "@vercel/python-analysis": "0.11.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@renovatebot/pep440": "4.2.1",
@@ -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.20.0",
40
39
  "@vercel/python-runtime": "0.13.1",
41
- "@vercel/error-utils": "2.0.3"
40
+ "@vercel/build-utils": "13.21.0",
41
+ "@vercel/error-utils": "2.1.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "node ../../utils/build-builder.mjs",