@vercel/python 6.2.1 → 6.3.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 +58 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4401,6 +4401,7 @@ var build = async ({
|
|
|
4401
4401
|
venvPath
|
|
4402
4402
|
});
|
|
4403
4403
|
const hasCustomInstallCommand = (0, import_build_utils7.isPythonFramework)(framework) && !!projectInstallCommand;
|
|
4404
|
+
let useRuntime = false;
|
|
4404
4405
|
if (hasCustomInstallCommand) {
|
|
4405
4406
|
const baseEnv = spawnEnv || process.env;
|
|
4406
4407
|
const pythonEnv = createVenvEnv(venvPath, baseEnv);
|
|
@@ -4436,7 +4437,18 @@ var build = async ({
|
|
|
4436
4437
|
`uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
|
|
4437
4438
|
);
|
|
4438
4439
|
}
|
|
4439
|
-
const
|
|
4440
|
+
const baseEnv = spawnEnv || process.env;
|
|
4441
|
+
useRuntime = !!baseEnv.VERCEL_RUNTIME_PYTHON_ENABLED;
|
|
4442
|
+
const runtimeDependencies = [];
|
|
4443
|
+
if (useRuntime) {
|
|
4444
|
+
runtimeDependencies.push(
|
|
4445
|
+
baseEnv.VERCEL_RUNTIME_PYTHON || "vercel-runtime==0.1.0"
|
|
4446
|
+
);
|
|
4447
|
+
}
|
|
4448
|
+
runtimeDependencies.push("werkzeug>=1.0.1");
|
|
4449
|
+
if (framework !== "flask") {
|
|
4450
|
+
runtimeDependencies.push("uvicorn>=0.24");
|
|
4451
|
+
}
|
|
4440
4452
|
const { projectDir } = await ensureUvProject({
|
|
4441
4453
|
workPath,
|
|
4442
4454
|
entryDirectory,
|
|
@@ -4457,15 +4469,57 @@ var build = async ({
|
|
|
4457
4469
|
});
|
|
4458
4470
|
}
|
|
4459
4471
|
}
|
|
4460
|
-
const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
|
|
4461
|
-
const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
|
|
4462
4472
|
(0, import_build_utils7.debug)("Entrypoint is", entrypoint);
|
|
4463
4473
|
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
|
|
4464
4474
|
const vendorDir = resolveVendorDir();
|
|
4465
4475
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
4466
4476
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
4467
4477
|
(0, import_build_utils7.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
4468
|
-
|
|
4478
|
+
let handlerPyContents;
|
|
4479
|
+
if (useRuntime) {
|
|
4480
|
+
handlerPyContents = `
|
|
4481
|
+
import importlib
|
|
4482
|
+
import os
|
|
4483
|
+
import os.path
|
|
4484
|
+
import site
|
|
4485
|
+
import sys
|
|
4486
|
+
|
|
4487
|
+
_here = os.path.dirname(__file__)
|
|
4488
|
+
|
|
4489
|
+
os.environ.update({
|
|
4490
|
+
"__VC_HANDLER_MODULE_NAME": "${moduleName}",
|
|
4491
|
+
"__VC_HANDLER_ENTRYPOINT": "${entrypointWithSuffix}",
|
|
4492
|
+
"__VC_HANDLER_ENTRYPOINT_ABS": os.path.join(_here, "${entrypointWithSuffix}"),
|
|
4493
|
+
"__VC_HANDLER_VENDOR_DIR": "${vendorDir}",
|
|
4494
|
+
})
|
|
4495
|
+
|
|
4496
|
+
_vendor_rel = '${vendorDir}'
|
|
4497
|
+
_vendor = os.path.normpath(os.path.join(_here, _vendor_rel))
|
|
4498
|
+
|
|
4499
|
+
if os.path.isdir(_vendor):
|
|
4500
|
+
# Process .pth files like a real site-packages dir
|
|
4501
|
+
site.addsitedir(_vendor)
|
|
4502
|
+
|
|
4503
|
+
# Move _vendor to the front (after script dir if present)
|
|
4504
|
+
try:
|
|
4505
|
+
while _vendor in sys.path:
|
|
4506
|
+
sys.path.remove(_vendor)
|
|
4507
|
+
except ValueError:
|
|
4508
|
+
pass
|
|
4509
|
+
|
|
4510
|
+
# Put vendored deps ahead of site-packages but after the script dir
|
|
4511
|
+
idx = 1 if (sys.path and sys.path[0] in ('', _here)) else 0
|
|
4512
|
+
sys.path.insert(idx, _vendor)
|
|
4513
|
+
|
|
4514
|
+
importlib.invalidate_caches()
|
|
4515
|
+
|
|
4516
|
+
from vercel_runtime.vc_init import vc_handler
|
|
4517
|
+
`;
|
|
4518
|
+
} else {
|
|
4519
|
+
const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
|
|
4520
|
+
const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
|
|
4521
|
+
handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix).replace(/__VC_HANDLER_VENDOR_DIR/g, vendorDir);
|
|
4522
|
+
}
|
|
4469
4523
|
const predefinedExcludes = [
|
|
4470
4524
|
".git/**",
|
|
4471
4525
|
".gitignore",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@types/execa": "^0.9.0",
|
|
21
21
|
"@types/fs-extra": "11.0.2",
|
|
22
22
|
"@types/jest": "27.4.1",
|
|
23
|
-
"@types/node": "
|
|
23
|
+
"@types/node": "20.11.0",
|
|
24
24
|
"@types/which": "3.0.0",
|
|
25
25
|
"cross-env": "7.0.3",
|
|
26
26
|
"execa": "^1.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"pip-requirements-js": "1.0.2",
|
|
31
31
|
"smol-toml": "1.5.2",
|
|
32
32
|
"which": "3.0.0",
|
|
33
|
-
"@vercel/build-utils": "13.2.
|
|
33
|
+
"@vercel/build-utils": "13.2.14",
|
|
34
34
|
"@vercel/error-utils": "2.0.3"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|