@vercel/python 7.0.0 → 9.0.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.
- package/dist/index.js +3 -2
- package/package.json +4 -4
- package/templates/vc_fastapi_static.py +17 -12
package/dist/index.js
CHANGED
|
@@ -5032,7 +5032,7 @@ var import_fs20 = __toESM(require("fs"));
|
|
|
5032
5032
|
var import_path21 = require("path");
|
|
5033
5033
|
|
|
5034
5034
|
// src/package-versions.ts
|
|
5035
|
-
var VERCEL_RUNTIME_VERSION = "0.
|
|
5035
|
+
var VERCEL_RUNTIME_VERSION = "0.22.1";
|
|
5036
5036
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
5037
5037
|
|
|
5038
5038
|
// src/conditional-vendoring.ts
|
|
@@ -10315,11 +10315,12 @@ async function getFastAPIStaticDiscovery(venvPath, entrypointAbs, variableName,
|
|
|
10315
10315
|
const pythonPath = getVenvPythonBin(venvPath);
|
|
10316
10316
|
const outputDir = (0, import_path17.join)(workPath, ".vercel", "python");
|
|
10317
10317
|
const outputPath = (0, import_path17.join)(outputDir, "vc_fastapi_static_output.json");
|
|
10318
|
+
const moduleName = entrypointToModule((0, import_path17.relative)(workPath, entrypointAbs));
|
|
10318
10319
|
await import_fs17.default.promises.mkdir(outputDir, { recursive: true });
|
|
10319
10320
|
try {
|
|
10320
10321
|
const { stderr } = await (0, import_execa9.default)(
|
|
10321
10322
|
pythonPath,
|
|
10322
|
-
[scriptPath3,
|
|
10323
|
+
[scriptPath3, variableName, outputPath, workPath, moduleName],
|
|
10323
10324
|
{ env, cwd: workPath }
|
|
10324
10325
|
);
|
|
10325
10326
|
if (stderr) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
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.
|
|
20
|
+
"@vercel/build-utils": "14.5.0"
|
|
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.
|
|
41
|
+
"@vercel/build-utils": "14.5.0",
|
|
42
42
|
"@vercel/error-utils": "2.2.1",
|
|
43
|
-
"@vercel/python-runtime": "0.
|
|
43
|
+
"@vercel/python-runtime": "0.22.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node ../../utils/build-builder.mjs",
|
|
@@ -25,12 +25,13 @@ Writes a JSON object to the output file:
|
|
|
25
25
|
* app.mount(): routes declared BEFORE the mount win (evaluated in order).
|
|
26
26
|
* app.frontend(): all normal routes win (the build is low-priority).
|
|
27
27
|
|
|
28
|
-
Usage:
|
|
28
|
+
Usage:
|
|
29
|
+
python <this_script> <variable_name> <output_path> <project_root> <module_name>
|
|
29
30
|
"""
|
|
30
31
|
|
|
31
32
|
from __future__ import annotations
|
|
32
33
|
|
|
33
|
-
import importlib
|
|
34
|
+
import importlib
|
|
34
35
|
import json
|
|
35
36
|
import os
|
|
36
37
|
import re
|
|
@@ -585,17 +586,21 @@ def write_output(output_path: str, discovery: Output) -> None:
|
|
|
585
586
|
json.dump(discovery.to_dict(), f)
|
|
586
587
|
|
|
587
588
|
|
|
588
|
-
def discover(
|
|
589
|
-
"""Import the entrypoint and walk its app's router
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
589
|
+
def discover(variable_name: str, project_root: str, module_name: str) -> Output:
|
|
590
|
+
"""Import the entrypoint as its real module and walk its app's router.
|
|
591
|
+
|
|
592
|
+
The project root is put on sys.path so importlib.import_module loads the
|
|
593
|
+
entrypoint by its dotted name (as the deployed runtime does), which is what
|
|
594
|
+
makes relative and first-party absolute imports resolve. Returns empty on
|
|
595
|
+
any failure.
|
|
596
|
+
"""
|
|
597
|
+
if project_root and project_root not in sys.path:
|
|
598
|
+
sys.path.insert(0, project_root)
|
|
593
599
|
|
|
594
|
-
mod = importlib.util.module_from_spec(spec)
|
|
595
600
|
try:
|
|
596
|
-
|
|
601
|
+
mod = importlib.import_module(module_name)
|
|
597
602
|
except Exception as exc:
|
|
598
|
-
print(f"vc_fastapi_static:
|
|
603
|
+
print(f"vc_fastapi_static: import failed: {exc}", file=sys.stderr)
|
|
599
604
|
return Output()
|
|
600
605
|
|
|
601
606
|
app = getattr(mod, variable_name, None)
|
|
@@ -608,8 +613,8 @@ def discover(entrypoint_abs: str, variable_name: str) -> Output:
|
|
|
608
613
|
|
|
609
614
|
|
|
610
615
|
def main() -> None:
|
|
611
|
-
|
|
612
|
-
write_output(output_path, discover(
|
|
616
|
+
variable_name, output_path, project_root, module_name = sys.argv[1:5]
|
|
617
|
+
write_output(output_path, discover(variable_name, project_root, module_name))
|
|
613
618
|
|
|
614
619
|
|
|
615
620
|
if __name__ == "__main__":
|