@vercel/python 17.0.2 → 19.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 +69 -54
- package/package.json +4 -4
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.23.
|
|
5035
|
+
var VERCEL_RUNTIME_VERSION = "0.23.2";
|
|
5036
5036
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
5037
5037
|
|
|
5038
5038
|
// src/conditional-vendoring.ts
|
|
@@ -8092,17 +8092,18 @@ function moduleColonFuncToCronPath(serviceName, moduleFunction) {
|
|
|
8092
8092
|
function getGeneratedScheduleHandlerPath(outputPath) {
|
|
8093
8093
|
return `_vc_schedule_handlers/${outputPath.replace(/[^A-Za-z0-9]+/g, "_")}.py`;
|
|
8094
8094
|
}
|
|
8095
|
-
function createScheduleHandlerModule(
|
|
8096
|
-
const entries =
|
|
8097
|
-
|
|
8098
|
-
|
|
8095
|
+
function createScheduleHandlerModule({ entrypoints }, rootDir) {
|
|
8096
|
+
const entries = entrypoints.flatMap(
|
|
8097
|
+
({ sourceFile, scheduleNames }) => scheduleNames.map(
|
|
8098
|
+
(name) => ` ${JSON.stringify(name)}: os.path.join(_root, ${JSON.stringify(sourceFile)}),`
|
|
8099
|
+
)
|
|
8099
8100
|
);
|
|
8100
8101
|
return [
|
|
8101
8102
|
"import os.path",
|
|
8102
8103
|
"",
|
|
8103
8104
|
"from vercel_runtime.schedules import create_schedule_scripts_app",
|
|
8104
8105
|
"",
|
|
8105
|
-
"_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))"
|
|
8106
|
+
rootDir === void 0 ? "_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))" : `_root = ${JSON.stringify(rootDir)}`,
|
|
8106
8107
|
"app = create_schedule_scripts_app({",
|
|
8107
8108
|
...entries,
|
|
8108
8109
|
"})",
|
|
@@ -8112,8 +8113,10 @@ function createScheduleHandlerModule(sourceFilesByScheduleName) {
|
|
|
8112
8113
|
|
|
8113
8114
|
// src/start-dev-server.ts
|
|
8114
8115
|
var import_child_process2 = require("child_process");
|
|
8116
|
+
var import_crypto2 = require("crypto");
|
|
8115
8117
|
var import_fs13 = require("fs");
|
|
8116
8118
|
var import_path13 = require("path");
|
|
8119
|
+
var import_util2 = require("util");
|
|
8117
8120
|
var import_build_utils15 = require("@vercel/build-utils");
|
|
8118
8121
|
var import_get_port = __toESM(require_get_port());
|
|
8119
8122
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
@@ -9243,6 +9246,25 @@ async function doInstallInjectedDevPackage(pkg, opts) {
|
|
|
9243
9246
|
}
|
|
9244
9247
|
var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
|
|
9245
9248
|
var PENDING_STARTS = /* @__PURE__ */ new Map();
|
|
9249
|
+
function signalServer(pid, signal) {
|
|
9250
|
+
try {
|
|
9251
|
+
process.kill(-pid, signal);
|
|
9252
|
+
} catch {
|
|
9253
|
+
try {
|
|
9254
|
+
process.kill(pid, signal);
|
|
9255
|
+
} catch (err) {
|
|
9256
|
+
(0, import_build_utils15.debug)(`Error sending ${signal} to ${pid}: ${err}`);
|
|
9257
|
+
}
|
|
9258
|
+
}
|
|
9259
|
+
}
|
|
9260
|
+
function killPersistentServer(key) {
|
|
9261
|
+
const info = PERSISTENT_SERVERS.get(key);
|
|
9262
|
+
if (!info)
|
|
9263
|
+
return;
|
|
9264
|
+
PERSISTENT_SERVERS.delete(key);
|
|
9265
|
+
signalServer(info.pid, "SIGTERM");
|
|
9266
|
+
signalServer(info.pid, "SIGKILL");
|
|
9267
|
+
}
|
|
9246
9268
|
var restoreWarnings = null;
|
|
9247
9269
|
var cleanupHandlersInstalled = false;
|
|
9248
9270
|
function installGlobalCleanupHandlers() {
|
|
@@ -9250,18 +9272,8 @@ function installGlobalCleanupHandlers() {
|
|
|
9250
9272
|
return;
|
|
9251
9273
|
cleanupHandlersInstalled = true;
|
|
9252
9274
|
const killAll = () => {
|
|
9253
|
-
for (const
|
|
9254
|
-
|
|
9255
|
-
process.kill(info.pid, "SIGTERM");
|
|
9256
|
-
} catch (err) {
|
|
9257
|
-
(0, import_build_utils15.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
9258
|
-
}
|
|
9259
|
-
try {
|
|
9260
|
-
process.kill(info.pid, "SIGKILL");
|
|
9261
|
-
} catch (err) {
|
|
9262
|
-
(0, import_build_utils15.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
9263
|
-
}
|
|
9264
|
-
PERSISTENT_SERVERS.delete(key);
|
|
9275
|
+
for (const key of PERSISTENT_SERVERS.keys()) {
|
|
9276
|
+
killPersistentServer(key);
|
|
9265
9277
|
}
|
|
9266
9278
|
if (restoreWarnings) {
|
|
9267
9279
|
try {
|
|
@@ -9285,9 +9297,9 @@ function installGlobalCleanupHandlers() {
|
|
|
9285
9297
|
function escapePythonStringContents(value) {
|
|
9286
9298
|
return JSON.stringify(value).slice(1, -1);
|
|
9287
9299
|
}
|
|
9288
|
-
function createDevShim(workPath, entry, modulePath,
|
|
9300
|
+
function createDevShim(workPath, entry, modulePath, shimSubdir, framework, variableName) {
|
|
9289
9301
|
try {
|
|
9290
|
-
const vercelPythonDir =
|
|
9302
|
+
const vercelPythonDir = shimSubdir ? (0, import_path13.join)(workPath, ".vercel", "python", shimSubdir) : (0, import_path13.join)(workPath, ".vercel", "python");
|
|
9291
9303
|
(0, import_fs13.mkdirSync)(vercelPythonDir, { recursive: true });
|
|
9292
9304
|
let qualifiedModule = modulePath;
|
|
9293
9305
|
let extraPythonPath;
|
|
@@ -9363,43 +9375,50 @@ var startDevServer = async (opts) => {
|
|
|
9363
9375
|
onStderr
|
|
9364
9376
|
} = opts;
|
|
9365
9377
|
const framework = config?.framework;
|
|
9378
|
+
const scheduleFunction = config?.scheduleFunction;
|
|
9379
|
+
const scheduleHandlerPath = scheduleFunction && `_vc_schedule_handlers/schedule_${(0, import_crypto2.createHash)("sha256").update(scheduleFunction.outputPath).digest("hex")}.py`;
|
|
9380
|
+
const scheduleModule = scheduleFunction && createScheduleHandlerModule(scheduleFunction, workPath);
|
|
9381
|
+
const env = { ...process.env, ...meta.env || {} };
|
|
9382
|
+
const scheduleEnv = scheduleFunction ? { ...env } : void 0;
|
|
9366
9383
|
const serviceName = service?.name ?? (typeof meta.serviceName === "string" ? meta.serviceName : void 0);
|
|
9367
|
-
const serverKey = serviceName ? `${workPath}::${framework}::${serviceName}` : `${workPath}::${framework}`;
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9384
|
+
const serverKey = scheduleFunction ? `${workPath}::schedule::${scheduleFunction.outputPath}` : serviceName ? `${workPath}::${framework}::${serviceName}` : `${workPath}::${framework}`;
|
|
9385
|
+
while (true) {
|
|
9386
|
+
const existing = PERSISTENT_SERVERS.get(serverKey);
|
|
9387
|
+
if (existing) {
|
|
9388
|
+
if (scheduleFunction && (existing.scheduleModule !== scheduleModule || !(0, import_util2.isDeepStrictEqual)(existing.scheduleEnv, scheduleEnv))) {
|
|
9389
|
+
killPersistentServer(serverKey);
|
|
9390
|
+
} else {
|
|
9391
|
+
return {
|
|
9392
|
+
port: existing.port,
|
|
9393
|
+
pid: existing.pid,
|
|
9394
|
+
shutdown: async () => {
|
|
9395
|
+
}
|
|
9396
|
+
};
|
|
9374
9397
|
}
|
|
9375
|
-
};
|
|
9376
|
-
}
|
|
9377
|
-
{
|
|
9378
|
-
const pending = PENDING_STARTS.get(serverKey);
|
|
9379
|
-
if (pending) {
|
|
9380
|
-
const { port, pid } = await pending;
|
|
9381
|
-
return {
|
|
9382
|
-
port,
|
|
9383
|
-
pid,
|
|
9384
|
-
shutdown: async () => {
|
|
9385
|
-
}
|
|
9386
|
-
};
|
|
9387
9398
|
}
|
|
9399
|
+
const pending = PENDING_STARTS.get(serverKey);
|
|
9400
|
+
if (!pending)
|
|
9401
|
+
break;
|
|
9402
|
+
await pending;
|
|
9388
9403
|
}
|
|
9389
|
-
if (!framework) {
|
|
9404
|
+
if (!framework && !scheduleFunction) {
|
|
9390
9405
|
return null;
|
|
9391
9406
|
}
|
|
9392
9407
|
if (!restoreWarnings)
|
|
9393
9408
|
restoreWarnings = silenceNodeWarnings();
|
|
9394
9409
|
installGlobalCleanupHandlers();
|
|
9395
|
-
const env = { ...process.env, ...meta.env || {} };
|
|
9396
9410
|
const entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
9397
9411
|
const isPyprojectEntrypoint = entrypoint === "pyproject.toml";
|
|
9398
9412
|
let resolved;
|
|
9399
9413
|
const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
|
|
9400
9414
|
const isPyQueueSidecar = config?.pythonQueueSidecar === "subscriber" || config?.pythonQueueSidecar === "workflow";
|
|
9401
9415
|
let detected;
|
|
9402
|
-
if (
|
|
9416
|
+
if (scheduleHandlerPath && scheduleModule) {
|
|
9417
|
+
const entrypoint2 = import_path13.posix.join(".vercel/python", scheduleHandlerPath);
|
|
9418
|
+
(0, import_fs13.mkdirSync)((0, import_path13.dirname)((0, import_path13.join)(workPath, entrypoint2)), { recursive: true });
|
|
9419
|
+
(0, import_fs13.writeFileSync)((0, import_path13.join)(workPath, entrypoint2), scheduleModule);
|
|
9420
|
+
detected = { entrypoint: { entrypoint: entrypoint2, variableName: "app" } };
|
|
9421
|
+
} else if (isPyprojectEntrypoint) {
|
|
9403
9422
|
const declaredEntrypoint = await getVercelToolsEntrypoint(
|
|
9404
9423
|
workPath,
|
|
9405
9424
|
opts.repoRootPath
|
|
@@ -9441,7 +9460,7 @@ var startDevServer = async (opts) => {
|
|
|
9441
9460
|
});
|
|
9442
9461
|
}
|
|
9443
9462
|
const { entrypoint: entry, variableName } = resolved;
|
|
9444
|
-
const modulePath = entrypointToModule(entry);
|
|
9463
|
+
const modulePath = scheduleHandlerPath ? generatedPythonPathToModule(scheduleHandlerPath) : entrypointToModule(entry);
|
|
9445
9464
|
let childProcess = null;
|
|
9446
9465
|
let stdoutLogListener = null;
|
|
9447
9466
|
let stderrLogListener = null;
|
|
@@ -9583,7 +9602,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
9583
9602
|
);
|
|
9584
9603
|
}
|
|
9585
9604
|
const apschedulerSubscribers = [];
|
|
9586
|
-
if (!legacyProject) {
|
|
9605
|
+
if (!legacyProject && !scheduleFunction) {
|
|
9587
9606
|
const runtimeDir = (0, import_path13.join)(workPath, ".vercel", "python");
|
|
9588
9607
|
const declaredSubscribers = await getPyprojectSubscribers(workPath);
|
|
9589
9608
|
const introspectionEnv = {
|
|
@@ -9703,8 +9722,8 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
9703
9722
|
workPath,
|
|
9704
9723
|
entry,
|
|
9705
9724
|
modulePath,
|
|
9706
|
-
serviceName,
|
|
9707
|
-
framework,
|
|
9725
|
+
scheduleHandlerPath ? scheduleHandlerPath.replace(/\.py$/, "") : serviceName && import_path13.posix.join("services", serviceName),
|
|
9726
|
+
framework ?? "python",
|
|
9708
9727
|
variableName ?? ""
|
|
9709
9728
|
);
|
|
9710
9729
|
if (devShim) {
|
|
@@ -9766,7 +9785,9 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
9766
9785
|
pid,
|
|
9767
9786
|
child: childProcess,
|
|
9768
9787
|
stdoutLogListener,
|
|
9769
|
-
stderrLogListener
|
|
9788
|
+
stderrLogListener,
|
|
9789
|
+
scheduleModule,
|
|
9790
|
+
scheduleEnv
|
|
9770
9791
|
});
|
|
9771
9792
|
const shutdown = async () => {
|
|
9772
9793
|
};
|
|
@@ -13118,17 +13139,11 @@ var build = async ({
|
|
|
13118
13139
|
const generatedPath = getGeneratedScheduleHandlerPath(
|
|
13119
13140
|
scheduleFunction.outputPath
|
|
13120
13141
|
);
|
|
13121
|
-
const sourceFilesByScheduleName = /* @__PURE__ */ new Map();
|
|
13122
|
-
for (const { sourceFile, scheduleNames } of scheduleFunction.entrypoints) {
|
|
13123
|
-
for (const name of scheduleNames) {
|
|
13124
|
-
sourceFilesByScheduleName.set(name, sourceFile);
|
|
13125
|
-
}
|
|
13126
|
-
}
|
|
13127
13142
|
const scheduleLambda = new import_build_utils24.Lambda({
|
|
13128
13143
|
files: {
|
|
13129
13144
|
...files,
|
|
13130
13145
|
[generatedPath]: new import_build_utils24.FileBlob({
|
|
13131
|
-
data: createScheduleHandlerModule(
|
|
13146
|
+
data: createScheduleHandlerModule(scheduleFunction)
|
|
13132
13147
|
}),
|
|
13133
13148
|
[`${handlerPyFilename}.py`]: new import_build_utils24.FileBlob({
|
|
13134
13149
|
data: createRuntimeTrampoline({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.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.15.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@renovatebot/pep440": "4.2.1",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"smol-toml": "1.5.2",
|
|
38
38
|
"vitest": "4.1.10",
|
|
39
39
|
"which": "3.0.0",
|
|
40
|
-
"@vercel/build-utils": "14.
|
|
40
|
+
"@vercel/build-utils": "14.15.0",
|
|
41
41
|
"@vercel/error-utils": "2.2.1",
|
|
42
|
-
"@vercel/python-runtime": "0.23.
|
|
42
|
+
"@vercel/python-runtime": "0.23.2"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ../../utils/build-builder.mjs",
|