@vercel/python 32.0.0 → 32.0.1-snapshot-c7f6a2a993e4
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 +421 -200
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5055,7 +5055,7 @@ var import_fs22 = __toESM(require("fs"));
|
|
|
5055
5055
|
var import_path23 = require("path");
|
|
5056
5056
|
|
|
5057
5057
|
// src/package-versions.ts
|
|
5058
|
-
var VERCEL_RUNTIME_VERSION = "0.24.
|
|
5058
|
+
var VERCEL_RUNTIME_VERSION = "0.24.4";
|
|
5059
5059
|
var VERCEL_WORKERS_VERSION = "0.0.25";
|
|
5060
5060
|
|
|
5061
5061
|
// src/conditional-vendoring.ts
|
|
@@ -5382,7 +5382,7 @@ async function queryPythonWorkflowSdkVersion(opts) {
|
|
|
5382
5382
|
}
|
|
5383
5383
|
|
|
5384
5384
|
// src/index.ts
|
|
5385
|
-
var
|
|
5385
|
+
var import_build_utils26 = require("@vercel/build-utils");
|
|
5386
5386
|
|
|
5387
5387
|
// src/install.ts
|
|
5388
5388
|
var import_execa4 = __toESM(require_execa());
|
|
@@ -9589,11 +9589,169 @@ function moduleColonFuncToCronPath(serviceName, moduleFunction) {
|
|
|
9589
9589
|
return (0, import_build_utils13.getInternalServiceCronPath)(serviceName, entrypointPath, funcPart);
|
|
9590
9590
|
}
|
|
9591
9591
|
|
|
9592
|
+
// src/schedules.ts
|
|
9593
|
+
var import_crypto2 = require("crypto");
|
|
9594
|
+
var import_build_utils14 = require("@vercel/build-utils");
|
|
9595
|
+
var SCHEDULES_FUNCTION_PATH = "schedules";
|
|
9596
|
+
var GENERATED_SCHEDULE_HANDLER_PATH = "_vc_schedule_handlers/schedules.py";
|
|
9597
|
+
var SCHEDULE_NAME_RE = /^[0-9A-Za-z][0-9A-Za-z._-]*$/;
|
|
9598
|
+
var MAX_SCHEDULE_NAME_LENGTH = 256;
|
|
9599
|
+
function createScheduleHandlerModule({
|
|
9600
|
+
moduleName,
|
|
9601
|
+
service,
|
|
9602
|
+
schedules
|
|
9603
|
+
}) {
|
|
9604
|
+
return [
|
|
9605
|
+
"import importlib",
|
|
9606
|
+
"",
|
|
9607
|
+
"from vercel_runtime.schedules import create_schedule_service_app",
|
|
9608
|
+
"",
|
|
9609
|
+
`importlib.import_module(${JSON.stringify(moduleName)})`,
|
|
9610
|
+
`app = create_schedule_service_app(${JSON.stringify(service)}, ${JSON.stringify(schedules)})`,
|
|
9611
|
+
""
|
|
9612
|
+
].join("\n");
|
|
9613
|
+
}
|
|
9614
|
+
function createScheduleIntrospectionScript(moduleName) {
|
|
9615
|
+
return [
|
|
9616
|
+
"import importlib, json, os",
|
|
9617
|
+
// Everything else written to stdout, including by C extensions,
|
|
9618
|
+
// subprocesses and atexit handlers, goes to stderr, so stdout has only
|
|
9619
|
+
// the schedules.
|
|
9620
|
+
"out = os.fdopen(os.dup(1), 'w')",
|
|
9621
|
+
"os.dup2(2, 1)",
|
|
9622
|
+
`importlib.import_module(${JSON.stringify(moduleName)})`,
|
|
9623
|
+
"from vercel.schedules import get_registered_schedules",
|
|
9624
|
+
"json.dump([",
|
|
9625
|
+
" {",
|
|
9626
|
+
" 'name': s.name,",
|
|
9627
|
+
" 'cron': str(s.cron),",
|
|
9628
|
+
" 'timezone': s.timezone,",
|
|
9629
|
+
" 'jitter': None if s.jitter is None else int(s.jitter.total_seconds() // 60),",
|
|
9630
|
+
" 'max_duration': None if s.max_duration is None else int(s.max_duration.total_seconds()),",
|
|
9631
|
+
" 'regions': None if s.regions is None else list(s.regions),",
|
|
9632
|
+
" }",
|
|
9633
|
+
" for s in get_registered_schedules()",
|
|
9634
|
+
"], out)",
|
|
9635
|
+
"out.close()"
|
|
9636
|
+
].join("\n");
|
|
9637
|
+
}
|
|
9638
|
+
var REGION_ID_RE = /^[a-z]{3}[0-9]$/;
|
|
9639
|
+
var MAX_FUNCTION_NAME_LENGTH = 64;
|
|
9640
|
+
function formatMaxDuration(seconds) {
|
|
9641
|
+
if (seconds % 3600 === 0)
|
|
9642
|
+
return `${seconds / 3600}h`;
|
|
9643
|
+
if (seconds % 60 === 0)
|
|
9644
|
+
return `${seconds / 60}m`;
|
|
9645
|
+
return `${seconds}s`;
|
|
9646
|
+
}
|
|
9647
|
+
function getScheduleFunction(maxDuration, regions) {
|
|
9648
|
+
const sortedRegions = regions && [...new Set(regions)].sort();
|
|
9649
|
+
const parts = [
|
|
9650
|
+
...sortedRegions ?? [],
|
|
9651
|
+
...maxDuration === null ? [] : [formatMaxDuration(maxDuration)]
|
|
9652
|
+
];
|
|
9653
|
+
let path = [SCHEDULES_FUNCTION_PATH, ...parts].join("-");
|
|
9654
|
+
if (!(sortedRegions ?? []).every((region) => REGION_ID_RE.test(region)) || path.length > MAX_FUNCTION_NAME_LENGTH) {
|
|
9655
|
+
const hash = (0, import_crypto2.createHash)("sha256").update(JSON.stringify([maxDuration, sortedRegions])).digest("hex").slice(0, 8);
|
|
9656
|
+
path = `${SCHEDULES_FUNCTION_PATH}-${hash}`;
|
|
9657
|
+
}
|
|
9658
|
+
return {
|
|
9659
|
+
path,
|
|
9660
|
+
...maxDuration !== null && { maxDuration },
|
|
9661
|
+
...sortedRegions !== null && { regions: sortedRegions }
|
|
9662
|
+
};
|
|
9663
|
+
}
|
|
9664
|
+
function parseIntrospectedSchedules(stdout) {
|
|
9665
|
+
try {
|
|
9666
|
+
const parsed = JSON.parse(stdout);
|
|
9667
|
+
return Array.isArray(parsed) ? parsed : void 0;
|
|
9668
|
+
} catch {
|
|
9669
|
+
return void 0;
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
function scheduleError(service, message) {
|
|
9673
|
+
return new import_build_utils14.NowBuildError({
|
|
9674
|
+
code: "PYTHON_INVALID_SCHEDULE",
|
|
9675
|
+
message: `Can't build schedule "${service}": ${message}`
|
|
9676
|
+
});
|
|
9677
|
+
}
|
|
9678
|
+
async function introspectSchedules({
|
|
9679
|
+
moduleName,
|
|
9680
|
+
service,
|
|
9681
|
+
uv,
|
|
9682
|
+
venvPath,
|
|
9683
|
+
projectDir
|
|
9684
|
+
}) {
|
|
9685
|
+
let stdout;
|
|
9686
|
+
try {
|
|
9687
|
+
({ stdout } = await uv.run({
|
|
9688
|
+
venvPath,
|
|
9689
|
+
projectDir,
|
|
9690
|
+
args: ["python", "-c", createScheduleIntrospectionScript(moduleName)],
|
|
9691
|
+
// Modules read these at import time on a deployment, as for queue
|
|
9692
|
+
// introspection.
|
|
9693
|
+
env: {
|
|
9694
|
+
VERCEL: "1",
|
|
9695
|
+
VERCEL_REGION: process.env.VERCEL_REGION || "iad1",
|
|
9696
|
+
VERCEL_DEPLOYMENT_ID: process.env.VERCEL_DEPLOYMENT_ID || "dpl_introspection"
|
|
9697
|
+
}
|
|
9698
|
+
}));
|
|
9699
|
+
} catch (err) {
|
|
9700
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9701
|
+
throw scheduleError(
|
|
9702
|
+
service,
|
|
9703
|
+
`importing module "${moduleName}" failed. It must import, and declare its schedules with \`@schedule\` from "vercel-schedules": ${message}`
|
|
9704
|
+
);
|
|
9705
|
+
}
|
|
9706
|
+
const introspected = parseIntrospectedSchedules(stdout);
|
|
9707
|
+
if (!introspected) {
|
|
9708
|
+
throw scheduleError(
|
|
9709
|
+
service,
|
|
9710
|
+
`could not read the schedules of module "${moduleName}": introspection did not return a JSON array`
|
|
9711
|
+
);
|
|
9712
|
+
}
|
|
9713
|
+
if (introspected.length === 0) {
|
|
9714
|
+
throw scheduleError(
|
|
9715
|
+
service,
|
|
9716
|
+
`module "${moduleName}" declares no schedules. Declare them with \`@schedule\` from "vercel-schedules".`
|
|
9717
|
+
);
|
|
9718
|
+
}
|
|
9719
|
+
const schedules = {};
|
|
9720
|
+
const functions = /* @__PURE__ */ new Map();
|
|
9721
|
+
for (const {
|
|
9722
|
+
name,
|
|
9723
|
+
cron,
|
|
9724
|
+
timezone,
|
|
9725
|
+
jitter,
|
|
9726
|
+
max_duration: maxDuration = null,
|
|
9727
|
+
regions = null
|
|
9728
|
+
} of introspected) {
|
|
9729
|
+
const deployedName = `${service}.${name}`;
|
|
9730
|
+
if (deployedName.length > MAX_SCHEDULE_NAME_LENGTH || !SCHEDULE_NAME_RE.test(deployedName)) {
|
|
9731
|
+
throw scheduleError(
|
|
9732
|
+
service,
|
|
9733
|
+
`the schedule name "${deployedName}" is invalid. Names can have at most ${MAX_SCHEDULE_NAME_LENGTH} characters, and contain only letters, numbers, ".", "_" and "-". Shorten the \`@schedule\` name "${name}".`
|
|
9734
|
+
);
|
|
9735
|
+
}
|
|
9736
|
+
const target = getScheduleFunction(maxDuration, regions);
|
|
9737
|
+
const fn = functions.get(target.path) ?? { ...target, schedules: [] };
|
|
9738
|
+
fn.schedules.push(name);
|
|
9739
|
+
functions.set(fn.path, fn);
|
|
9740
|
+
schedules[deployedName] = {
|
|
9741
|
+
schedule: cron,
|
|
9742
|
+
...timezone !== null && { timezone },
|
|
9743
|
+
...jitter !== null && { jitter },
|
|
9744
|
+
function: fn.path
|
|
9745
|
+
};
|
|
9746
|
+
}
|
|
9747
|
+
return { schedules, functions: [...functions.values()] };
|
|
9748
|
+
}
|
|
9749
|
+
|
|
9592
9750
|
// src/start-dev-server.ts
|
|
9593
9751
|
var import_child_process2 = require("child_process");
|
|
9594
9752
|
var import_fs15 = require("fs");
|
|
9595
9753
|
var import_path15 = require("path");
|
|
9596
|
-
var
|
|
9754
|
+
var import_build_utils17 = require("@vercel/build-utils");
|
|
9597
9755
|
var import_get_port = __toESM(require_get_port());
|
|
9598
9756
|
var import_is_port_reachable = __toESM(require_is_port_reachable());
|
|
9599
9757
|
var import_python_analysis12 = require("@vercel/python-analysis");
|
|
@@ -9602,7 +9760,7 @@ var import_python_analysis12 = require("@vercel/python-analysis");
|
|
|
9602
9760
|
var import_path14 = require("path");
|
|
9603
9761
|
var import_fs14 = __toESM(require("fs"));
|
|
9604
9762
|
var import_execa6 = __toESM(require_execa());
|
|
9605
|
-
var
|
|
9763
|
+
var import_build_utils16 = require("@vercel/build-utils");
|
|
9606
9764
|
|
|
9607
9765
|
// src/module-entrypoint.ts
|
|
9608
9766
|
var import_path12 = require("path");
|
|
@@ -9661,7 +9819,7 @@ async function resolveExistingEntrypoint(workPath, filePath) {
|
|
|
9661
9819
|
// src/workflows.ts
|
|
9662
9820
|
var import_path13 = require("path");
|
|
9663
9821
|
var import_fs13 = __toESM(require("fs"));
|
|
9664
|
-
var
|
|
9822
|
+
var import_build_utils15 = require("@vercel/build-utils");
|
|
9665
9823
|
var WORKFLOW_OUTPUT_DIR = "_py_workflows";
|
|
9666
9824
|
var WORKFLOW_TOPIC_PATTERN = "__wkf_*";
|
|
9667
9825
|
var WORKFLOW_DEV_TOPIC_PATTERN = "__*wkf_*";
|
|
@@ -9674,14 +9832,14 @@ function getWorkflowOutputPath(workflowName) {
|
|
|
9674
9832
|
return `${WORKFLOW_OUTPUT_DIR}/${safePathSegment(workflowName)}`;
|
|
9675
9833
|
}
|
|
9676
9834
|
function getWorkflowConsumerName(workflowName) {
|
|
9677
|
-
return (0,
|
|
9835
|
+
return (0, import_build_utils15.sanitizeConsumerName)(getWorkflowOutputPath(workflowName));
|
|
9678
9836
|
}
|
|
9679
9837
|
async function getPyprojectWorkflows(workPath) {
|
|
9680
9838
|
const pyprojectPath = (0, import_path13.join)(workPath, "pyproject.toml");
|
|
9681
9839
|
if (!import_fs13.default.existsSync(pyprojectPath)) {
|
|
9682
9840
|
return [];
|
|
9683
9841
|
}
|
|
9684
|
-
const pyproject = await (0,
|
|
9842
|
+
const pyproject = await (0, import_build_utils15.readConfigFile)(pyprojectPath);
|
|
9685
9843
|
const workflows = pyproject?.tool?.vercel?.workflows;
|
|
9686
9844
|
if (!workflows) {
|
|
9687
9845
|
return [];
|
|
@@ -9740,7 +9898,7 @@ async function parseWorkflow(workPath, index, config) {
|
|
|
9740
9898
|
};
|
|
9741
9899
|
}
|
|
9742
9900
|
function workflowError(message) {
|
|
9743
|
-
return new
|
|
9901
|
+
return new import_build_utils15.NowBuildError({
|
|
9744
9902
|
code: "PYTHON_INVALID_WORKFLOW_CONFIG",
|
|
9745
9903
|
message
|
|
9746
9904
|
});
|
|
@@ -9818,7 +9976,7 @@ function getSubscriberOutputPath(subscriberName) {
|
|
|
9818
9976
|
return `${SUBSCRIBER_OUTPUT_DIR}/${safePathSegment(subscriberName)}`;
|
|
9819
9977
|
}
|
|
9820
9978
|
function getSubscriberConsumerName(subscriberName) {
|
|
9821
|
-
return (0,
|
|
9979
|
+
return (0, import_build_utils16.sanitizeConsumerName)(getSubscriberOutputPath(subscriberName));
|
|
9822
9980
|
}
|
|
9823
9981
|
function getGeneratedQueueHandlerPath(outputPath) {
|
|
9824
9982
|
return `_vc_queue_handlers/${outputPath.replace(/[^A-Za-z0-9_]+/g, "_")}.py`;
|
|
@@ -9831,7 +9989,7 @@ async function hasPyprojectSubscribers(workPath) {
|
|
|
9831
9989
|
if (!import_fs14.default.existsSync(pyprojectPath)) {
|
|
9832
9990
|
return false;
|
|
9833
9991
|
}
|
|
9834
|
-
const pyproject = await (0,
|
|
9992
|
+
const pyproject = await (0, import_build_utils16.readConfigFile)(pyprojectPath);
|
|
9835
9993
|
const subscribers = pyproject?.tool?.vercel?.subscribers;
|
|
9836
9994
|
return Array.isArray(subscribers) && subscribers.length > 0;
|
|
9837
9995
|
}
|
|
@@ -9840,7 +9998,7 @@ async function getPyprojectSubscribers(workPath, { legacySchema = false } = {})
|
|
|
9840
9998
|
if (!import_fs14.default.existsSync(pyprojectPath)) {
|
|
9841
9999
|
return [];
|
|
9842
10000
|
}
|
|
9843
|
-
const pyproject = await (0,
|
|
10001
|
+
const pyproject = await (0, import_build_utils16.readConfigFile)(pyprojectPath);
|
|
9844
10002
|
const subscribers = pyproject?.tool?.vercel?.subscribers;
|
|
9845
10003
|
if (!subscribers) {
|
|
9846
10004
|
return [];
|
|
@@ -9869,7 +10027,7 @@ async function getApschedulerPreviewConfig(workPath) {
|
|
|
9869
10027
|
if (!import_fs14.default.existsSync(pyprojectPath)) {
|
|
9870
10028
|
return void 0;
|
|
9871
10029
|
}
|
|
9872
|
-
const pyproject = await (0,
|
|
10030
|
+
const pyproject = await (0, import_build_utils16.readConfigFile)(pyprojectPath);
|
|
9873
10031
|
const apscheduler = pyproject?.tool?.vercel?.apscheduler;
|
|
9874
10032
|
if (apscheduler === void 0) {
|
|
9875
10033
|
return void 0;
|
|
@@ -10245,7 +10403,7 @@ async function introspectQueueSubscriptions({
|
|
|
10245
10403
|
});
|
|
10246
10404
|
return parseIntrospectedSubscriptions(kind, declaration.name, stdout);
|
|
10247
10405
|
} catch (err) {
|
|
10248
|
-
if (err instanceof
|
|
10406
|
+
if (err instanceof import_build_utils16.NowBuildError) {
|
|
10249
10407
|
throw err;
|
|
10250
10408
|
}
|
|
10251
10409
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -10303,7 +10461,7 @@ async function introspectDevQueueSubscriptions({
|
|
|
10303
10461
|
});
|
|
10304
10462
|
return { subscriptions, owners: introspected.owners };
|
|
10305
10463
|
} catch (err) {
|
|
10306
|
-
(0,
|
|
10464
|
+
(0, import_build_utils16.debug)(
|
|
10307
10465
|
`Failed to introspect dev queue subscriptions for module "${moduleName}": ${err instanceof Error ? err.message : String(err)}`
|
|
10308
10466
|
);
|
|
10309
10467
|
return void 0;
|
|
@@ -10393,13 +10551,13 @@ function apschedulerSubscriberIdentities(subscribers) {
|
|
|
10393
10551
|
}));
|
|
10394
10552
|
}
|
|
10395
10553
|
function subscriberError(message) {
|
|
10396
|
-
return new
|
|
10554
|
+
return new import_build_utils16.NowBuildError({
|
|
10397
10555
|
code: "PYTHON_INVALID_SUBSCRIBER_CONFIG",
|
|
10398
10556
|
message
|
|
10399
10557
|
});
|
|
10400
10558
|
}
|
|
10401
10559
|
function apschedulerError(message) {
|
|
10402
|
-
return new
|
|
10560
|
+
return new import_build_utils16.NowBuildError({
|
|
10403
10561
|
code: "PYTHON_INVALID_APSCHEDULER_CONFIG",
|
|
10404
10562
|
message
|
|
10405
10563
|
});
|
|
@@ -10502,7 +10660,7 @@ async function syncDependencies({
|
|
|
10502
10660
|
rootDir: workPath
|
|
10503
10661
|
});
|
|
10504
10662
|
if (onlyGroup && !(onlyGroup in (pythonPackage.manifest?.data?.["dependency-groups"] ?? {}))) {
|
|
10505
|
-
(0,
|
|
10663
|
+
(0, import_build_utils17.debug)(`No "${onlyGroup}" dependency group found, skipping dependency sync`);
|
|
10506
10664
|
return;
|
|
10507
10665
|
}
|
|
10508
10666
|
const installInfo = detectInstallSource(pythonPackage, workPath);
|
|
@@ -10510,7 +10668,7 @@ async function syncDependencies({
|
|
|
10510
10668
|
let { manifestPath } = installInfo;
|
|
10511
10669
|
const manifest = pythonPackage.manifest;
|
|
10512
10670
|
if (!manifestType || !manifestPath) {
|
|
10513
|
-
(0,
|
|
10671
|
+
(0, import_build_utils17.debug)("No Python project manifest found, skipping dependency sync");
|
|
10514
10672
|
return;
|
|
10515
10673
|
}
|
|
10516
10674
|
if (manifest?.origin && manifestType === "pyproject.toml") {
|
|
@@ -10520,7 +10678,7 @@ async function syncDependencies({
|
|
|
10520
10678
|
const content = (0, import_python_analysis12.stringifyManifest)(manifest.data);
|
|
10521
10679
|
(0, import_fs15.writeFileSync)(tempPyproject, content, "utf8");
|
|
10522
10680
|
manifestPath = tempPyproject;
|
|
10523
|
-
(0,
|
|
10681
|
+
(0, import_build_utils17.debug)(
|
|
10524
10682
|
`Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}`
|
|
10525
10683
|
);
|
|
10526
10684
|
}
|
|
@@ -10555,7 +10713,7 @@ async function syncDependencies({
|
|
|
10555
10713
|
for (const [channel, chunk] of captured) {
|
|
10556
10714
|
(channel === "stdout" ? writeOut : writeErr)(chunk.toString());
|
|
10557
10715
|
}
|
|
10558
|
-
throw new
|
|
10716
|
+
throw new import_build_utils17.NowBuildError({
|
|
10559
10717
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
10560
10718
|
message: `Failed to install Python dependencies from ${manifestType}: ${err instanceof Error ? err.message : String(err)}`
|
|
10561
10719
|
});
|
|
@@ -10579,7 +10737,7 @@ async function runSync({
|
|
|
10579
10737
|
switch (manifestType) {
|
|
10580
10738
|
case "uv.lock": {
|
|
10581
10739
|
if (!uvPath) {
|
|
10582
|
-
throw new
|
|
10740
|
+
throw new import_build_utils17.NowBuildError({
|
|
10583
10741
|
code: "PYTHON_DEPENDENCY_SYNC_FAILED",
|
|
10584
10742
|
message: "uv is required to install dependencies from uv.lock.",
|
|
10585
10743
|
link: "https://docs.astral.sh/uv/getting-started/installation/",
|
|
@@ -10617,11 +10775,11 @@ async function runSync({
|
|
|
10617
10775
|
break;
|
|
10618
10776
|
}
|
|
10619
10777
|
default:
|
|
10620
|
-
(0,
|
|
10778
|
+
(0, import_build_utils17.debug)(`Unknown manifest type: ${manifestType}`);
|
|
10621
10779
|
return;
|
|
10622
10780
|
}
|
|
10623
10781
|
await new Promise((resolve5, reject) => {
|
|
10624
|
-
(0,
|
|
10782
|
+
(0, import_build_utils17.debug)(`Running "${spawnCmd} ${spawnArgs.join(" ")}" in ${projectDir}...`);
|
|
10625
10783
|
const child = (0, import_child_process2.spawn)(spawnCmd, spawnArgs, {
|
|
10626
10784
|
cwd: projectDir,
|
|
10627
10785
|
env: getProtectedUvEnv(env),
|
|
@@ -10694,11 +10852,11 @@ async function doInstallInjectedDevPackage(pkg, opts) {
|
|
|
10694
10852
|
`${distInfoName}-${pkg.pinnedVersion}.dist-info`
|
|
10695
10853
|
);
|
|
10696
10854
|
if ((0, import_fs15.existsSync)(distInfo)) {
|
|
10697
|
-
(0,
|
|
10855
|
+
(0, import_build_utils17.debug)(`${pkg.name} ${pkg.pinnedVersion} already installed, skipping`);
|
|
10698
10856
|
return;
|
|
10699
10857
|
}
|
|
10700
10858
|
}
|
|
10701
|
-
(0,
|
|
10859
|
+
(0, import_build_utils17.debug)(
|
|
10702
10860
|
`Installing ${pkg.name} into ${targetDir} (type: ${isLocalDev ? "local" : "pypi"}, source: ${dep})`
|
|
10703
10861
|
);
|
|
10704
10862
|
const pip = uvPath ? { cmd: uvPath, prefix: ["pip", "install"] } : { cmd: pythonBin, prefix: ["-m", "pip", "install"] };
|
|
@@ -10723,14 +10881,14 @@ async function doInstallInjectedDevPackage(pkg, opts) {
|
|
|
10723
10881
|
if (onStdout) {
|
|
10724
10882
|
onStdout(data);
|
|
10725
10883
|
} else {
|
|
10726
|
-
(0,
|
|
10884
|
+
(0, import_build_utils17.debug)(data.toString());
|
|
10727
10885
|
}
|
|
10728
10886
|
});
|
|
10729
10887
|
child.stderr?.on("data", (data) => {
|
|
10730
10888
|
if (onStderr) {
|
|
10731
10889
|
onStderr(data);
|
|
10732
10890
|
} else {
|
|
10733
|
-
(0,
|
|
10891
|
+
(0, import_build_utils17.debug)(data.toString());
|
|
10734
10892
|
}
|
|
10735
10893
|
});
|
|
10736
10894
|
child.on("error", reject);
|
|
@@ -10756,7 +10914,7 @@ function signalServer(pid, signal) {
|
|
|
10756
10914
|
try {
|
|
10757
10915
|
process.kill(pid, signal);
|
|
10758
10916
|
} catch (err) {
|
|
10759
|
-
(0,
|
|
10917
|
+
(0, import_build_utils17.debug)(`Error sending ${signal} to ${pid}: ${err}`);
|
|
10760
10918
|
}
|
|
10761
10919
|
}
|
|
10762
10920
|
}
|
|
@@ -10782,7 +10940,7 @@ function installGlobalCleanupHandlers() {
|
|
|
10782
10940
|
try {
|
|
10783
10941
|
restoreWarnings();
|
|
10784
10942
|
} catch (err) {
|
|
10785
|
-
(0,
|
|
10943
|
+
(0, import_build_utils17.debug)(`Error restoring warnings: ${err}`);
|
|
10786
10944
|
}
|
|
10787
10945
|
restoreWarnings = null;
|
|
10788
10946
|
}
|
|
@@ -10828,14 +10986,14 @@ function createDevShim(workPath, entry, modulePath, shimSubdir, framework, varia
|
|
|
10828
10986
|
escapePythonStringContents(variableName)
|
|
10829
10987
|
);
|
|
10830
10988
|
(0, import_fs15.writeFileSync)(shimPath, shimSource, "utf8");
|
|
10831
|
-
(0,
|
|
10989
|
+
(0, import_build_utils17.debug)(`Prepared Python dev shim at ${shimPath}`);
|
|
10832
10990
|
return {
|
|
10833
10991
|
module: DEV_SHIM_MODULE,
|
|
10834
10992
|
extraPythonPath,
|
|
10835
10993
|
shimDir: vercelPythonDir
|
|
10836
10994
|
};
|
|
10837
10995
|
} catch (err) {
|
|
10838
|
-
(0,
|
|
10996
|
+
(0, import_build_utils17.debug)(`Failed to prepare dev shim: ${err?.message || err}`);
|
|
10839
10997
|
return null;
|
|
10840
10998
|
}
|
|
10841
10999
|
}
|
|
@@ -10847,7 +11005,7 @@ async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath)
|
|
|
10847
11005
|
}
|
|
10848
11006
|
const { pythonCmd, venvRoot } = useVirtualEnv(workPath, env, systemPython);
|
|
10849
11007
|
if (venvRoot) {
|
|
10850
|
-
(0,
|
|
11008
|
+
(0, import_build_utils17.debug)(`Using existing virtualenv at ${venvRoot} for multi-service dev`);
|
|
10851
11009
|
return { command: pythonCmd, args: [] };
|
|
10852
11010
|
}
|
|
10853
11011
|
await dedupePendingOperation(
|
|
@@ -10860,7 +11018,7 @@ async function getMultiServicePythonRunner(workPath, env, systemPython, uvPath)
|
|
|
10860
11018
|
quiet: true
|
|
10861
11019
|
})
|
|
10862
11020
|
);
|
|
10863
|
-
(0,
|
|
11021
|
+
(0, import_build_utils17.debug)(`Created virtualenv at ${venvPath} for multi-service dev`);
|
|
10864
11022
|
const pythonBin = getVenvPythonBin(venvPath);
|
|
10865
11023
|
const binDir = getVenvBinDir(venvPath);
|
|
10866
11024
|
env.VIRTUAL_ENV = venvPath;
|
|
@@ -10942,7 +11100,7 @@ async function spawnPersistentServer({
|
|
|
10942
11100
|
const moduleToRun = devShim?.module || modulePath;
|
|
10943
11101
|
const pythonArgs = ["-u", "-m", moduleToRun];
|
|
10944
11102
|
const argv = [...spawnArgsPrefix, ...pythonArgs];
|
|
10945
|
-
(0,
|
|
11103
|
+
(0, import_build_utils17.debug)(
|
|
10946
11104
|
`Starting Python dev server (${framework}): ${spawnCommand} ${argv.join(" ")} [PORT=${port}]`
|
|
10947
11105
|
);
|
|
10948
11106
|
if (process.stdout.columns) {
|
|
@@ -11011,7 +11169,7 @@ var startProxyDevServer = async ({
|
|
|
11011
11169
|
try {
|
|
11012
11170
|
const proxySource = (0, import_fs15.readFileSync)((0, import_path15.join)(workPath, entrypoint), "utf8");
|
|
11013
11171
|
if (!await (0, import_python_analysis12.containsTopLevelCallable)(proxySource, handlerFunction)) {
|
|
11014
|
-
throw new
|
|
11172
|
+
throw new import_build_utils17.NowBuildError({
|
|
11015
11173
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
11016
11174
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
11017
11175
|
});
|
|
@@ -11127,7 +11285,7 @@ var startDevServer = async (opts) => {
|
|
|
11127
11285
|
filePath: entrypoint,
|
|
11128
11286
|
// Schedule-triggered services create their own "app" wrapper dynamically.
|
|
11129
11287
|
// Other services use handlerFunction as the entrypoint variable name.
|
|
11130
|
-
varName: service && (0,
|
|
11288
|
+
varName: service && (0, import_build_utils17.isScheduleTriggeredService)(service) ? void 0 : handlerFunction ?? (isPyQueueSidecar ? "app" : void 0)
|
|
11131
11289
|
} : void 0,
|
|
11132
11290
|
service,
|
|
11133
11291
|
opts.repoRootPath
|
|
@@ -11149,7 +11307,7 @@ var startDevServer = async (opts) => {
|
|
|
11149
11307
|
if (detected?.error) {
|
|
11150
11308
|
throw detected.error;
|
|
11151
11309
|
}
|
|
11152
|
-
throw new
|
|
11310
|
+
throw new import_build_utils17.NowBuildError({
|
|
11153
11311
|
code: isPyprojectEntrypoint ? "PYTHON_PYPROJECT_NOTHING_TO_BUILD" : "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
11154
11312
|
message: isPyprojectEntrypoint ? 'Entrypoint "pyproject.toml" does not declare a web app. Set "tool.vercel.entrypoint" in pyproject.toml.' : "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
11155
11313
|
});
|
|
@@ -11168,7 +11326,7 @@ var startDevServer = async (opts) => {
|
|
|
11168
11326
|
const yellow = "\x1B[33m";
|
|
11169
11327
|
const white = "\x1B[1m";
|
|
11170
11328
|
const reset = "\x1B[0m";
|
|
11171
|
-
throw new
|
|
11329
|
+
throw new import_build_utils17.NowBuildError({
|
|
11172
11330
|
code: "PYTHON_EXTERNAL_VENV_DETECTED",
|
|
11173
11331
|
message: `Detected activated venv at ${yellow}${venv}${reset}, ${white}vercel dev${reset} manages virtual environments automatically.
|
|
11174
11332
|
Run ${white}deactivate${reset} and try again.`
|
|
@@ -11185,11 +11343,11 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
11185
11343
|
);
|
|
11186
11344
|
spawnCommand = runner.command;
|
|
11187
11345
|
spawnArgsPrefix = runner.args;
|
|
11188
|
-
(0,
|
|
11346
|
+
(0, import_build_utils17.debug)(
|
|
11189
11347
|
`Multi-service Python runner: ${spawnCommand} ${spawnArgsPrefix.join(" ")}`
|
|
11190
11348
|
);
|
|
11191
11349
|
} else if (venv) {
|
|
11192
|
-
(0,
|
|
11350
|
+
(0, import_build_utils17.debug)(`Running in virtualenv at ${venv}`);
|
|
11193
11351
|
} else {
|
|
11194
11352
|
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
11195
11353
|
workPath,
|
|
@@ -11198,9 +11356,9 @@ Run ${white}deactivate${reset} and try again.`
|
|
|
11198
11356
|
);
|
|
11199
11357
|
spawnCommand = venvPythonCmd;
|
|
11200
11358
|
if (venvRoot) {
|
|
11201
|
-
(0,
|
|
11359
|
+
(0, import_build_utils17.debug)(`Using virtualenv at ${venvRoot}`);
|
|
11202
11360
|
} else {
|
|
11203
|
-
(0,
|
|
11361
|
+
(0, import_build_utils17.debug)("No virtualenv found");
|
|
11204
11362
|
try {
|
|
11205
11363
|
const yellow = "\x1B[33m";
|
|
11206
11364
|
const reset = "\x1B[0m";
|
|
@@ -11279,7 +11437,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
11279
11437
|
);
|
|
11280
11438
|
}
|
|
11281
11439
|
} catch (err) {
|
|
11282
|
-
(0,
|
|
11440
|
+
(0, import_build_utils17.debug)(
|
|
11283
11441
|
`Skipping conditional dev package injection: ${err instanceof Error ? err.message : String(err)}`
|
|
11284
11442
|
);
|
|
11285
11443
|
}
|
|
@@ -11335,7 +11493,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
11335
11493
|
devOpts
|
|
11336
11494
|
);
|
|
11337
11495
|
}
|
|
11338
|
-
const queueSidecarKind = config?.pythonQueueSidecar === "subscriber" || config?.pythonQueueSidecar === "workflow" ? config.pythonQueueSidecar : service && (0,
|
|
11496
|
+
const queueSidecarKind = config?.pythonQueueSidecar === "subscriber" || config?.pythonQueueSidecar === "workflow" ? config.pythonQueueSidecar : service && (0, import_build_utils17.isQueueBackedService)(service) ? (0, import_build_utils17.isWorkflowTriggeredService)(service) ? "workflow" : "subscriber" : void 0;
|
|
11339
11497
|
let queueSubscriptions;
|
|
11340
11498
|
if (queueSidecarKind) {
|
|
11341
11499
|
let useQueueServing = !legacyProject;
|
|
@@ -11424,7 +11582,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
11424
11582
|
};
|
|
11425
11583
|
|
|
11426
11584
|
// src/quirks/index.ts
|
|
11427
|
-
var
|
|
11585
|
+
var import_build_utils20 = require("@vercel/build-utils");
|
|
11428
11586
|
var import_python_analysis14 = require("@vercel/python-analysis");
|
|
11429
11587
|
|
|
11430
11588
|
// src/quirks/matplotlib.ts
|
|
@@ -11440,7 +11598,7 @@ var matplotlibQuirk = {
|
|
|
11440
11598
|
// src/quirks/litellm.ts
|
|
11441
11599
|
var import_fs16 = __toESM(require("fs"));
|
|
11442
11600
|
var import_path16 = require("path");
|
|
11443
|
-
var
|
|
11601
|
+
var import_build_utils18 = require("@vercel/build-utils");
|
|
11444
11602
|
var LAMBDA_ROOT = "/var/task";
|
|
11445
11603
|
var CONFIG_CANDIDATES = [
|
|
11446
11604
|
"litellm_config.yaml",
|
|
@@ -11475,24 +11633,24 @@ var litellmQuirk = {
|
|
|
11475
11633
|
);
|
|
11476
11634
|
try {
|
|
11477
11635
|
await import_fs16.default.promises.access(schemaPath);
|
|
11478
|
-
(0,
|
|
11636
|
+
(0, import_build_utils18.debug)(`LiteLLM quirk: found schema at ${schemaPath}`);
|
|
11479
11637
|
buildEnv.PRISMA_SCHEMA_PATH = schemaPath;
|
|
11480
11638
|
break;
|
|
11481
11639
|
} catch {
|
|
11482
11640
|
}
|
|
11483
11641
|
}
|
|
11484
11642
|
if (!buildEnv.PRISMA_SCHEMA_PATH) {
|
|
11485
|
-
(0,
|
|
11643
|
+
(0, import_build_utils18.debug)("LiteLLM quirk: schema.prisma not found in any site-packages");
|
|
11486
11644
|
}
|
|
11487
11645
|
if (!process.env.CONFIG_FILE_PATH) {
|
|
11488
11646
|
const configName = await findConfigFile(ctx.workPath);
|
|
11489
11647
|
if (configName) {
|
|
11490
|
-
(0,
|
|
11648
|
+
(0, import_build_utils18.debug)(`LiteLLM quirk: found config at ${configName}`);
|
|
11491
11649
|
buildEnv.CONFIG_FILE_PATH = (0, import_path16.join)(ctx.workPath, configName);
|
|
11492
11650
|
env.CONFIG_FILE_PATH = import_path16.posix.join(LAMBDA_ROOT, configName);
|
|
11493
11651
|
}
|
|
11494
11652
|
} else {
|
|
11495
|
-
(0,
|
|
11653
|
+
(0, import_build_utils18.debug)(
|
|
11496
11654
|
`LiteLLM quirk: CONFIG_FILE_PATH already set to ${process.env.CONFIG_FILE_PATH}`
|
|
11497
11655
|
);
|
|
11498
11656
|
}
|
|
@@ -11504,7 +11662,7 @@ var litellmQuirk = {
|
|
|
11504
11662
|
var import_fs17 = __toESM(require("fs"));
|
|
11505
11663
|
var import_path17 = require("path");
|
|
11506
11664
|
var import_execa7 = __toESM(require_execa());
|
|
11507
|
-
var
|
|
11665
|
+
var import_build_utils19 = require("@vercel/build-utils");
|
|
11508
11666
|
var import_python_analysis13 = require("@vercel/python-analysis");
|
|
11509
11667
|
function execErrorMessage(err) {
|
|
11510
11668
|
if (err != null && typeof err === "object" && "stderr" in err) {
|
|
@@ -11547,7 +11705,7 @@ async function findUserSchema(workPath) {
|
|
|
11547
11705
|
await import_fs17.default.promises.access(resolved);
|
|
11548
11706
|
return resolved;
|
|
11549
11707
|
} catch {
|
|
11550
|
-
(0,
|
|
11708
|
+
(0, import_build_utils19.debug)(`PRISMA_SCHEMA_PATH=${envPath} not found at ${resolved}`);
|
|
11551
11709
|
return null;
|
|
11552
11710
|
}
|
|
11553
11711
|
}
|
|
@@ -11651,7 +11809,7 @@ var prismaQuirk = {
|
|
|
11651
11809
|
dummySchemaPath,
|
|
11652
11810
|
buildDummySchema(generatedDir)
|
|
11653
11811
|
);
|
|
11654
|
-
(0,
|
|
11812
|
+
(0, import_build_utils19.debug)(`Running prisma generate (dummy) with cache dir: ${cacheDir}`);
|
|
11655
11813
|
try {
|
|
11656
11814
|
const dummyResult = await (0, import_execa7.default)(
|
|
11657
11815
|
pythonPath,
|
|
@@ -11663,11 +11821,11 @@ var prismaQuirk = {
|
|
|
11663
11821
|
}
|
|
11664
11822
|
);
|
|
11665
11823
|
if (dummyResult.stdout)
|
|
11666
|
-
(0,
|
|
11824
|
+
(0, import_build_utils19.debug)(`prisma generate (dummy) stdout: ${dummyResult.stdout}`);
|
|
11667
11825
|
if (dummyResult.stderr)
|
|
11668
|
-
(0,
|
|
11826
|
+
(0, import_build_utils19.debug)(`prisma generate (dummy) stderr: ${dummyResult.stderr}`);
|
|
11669
11827
|
} catch (err) {
|
|
11670
|
-
throw new
|
|
11828
|
+
throw new import_build_utils19.NowBuildError({
|
|
11671
11829
|
code: "PRISMA_GENERATE_FAILED",
|
|
11672
11830
|
message: `Prisma engine download failed during \`prisma generate\`. Check that your prisma version is compatible with this Python version.
|
|
11673
11831
|
` + execErrorMessage(err)
|
|
@@ -11686,22 +11844,22 @@ var prismaQuirk = {
|
|
|
11686
11844
|
const destPath = (0, import_path17.join)(cacheDir, runtimeName);
|
|
11687
11845
|
try {
|
|
11688
11846
|
await import_fs17.default.promises.access(destPath);
|
|
11689
|
-
(0,
|
|
11847
|
+
(0, import_build_utils19.debug)(`Engine binary: ${runtimeName} already exists, skipping`);
|
|
11690
11848
|
} catch {
|
|
11691
|
-
(0,
|
|
11849
|
+
(0, import_build_utils19.debug)(`Engine binary: copying ${entry} -> ${runtimeName}`);
|
|
11692
11850
|
await import_fs17.default.promises.copyFile(srcPath, destPath);
|
|
11693
11851
|
}
|
|
11694
11852
|
engineCopied = true;
|
|
11695
11853
|
}
|
|
11696
11854
|
} catch (err) {
|
|
11697
|
-
throw new
|
|
11855
|
+
throw new import_build_utils19.NowBuildError({
|
|
11698
11856
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
11699
11857
|
message: `could not read Prisma engine directory "${nodeModulesDir}". This may indicate an incompatible prisma version.
|
|
11700
11858
|
` + (err instanceof Error ? err.message : String(err))
|
|
11701
11859
|
});
|
|
11702
11860
|
}
|
|
11703
11861
|
if (!engineCopied) {
|
|
11704
|
-
throw new
|
|
11862
|
+
throw new import_build_utils19.NowBuildError({
|
|
11705
11863
|
code: "PRISMA_ENGINE_NOT_FOUND",
|
|
11706
11864
|
message: `could not find engine binary matching "${srcBinaryPrefix}*" in "${nodeModulesDir}". This may indicate an incompatible prisma version or an unsupported platform (${process.arch}).`
|
|
11707
11865
|
});
|
|
@@ -11728,14 +11886,14 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
11728
11886
|
pythonEnv
|
|
11729
11887
|
);
|
|
11730
11888
|
if (clientAlreadyGenerated) {
|
|
11731
|
-
(0,
|
|
11889
|
+
(0, import_build_utils19.debug)(
|
|
11732
11890
|
"Prisma quirk: client already generated, skipping user schema generate"
|
|
11733
11891
|
);
|
|
11734
11892
|
shouldGenerate = false;
|
|
11735
11893
|
}
|
|
11736
11894
|
}
|
|
11737
11895
|
if (shouldGenerate) {
|
|
11738
|
-
(0,
|
|
11896
|
+
(0, import_build_utils19.debug)(`Running prisma generate with user schema: ${userSchema}`);
|
|
11739
11897
|
try {
|
|
11740
11898
|
const userResult = await (0, import_execa7.default)(
|
|
11741
11899
|
pythonPath,
|
|
@@ -11747,11 +11905,11 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
11747
11905
|
}
|
|
11748
11906
|
);
|
|
11749
11907
|
if (userResult.stdout)
|
|
11750
|
-
(0,
|
|
11908
|
+
(0, import_build_utils19.debug)(`prisma generate stdout: ${userResult.stdout}`);
|
|
11751
11909
|
if (userResult.stderr)
|
|
11752
|
-
(0,
|
|
11910
|
+
(0, import_build_utils19.debug)(`prisma generate stderr: ${userResult.stderr}`);
|
|
11753
11911
|
} catch (err) {
|
|
11754
|
-
throw new
|
|
11912
|
+
throw new import_build_utils19.NowBuildError({
|
|
11755
11913
|
code: "PRISMA_GENERATE_FAILED",
|
|
11756
11914
|
message: `\`prisma generate\` failed for schema "${userSchema}".
|
|
11757
11915
|
` + execErrorMessage(err)
|
|
@@ -11767,7 +11925,7 @@ echo "OpenSSL ${RUNTIME_OPENSSL_VERSION}.0 1 Jan 2024 (Library: OpenSSL ${RUNTIM
|
|
|
11767
11925
|
);
|
|
11768
11926
|
const count = await (0, import_python_analysis13.extendDistRecord)(sitePackages, "prisma", allFiles);
|
|
11769
11927
|
if (count > 0) {
|
|
11770
|
-
(0,
|
|
11928
|
+
(0, import_build_utils19.debug)(`Appended ${count} entries to prisma RECORD`);
|
|
11771
11929
|
}
|
|
11772
11930
|
} catch (err) {
|
|
11773
11931
|
console.warn(
|
|
@@ -11861,13 +12019,13 @@ async function runQuirks(ctx) {
|
|
|
11861
12019
|
(0, import_python_analysis14.normalizePackageName)(quirk.dependency)
|
|
11862
12020
|
);
|
|
11863
12021
|
if (!installed) {
|
|
11864
|
-
(0,
|
|
12022
|
+
(0, import_build_utils20.debug)(`Quirk "${quirk.dependency}": not installed, skipping`);
|
|
11865
12023
|
}
|
|
11866
12024
|
return installed;
|
|
11867
12025
|
});
|
|
11868
12026
|
const sorted = toposortQuirks(activated);
|
|
11869
12027
|
for (const quirk of sorted) {
|
|
11870
|
-
(0,
|
|
12028
|
+
(0, import_build_utils20.debug)(`Quirk "${quirk.dependency}": detected, running fix-up`);
|
|
11871
12029
|
const result = await quirk.run(ctx);
|
|
11872
12030
|
if (result.env) {
|
|
11873
12031
|
Object.assign(mergedEnv, result.env);
|
|
@@ -11891,7 +12049,7 @@ async function runQuirks(ctx) {
|
|
|
11891
12049
|
var import_fs18 = __toESM(require("fs"));
|
|
11892
12050
|
var import_path18 = require("path");
|
|
11893
12051
|
var import_execa8 = __toESM(require_execa());
|
|
11894
|
-
var
|
|
12052
|
+
var import_build_utils21 = require("@vercel/build-utils");
|
|
11895
12053
|
var scriptPath2 = (0, import_path18.join)(__dirname, "..", "templates", "vc_django_settings.py");
|
|
11896
12054
|
var script2 = import_fs18.default.readFileSync(scriptPath2, "utf-8");
|
|
11897
12055
|
async function getDjangoSettings(projectDir, env) {
|
|
@@ -11983,7 +12141,7 @@ async function runDjangoCollectStatic(venvPath, workPath, djangoPath, env, outpu
|
|
|
11983
12141
|
await import_fs18.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
|
|
11984
12142
|
await import_fs18.default.promises.copyFile(manifestSrc, manifestDest);
|
|
11985
12143
|
manifestRelPath = (0, import_path18.relative)(workPath, manifestDest);
|
|
11986
|
-
(0,
|
|
12144
|
+
(0, import_build_utils21.debug)(`Copied staticfiles.json to ${manifestDest} for Lambda bundle`);
|
|
11987
12145
|
}
|
|
11988
12146
|
return {
|
|
11989
12147
|
staticSourceDirs,
|
|
@@ -11998,7 +12156,7 @@ var import_pep4405 = __toESM(require_pep440());
|
|
|
11998
12156
|
var import_fs19 = __toESM(require("fs"));
|
|
11999
12157
|
var import_path19 = require("path");
|
|
12000
12158
|
var import_execa9 = __toESM(require_execa());
|
|
12001
|
-
var
|
|
12159
|
+
var import_build_utils22 = require("@vercel/build-utils");
|
|
12002
12160
|
var scriptPath3 = (0, import_path19.join)(__dirname, "..", "templates", "vc_fastapi_static.py");
|
|
12003
12161
|
var STATIC_FILES_DEBUG_LABEL = "FastAPI";
|
|
12004
12162
|
var STATIC_COLLECTION_WARNING = "Warning: FastAPI static file collection failed. Static files will not be served from the CDN.";
|
|
@@ -12022,19 +12180,19 @@ async function getFastAPIStaticDiscovery(venvPath, entrypointAbs, variableName,
|
|
|
12022
12180
|
{ env, cwd: workPath }
|
|
12023
12181
|
);
|
|
12024
12182
|
if (stderr) {
|
|
12025
|
-
(0,
|
|
12183
|
+
(0, import_build_utils22.debug)(`FastAPI shim stderr:
|
|
12026
12184
|
${stderr}`);
|
|
12027
12185
|
}
|
|
12028
12186
|
const raw = await import_fs19.default.promises.readFile(outputPath, "utf8");
|
|
12029
12187
|
const parsed = JSON.parse(raw);
|
|
12030
|
-
(0,
|
|
12188
|
+
(0, import_build_utils22.debug)(`FastAPI: discovered: ${JSON.stringify(parsed)}`);
|
|
12031
12189
|
return parsed;
|
|
12032
12190
|
} catch (err) {
|
|
12033
12191
|
console.error(STATIC_COLLECTION_WARNING);
|
|
12034
|
-
(0,
|
|
12192
|
+
(0, import_build_utils22.debug)(
|
|
12035
12193
|
`FastAPI: static discovery failed: ${err?.stderr ?? err?.message ?? err}`
|
|
12036
12194
|
);
|
|
12037
|
-
return
|
|
12195
|
+
return import_build_utils22.EMPTY_DISCOVERY;
|
|
12038
12196
|
} finally {
|
|
12039
12197
|
await import_fs19.default.promises.rm(outputPath, { force: true });
|
|
12040
12198
|
}
|
|
@@ -12048,15 +12206,15 @@ async function runFastAPICollectStatic(venvPath, workPath, env, outputStaticDir,
|
|
|
12048
12206
|
workPath,
|
|
12049
12207
|
suppressMiddlewareMounts
|
|
12050
12208
|
);
|
|
12051
|
-
return (0,
|
|
12209
|
+
return (0, import_build_utils22.promoteStaticFiles)(discovery, outputStaticDir, {
|
|
12052
12210
|
debugLabel: STATIC_FILES_DEBUG_LABEL
|
|
12053
12211
|
});
|
|
12054
12212
|
}
|
|
12055
12213
|
function getFastAPICdnBundle(collectedMounts, workPath, fastapiConfig) {
|
|
12056
|
-
const redirects = (0,
|
|
12214
|
+
const redirects = (0, import_build_utils22.staticDirectoryRedirects)(collectedMounts, {
|
|
12057
12215
|
debugLabel: STATIC_FILES_DEBUG_LABEL
|
|
12058
12216
|
});
|
|
12059
|
-
const { excludePatterns, directoryStubs } = fastapiConfig?.static?.exclude === true ? (0,
|
|
12217
|
+
const { excludePatterns, directoryStubs } = fastapiConfig?.static?.exclude === true ? (0, import_build_utils22.staticBundleExclusions)(collectedMounts, workPath, [
|
|
12060
12218
|
"index.html",
|
|
12061
12219
|
"404.html"
|
|
12062
12220
|
]) : { excludePatterns: [], directoryStubs: {} };
|
|
@@ -12119,7 +12277,7 @@ function fillBytecodeWithinCapacity(files, rankedItems, capacity) {
|
|
|
12119
12277
|
|
|
12120
12278
|
// src/compileall.ts
|
|
12121
12279
|
var import_execa10 = __toESM(require_execa());
|
|
12122
|
-
var
|
|
12280
|
+
var import_build_utils23 = require("@vercel/build-utils");
|
|
12123
12281
|
var import_fs20 = __toESM(require("fs"));
|
|
12124
12282
|
var import_os3 = require("os");
|
|
12125
12283
|
var import_path20 = require("path");
|
|
@@ -12176,18 +12334,18 @@ async function runCompileAll({
|
|
|
12176
12334
|
const raw = await import_fs20.default.promises.readFile(timingsPath, "utf8");
|
|
12177
12335
|
timings = new Map(Object.entries(JSON.parse(raw)));
|
|
12178
12336
|
} catch (err) {
|
|
12179
|
-
(0,
|
|
12337
|
+
(0, import_build_utils23.debug)(`compileall timings unavailable: ${String(err)}`);
|
|
12180
12338
|
}
|
|
12181
12339
|
return { success: true, timings };
|
|
12182
12340
|
} catch (err) {
|
|
12183
|
-
(0,
|
|
12341
|
+
(0, import_build_utils23.debug)(`compileall error details: ${JSON.stringify(err)}`);
|
|
12184
12342
|
return { success: false };
|
|
12185
12343
|
} finally {
|
|
12186
12344
|
if (tempDir) {
|
|
12187
12345
|
try {
|
|
12188
12346
|
await import_fs20.default.promises.rm(tempDir, { recursive: true, force: true });
|
|
12189
12347
|
} catch (err) {
|
|
12190
|
-
(0,
|
|
12348
|
+
(0, import_build_utils23.debug)(`compileall temporary file cleanup error: ${String(err)}`);
|
|
12191
12349
|
}
|
|
12192
12350
|
}
|
|
12193
12351
|
}
|
|
@@ -12292,7 +12450,7 @@ async function collectAppPrefixBytecodeFiles({
|
|
|
12292
12450
|
for (const result of results) {
|
|
12293
12451
|
if (!result)
|
|
12294
12452
|
continue;
|
|
12295
|
-
const file = new
|
|
12453
|
+
const file = new import_build_utils23.FileFsRef({
|
|
12296
12454
|
fsPath: result.srcFsPath,
|
|
12297
12455
|
size: result.size
|
|
12298
12456
|
});
|
|
@@ -12350,7 +12508,7 @@ async function collectAppBytecodeFiles({
|
|
|
12350
12508
|
for (const result of results) {
|
|
12351
12509
|
if (!result)
|
|
12352
12510
|
continue;
|
|
12353
|
-
const file = new
|
|
12511
|
+
const file = new import_build_utils23.FileFsRef({
|
|
12354
12512
|
fsPath: result.srcFsPath,
|
|
12355
12513
|
size: result.size
|
|
12356
12514
|
});
|
|
@@ -12371,7 +12529,7 @@ async function collectAppBytecodeFiles({
|
|
|
12371
12529
|
// src/installed-distributions.ts
|
|
12372
12530
|
var import_fs21 = __toESM(require("fs"));
|
|
12373
12531
|
var import_path21 = require("path");
|
|
12374
|
-
var
|
|
12532
|
+
var import_build_utils24 = require("@vercel/build-utils");
|
|
12375
12533
|
var import_python_analysis15 = require("@vercel/python-analysis");
|
|
12376
12534
|
var STRIP_BASENAMES = /* @__PURE__ */ new Set([
|
|
12377
12535
|
"py.typed",
|
|
@@ -12535,12 +12693,12 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
12535
12693
|
for (const result of results) {
|
|
12536
12694
|
if (!result)
|
|
12537
12695
|
continue;
|
|
12538
|
-
vendorFiles[result.bundlePath] = new
|
|
12696
|
+
vendorFiles[result.bundlePath] = new import_build_utils24.FileFsRef({
|
|
12539
12697
|
fsPath: result.srcFsPath,
|
|
12540
12698
|
size: result.size
|
|
12541
12699
|
});
|
|
12542
12700
|
}
|
|
12543
|
-
(0,
|
|
12701
|
+
(0, import_build_utils24.debug)(
|
|
12544
12702
|
`Mirrored ${Object.keys(vendorFiles).length} files` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
12545
12703
|
);
|
|
12546
12704
|
return vendorFiles;
|
|
@@ -12623,7 +12781,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
12623
12781
|
}
|
|
12624
12782
|
}
|
|
12625
12783
|
const result = await this.collectExistingBytecode(pending);
|
|
12626
|
-
(0,
|
|
12784
|
+
(0, import_build_utils24.debug)(
|
|
12627
12785
|
`Collected ${Object.keys(result.files).length} bytecode files (${(result.totalSize / (1024 * 1024)).toFixed(2)} MB)` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
12628
12786
|
);
|
|
12629
12787
|
return result;
|
|
@@ -12670,7 +12828,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
12670
12828
|
}
|
|
12671
12829
|
}
|
|
12672
12830
|
const result = await this.collectExistingBytecode(pending);
|
|
12673
|
-
(0,
|
|
12831
|
+
(0, import_build_utils24.debug)(
|
|
12674
12832
|
`Collected ${Object.keys(result.files).length} prefix bytecode files (${(result.totalSize / (1024 * 1024)).toFixed(2)} MB) for runtime root ${runtimeRoot}` + (includePackages ? ` from ${includePackages.length} packages` : "")
|
|
12675
12833
|
);
|
|
12676
12834
|
return result;
|
|
@@ -12708,7 +12866,7 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
12708
12866
|
for (const result of results) {
|
|
12709
12867
|
if (!result)
|
|
12710
12868
|
continue;
|
|
12711
|
-
const file = new
|
|
12869
|
+
const file = new import_build_utils24.FileFsRef({
|
|
12712
12870
|
fsPath: result.srcFsPath,
|
|
12713
12871
|
size: result.size
|
|
12714
12872
|
});
|
|
@@ -12732,14 +12890,14 @@ var InstalledPythonDistributions = class _InstalledPythonDistributions {
|
|
|
12732
12890
|
|
|
12733
12891
|
// src/import-closure.ts
|
|
12734
12892
|
var import_path22 = require("path");
|
|
12735
|
-
var
|
|
12893
|
+
var import_build_utils25 = require("@vercel/build-utils");
|
|
12736
12894
|
var RUNTIME_BOOTSTRAP_MODULE = "vercel_runtime.vc_init";
|
|
12737
12895
|
var IMPORT_CLOSURE_TIMEOUT_MS = 3e4;
|
|
12738
12896
|
async function withTimeout(promise, ms, label) {
|
|
12739
12897
|
let timer;
|
|
12740
12898
|
const timeout = new Promise((resolvePromise) => {
|
|
12741
12899
|
timer = setTimeout(() => {
|
|
12742
|
-
(0,
|
|
12900
|
+
(0, import_build_utils25.debug)(`${label} timed out after ${ms}ms`);
|
|
12743
12901
|
resolvePromise(void 0);
|
|
12744
12902
|
}, ms);
|
|
12745
12903
|
});
|
|
@@ -12797,7 +12955,7 @@ function getImportClosureOptions({
|
|
|
12797
12955
|
}
|
|
12798
12956
|
|
|
12799
12957
|
// src/index.ts
|
|
12800
|
-
var
|
|
12958
|
+
var import_build_utils27 = require("@vercel/build-utils");
|
|
12801
12959
|
var writeFile = import_fs22.default.promises.writeFile;
|
|
12802
12960
|
var PYTHON_ENTRYPOINT_DOCS_URL2 = "https://vercel.com/docs/functions/runtimes/python#python-entrypoints";
|
|
12803
12961
|
var version = -1;
|
|
@@ -12820,7 +12978,7 @@ async function getDevSidecars({
|
|
|
12820
12978
|
const framework = build2.config?.framework;
|
|
12821
12979
|
const isPyprojectEntrypoint = (0, import_path23.basename)(build2.src ?? "") === "pyproject.toml";
|
|
12822
12980
|
const isPyprojectService = service !== void 0 && (0, import_path23.basename)(service.entrypoint ?? "") === "pyproject.toml";
|
|
12823
|
-
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0,
|
|
12981
|
+
if (build2.config?.middleware === true || service !== void 0 && !isPyprojectService || service === void 0 && !isPyprojectEntrypoint && (typeof framework !== "string" || !(0, import_build_utils26.isPythonFramework)(framework))) {
|
|
12824
12982
|
return [];
|
|
12825
12983
|
}
|
|
12826
12984
|
const legacyWorkers = await isLegacyWorkersProject(workPath);
|
|
@@ -12902,7 +13060,7 @@ var frameworkHooks = {
|
|
|
12902
13060
|
let baseDir = detected?.baseDir;
|
|
12903
13061
|
if (baseDir === void 0) {
|
|
12904
13062
|
if (!import_fs22.default.existsSync((0, import_path23.join)(workPath, "manage.py"))) {
|
|
12905
|
-
(0,
|
|
13063
|
+
(0, import_build_utils26.debug)("Django hook: no manage.py detected, skipping");
|
|
12906
13064
|
return;
|
|
12907
13065
|
}
|
|
12908
13066
|
baseDir = "";
|
|
@@ -12919,13 +13077,13 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
|
|
|
12919
13077
|
} else {
|
|
12920
13078
|
detail = err?.stderr || err?.message || String(err);
|
|
12921
13079
|
}
|
|
12922
|
-
throw new
|
|
13080
|
+
throw new import_build_utils26.NowBuildError({
|
|
12923
13081
|
code: "DJANGO_SETTINGS_FAILED",
|
|
12924
13082
|
message: `Failed to read Django application settings from ${djangoPath}/manage.py:
|
|
12925
13083
|
${detail}`
|
|
12926
13084
|
});
|
|
12927
13085
|
}
|
|
12928
|
-
(0,
|
|
13086
|
+
(0, import_build_utils26.debug)(`Django settings: ${JSON.stringify(settingsResult)}`);
|
|
12929
13087
|
const { djangoSettings, settingsModule, djangoVersion } = settingsResult;
|
|
12930
13088
|
if (djangoVersion) {
|
|
12931
13089
|
console.log(`Django ${djangoVersion.join(".")} detected`);
|
|
@@ -12937,7 +13095,7 @@ ${detail}`
|
|
|
12937
13095
|
const variableName = parts.at(-1);
|
|
12938
13096
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
12939
13097
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
12940
|
-
(0,
|
|
13098
|
+
(0, import_build_utils26.debug)(`Django hook: ASGI entrypoint: ${ep} (variable: ${variableName})`);
|
|
12941
13099
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
12942
13100
|
} else {
|
|
12943
13101
|
const wsgiApp = djangoSettings["WSGI_APPLICATION"];
|
|
@@ -12946,7 +13104,7 @@ ${detail}`
|
|
|
12946
13104
|
const variableName = parts.at(-1);
|
|
12947
13105
|
const rel = `${parts.slice(0, -1).join("/")}.py`;
|
|
12948
13106
|
const ep = baseDir ? `${baseDir}/${rel}` : rel;
|
|
12949
|
-
(0,
|
|
13107
|
+
(0, import_build_utils26.debug)(
|
|
12950
13108
|
`Django hook: WSGI entrypoint: ${ep} (variable: ${variableName})`
|
|
12951
13109
|
);
|
|
12952
13110
|
resolvedEntrypoint = { entrypoint: ep, variableName };
|
|
@@ -12987,27 +13145,27 @@ ${detail}`
|
|
|
12987
13145
|
pyprojectData
|
|
12988
13146
|
}) => {
|
|
12989
13147
|
if (!detected?.entrypoint || !workPath || !venvPath) {
|
|
12990
|
-
(0,
|
|
13148
|
+
(0, import_build_utils26.debug)(
|
|
12991
13149
|
`FastAPI hook: skipping \u2014 detected.entrypoint=${JSON.stringify(detected?.entrypoint)}, workPath=${workPath}, venvPath=${venvPath}`
|
|
12992
13150
|
);
|
|
12993
13151
|
return;
|
|
12994
13152
|
}
|
|
12995
13153
|
const { entrypoint: entrypointRel, variableName } = detected.entrypoint;
|
|
12996
|
-
(0,
|
|
13154
|
+
(0, import_build_utils26.debug)(
|
|
12997
13155
|
`FastAPI hook: entrypoint=${entrypointRel}, variableName=${variableName}`
|
|
12998
13156
|
);
|
|
12999
13157
|
const entrypointAbs = (0, import_path23.join)(workPath, entrypointRel);
|
|
13000
13158
|
const outputStaticDir = (0, import_path23.join)(workPath, ".vercel", "output", "static");
|
|
13001
13159
|
const cdnEnv = process.env.VERCEL_FASTAPI_STATIC_CDN?.toLowerCase();
|
|
13002
13160
|
if (cdnEnv !== "1" && cdnEnv !== "true") {
|
|
13003
|
-
(0,
|
|
13161
|
+
(0, import_build_utils26.debug)(
|
|
13004
13162
|
"FastAPI: VERCEL_FASTAPI_STATIC_CDN not set, skipping static CDN collection"
|
|
13005
13163
|
);
|
|
13006
13164
|
return;
|
|
13007
13165
|
}
|
|
13008
13166
|
const staticCdn = pyprojectData?.tool?.vercel?.fastapi?.static?.cdn;
|
|
13009
13167
|
if (staticCdn === false) {
|
|
13010
|
-
(0,
|
|
13168
|
+
(0, import_build_utils26.debug)(
|
|
13011
13169
|
"FastAPI: static.cdn = false in pyproject.toml, skipping CDN collection"
|
|
13012
13170
|
);
|
|
13013
13171
|
return;
|
|
@@ -13087,12 +13245,12 @@ async function downloadFilesInWorkPath({
|
|
|
13087
13245
|
files,
|
|
13088
13246
|
meta = {}
|
|
13089
13247
|
}) {
|
|
13090
|
-
(0,
|
|
13091
|
-
let downloadedFiles = await (0,
|
|
13248
|
+
(0, import_build_utils26.debug)("Downloading user files...");
|
|
13249
|
+
let downloadedFiles = await (0, import_build_utils26.download)(files, workPath, meta);
|
|
13092
13250
|
if (meta.isDev && entrypoint) {
|
|
13093
13251
|
const normalizedEntrypoint = entrypoint.endsWith(".py") ? entrypoint : `${entrypoint}.py`;
|
|
13094
13252
|
if (!hasProp(downloadedFiles, entrypoint) && !hasProp(downloadedFiles, normalizedEntrypoint)) {
|
|
13095
|
-
throw new
|
|
13253
|
+
throw new import_build_utils26.NowBuildError({
|
|
13096
13254
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
13097
13255
|
message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
|
|
13098
13256
|
link: PYTHON_ENTRYPOINT_DOCS_URL2,
|
|
@@ -13102,8 +13260,8 @@ async function downloadFilesInWorkPath({
|
|
|
13102
13260
|
const { devCacheDir = (0, import_path23.join)(workPath, ".now", "cache") } = meta;
|
|
13103
13261
|
const cacheKey = (0, import_path23.basename)(entrypoint).replace(/\./g, "_");
|
|
13104
13262
|
const destCache = (0, import_path23.join)(devCacheDir, cacheKey);
|
|
13105
|
-
await (0,
|
|
13106
|
-
downloadedFiles = await (0,
|
|
13263
|
+
await (0, import_build_utils26.download)(downloadedFiles, destCache);
|
|
13264
|
+
downloadedFiles = await (0, import_build_utils26.glob)("**", destCache);
|
|
13107
13265
|
workPath = destCache;
|
|
13108
13266
|
}
|
|
13109
13267
|
return workPath;
|
|
@@ -13132,19 +13290,21 @@ function getMatchingFunction(config, entrypoint) {
|
|
|
13132
13290
|
return;
|
|
13133
13291
|
}
|
|
13134
13292
|
const candidates = entrypoint.endsWith(".py") ? [entrypoint, entrypoint.slice(0, -".py".length)] : [entrypoint];
|
|
13135
|
-
return (0,
|
|
13293
|
+
return (0, import_build_utils26.findMatchingFunction)(config?.functions, candidates);
|
|
13136
13294
|
}
|
|
13137
13295
|
function normalizeGlobs(value) {
|
|
13138
13296
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : typeof value === "string" ? [value] : [];
|
|
13139
13297
|
}
|
|
13140
13298
|
async function getPythonLambdaOptions({
|
|
13141
13299
|
config,
|
|
13142
|
-
entrypoint
|
|
13300
|
+
entrypoint,
|
|
13301
|
+
isScheduleEntrypoint = false
|
|
13143
13302
|
}) {
|
|
13144
13303
|
const match = getMatchingFunction(config, entrypoint);
|
|
13145
|
-
const lambdaOptions = await (0,
|
|
13304
|
+
const lambdaOptions = await (0, import_build_utils26.getLambdaOptionsFromFunction)({
|
|
13146
13305
|
sourceFile: match?.sourceFile ?? entrypoint,
|
|
13147
|
-
config
|
|
13306
|
+
config,
|
|
13307
|
+
isScheduleEntrypoint
|
|
13148
13308
|
});
|
|
13149
13309
|
delete lambdaOptions.architecture;
|
|
13150
13310
|
return lambdaOptions;
|
|
@@ -13165,7 +13325,7 @@ async function installInjectedPackage({
|
|
|
13165
13325
|
const dep = envOverride || (isLocalDev ? localDir : requirement);
|
|
13166
13326
|
const extras = envOverride || isLocalDev ? [] : extraRequirements;
|
|
13167
13327
|
const noExclude = ["--exclude-newer-package", `${name}=false`];
|
|
13168
|
-
(0,
|
|
13328
|
+
(0, import_build_utils26.debug)(`Installing ${dep}`);
|
|
13169
13329
|
await uv.pip({
|
|
13170
13330
|
venvPath,
|
|
13171
13331
|
projectDir,
|
|
@@ -13234,7 +13394,7 @@ async function setupPythonToolchain({
|
|
|
13234
13394
|
const hasCachedUv = import_fs22.default.existsSync(uvCacheDir);
|
|
13235
13395
|
const restoredCache = hasCachedVenv && hasCachedUv ? "both" : hasCachedVenv ? "venv" : hasCachedUv ? "uv" : "none";
|
|
13236
13396
|
if (hasCachedVenv || hasCachedUv) {
|
|
13237
|
-
(0,
|
|
13397
|
+
(0, import_build_utils26.debug)(
|
|
13238
13398
|
`Build cache detected: venv=${hasCachedVenv}, uv-cache=${hasCachedUv}`
|
|
13239
13399
|
);
|
|
13240
13400
|
}
|
|
@@ -13337,7 +13497,7 @@ async function packFunctionBundle({
|
|
|
13337
13497
|
"**/yarn.lock",
|
|
13338
13498
|
"**/package-lock.json"
|
|
13339
13499
|
];
|
|
13340
|
-
const files = await (0,
|
|
13500
|
+
const files = await (0, import_build_utils26.glob)("**", {
|
|
13341
13501
|
cwd: workPath,
|
|
13342
13502
|
ignore: [...predefinedExcludes, ...additionalExcludes ?? []]
|
|
13343
13503
|
});
|
|
@@ -13431,12 +13591,12 @@ async function packFunctionBundle({
|
|
|
13431
13591
|
workPath,
|
|
13432
13592
|
sitePackageDirs
|
|
13433
13593
|
);
|
|
13434
|
-
(0,
|
|
13594
|
+
(0, import_build_utils26.debug)(
|
|
13435
13595
|
`import closure: ${closure.files.size} files, ${keys.size} bundled modules` + (closure.truncated ? " (truncated)" : "")
|
|
13436
13596
|
);
|
|
13437
13597
|
return keys;
|
|
13438
13598
|
} catch (err) {
|
|
13439
|
-
(0,
|
|
13599
|
+
(0, import_build_utils26.debug)(
|
|
13440
13600
|
`import closure unavailable, ranking by compile density only: ${err}`
|
|
13441
13601
|
);
|
|
13442
13602
|
return void 0;
|
|
@@ -13462,7 +13622,7 @@ async function packFunctionBundle({
|
|
|
13462
13622
|
console.log("Optimizing Python bundle...");
|
|
13463
13623
|
const analysisDisabled = isBytecodeAnalysisDisabled();
|
|
13464
13624
|
if (analysisDisabled) {
|
|
13465
|
-
(0,
|
|
13625
|
+
(0, import_build_utils26.debug)(
|
|
13466
13626
|
"bytecode analysis disabled via VERCEL_PYTHON_DISABLE_BYTECODE_ANALYSIS; ranking by size"
|
|
13467
13627
|
);
|
|
13468
13628
|
}
|
|
@@ -13512,7 +13672,7 @@ async function packFunctionBundle({
|
|
|
13512
13672
|
console.log(
|
|
13513
13673
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
13514
13674
|
);
|
|
13515
|
-
(0,
|
|
13675
|
+
(0, import_build_utils26.debug)(`bytecode precompilation error details: ${err}`);
|
|
13516
13676
|
}
|
|
13517
13677
|
};
|
|
13518
13678
|
const runPrefixCompileAndFill = async (bundleResult) => {
|
|
@@ -13524,7 +13684,7 @@ async function packFunctionBundle({
|
|
|
13524
13684
|
const currentSize = await calculateBundleSize(files);
|
|
13525
13685
|
const remainingCapacity = BYTECODE_FILL_CEILING_BYTES - currentSize;
|
|
13526
13686
|
if (remainingCapacity <= 0) {
|
|
13527
|
-
(0,
|
|
13687
|
+
(0, import_build_utils26.debug)(
|
|
13528
13688
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
13529
13689
|
);
|
|
13530
13690
|
return;
|
|
@@ -13578,7 +13738,7 @@ async function packFunctionBundle({
|
|
|
13578
13738
|
console.log(
|
|
13579
13739
|
"Bytecode precompilation failed; continuing without precompiled bytecode."
|
|
13580
13740
|
);
|
|
13581
|
-
(0,
|
|
13741
|
+
(0, import_build_utils26.debug)(`bytecode precompilation error details: ${err}`);
|
|
13582
13742
|
}
|
|
13583
13743
|
};
|
|
13584
13744
|
const announceLargeFunction = () => console.log(
|
|
@@ -13610,7 +13770,7 @@ async function packFunctionBundle({
|
|
|
13610
13770
|
...bundleResult.bundledPublicPackages ?? []
|
|
13611
13771
|
]);
|
|
13612
13772
|
} else {
|
|
13613
|
-
(0,
|
|
13773
|
+
(0, import_build_utils26.debug)(
|
|
13614
13774
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(currentSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
13615
13775
|
);
|
|
13616
13776
|
}
|
|
@@ -13632,7 +13792,7 @@ async function packFunctionBundle({
|
|
|
13632
13792
|
if (capacity > 0) {
|
|
13633
13793
|
await runAdjacentCompileAndFill(BYTECODE_FILL_CEILING_BYTES);
|
|
13634
13794
|
} else {
|
|
13635
|
-
(0,
|
|
13795
|
+
(0, import_build_utils26.debug)(
|
|
13636
13796
|
`skipping bytecode precompilation: no zip capacity remaining (bundle is ${(depAnalysis.totalBundleSize / (1024 * 1024)).toFixed(2)} MB)`
|
|
13637
13797
|
);
|
|
13638
13798
|
}
|
|
@@ -13663,7 +13823,7 @@ async function buildProxyMiddleware({
|
|
|
13663
13823
|
dependencyScanner
|
|
13664
13824
|
}) {
|
|
13665
13825
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
13666
|
-
(0,
|
|
13826
|
+
(0, import_build_utils26.debug)(`workPath: ${workPath}`);
|
|
13667
13827
|
workPath = await downloadFilesInWorkPath({
|
|
13668
13828
|
workPath,
|
|
13669
13829
|
files: originalFiles,
|
|
@@ -13681,7 +13841,7 @@ async function buildProxyMiddleware({
|
|
|
13681
13841
|
"utf-8"
|
|
13682
13842
|
);
|
|
13683
13843
|
if (!await (0, import_python_analysis16.containsTopLevelCallable)(proxySource, proxyHandlerFunction)) {
|
|
13684
|
-
throw new
|
|
13844
|
+
throw new import_build_utils26.NowBuildError({
|
|
13685
13845
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
13686
13846
|
message: `Handler function "${proxyHandlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
13687
13847
|
});
|
|
@@ -13701,7 +13861,7 @@ async function buildProxyMiddleware({
|
|
|
13701
13861
|
projectDir,
|
|
13702
13862
|
lockPath: uvLockPath,
|
|
13703
13863
|
workspacePackage
|
|
13704
|
-
} = await builderSpan.child(
|
|
13864
|
+
} = await builderSpan.child(import_build_utils26.BUILDER_INSTALLER_STEP, {
|
|
13705
13865
|
runtime: "python",
|
|
13706
13866
|
"python.cache.restored": restoredCache
|
|
13707
13867
|
}).trace(async (installSpan) => {
|
|
@@ -13758,7 +13918,7 @@ async function buildProxyMiddleware({
|
|
|
13758
13918
|
];
|
|
13759
13919
|
const initialFiles = {};
|
|
13760
13920
|
for (const pattern of includeFilesPatterns) {
|
|
13761
|
-
Object.assign(initialFiles, await (0,
|
|
13921
|
+
Object.assign(initialFiles, await (0, import_build_utils26.glob)(pattern, workPath));
|
|
13762
13922
|
}
|
|
13763
13923
|
const { pycachePrefix, vendorDir, files } = await packFunctionBundle({
|
|
13764
13924
|
builderSpan,
|
|
@@ -13796,9 +13956,9 @@ async function buildProxyMiddleware({
|
|
|
13796
13956
|
variableName,
|
|
13797
13957
|
extraEnv: []
|
|
13798
13958
|
});
|
|
13799
|
-
files[`${handlerPyFilename}.py`] = new
|
|
13959
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils26.FileBlob({ data: runtimeTrampoline });
|
|
13800
13960
|
const lambdaOptions = await getPythonLambdaOptions({ config, entrypoint });
|
|
13801
|
-
const output = new
|
|
13961
|
+
const output = new import_build_utils26.Lambda({
|
|
13802
13962
|
files,
|
|
13803
13963
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
13804
13964
|
runtime: pythonVersion.runtime,
|
|
@@ -13811,12 +13971,12 @@ async function buildProxyMiddleware({
|
|
|
13811
13971
|
},
|
|
13812
13972
|
supportsResponseStreaming: true
|
|
13813
13973
|
});
|
|
13814
|
-
const matcher = (0,
|
|
13974
|
+
const matcher = (0, import_build_utils27.resolveMiddlewareMatcher)(
|
|
13815
13975
|
config.middlewareMatcher,
|
|
13816
13976
|
void 0,
|
|
13817
13977
|
entrypoint
|
|
13818
13978
|
);
|
|
13819
|
-
const src = (0,
|
|
13979
|
+
const src = (0, import_build_utils27.getRegExpFromMatchers)(matcher);
|
|
13820
13980
|
const middlewareRawSrc = !matcher ? [] : Array.isArray(matcher) ? [...matcher] : [matcher];
|
|
13821
13981
|
return {
|
|
13822
13982
|
resultVersion: 3,
|
|
@@ -13847,7 +14007,7 @@ var build = async ({
|
|
|
13847
14007
|
registerPreDeploy
|
|
13848
14008
|
}) => {
|
|
13849
14009
|
let entrypoint = rawEntrypoint === "<detect>" ? void 0 : rawEntrypoint;
|
|
13850
|
-
const builderSpan = parentSpan ?? new
|
|
14010
|
+
const builderSpan = parentSpan ?? new import_build_utils26.Span({ name: "vc.builder" });
|
|
13851
14011
|
const dependencyScanner = await DependencyScanner.load({
|
|
13852
14012
|
span: builderSpan
|
|
13853
14013
|
});
|
|
@@ -13865,7 +14025,7 @@ var build = async ({
|
|
|
13865
14025
|
}
|
|
13866
14026
|
const isPyprojectEntrypoint = entrypoint !== void 0 && (0, import_path23.basename)(entrypoint) === "pyproject.toml";
|
|
13867
14027
|
if (isPyprojectEntrypoint && entrypoint !== "pyproject.toml") {
|
|
13868
|
-
throw new
|
|
14028
|
+
throw new import_build_utils26.NowBuildError({
|
|
13869
14029
|
code: "PYTHON_INVALID_PYPROJECT_ENTRYPOINT",
|
|
13870
14030
|
message: `A "pyproject.toml" entrypoint must sit at the service root. Set the service "root" to "${(0, import_path23.dirname)(entrypoint)}" and use entrypoint "pyproject.toml".`
|
|
13871
14031
|
});
|
|
@@ -13880,7 +14040,7 @@ var build = async ({
|
|
|
13880
14040
|
let projectInstallCommand;
|
|
13881
14041
|
let hasCustomCommand = false;
|
|
13882
14042
|
const target = getTargetPlatform(meta.isDev ?? false);
|
|
13883
|
-
(0,
|
|
14043
|
+
(0, import_build_utils26.debug)(`workPath: ${workPath}`);
|
|
13884
14044
|
workPath = await downloadFilesInWorkPath({
|
|
13885
14045
|
workPath,
|
|
13886
14046
|
files: originalFiles,
|
|
@@ -13888,7 +14048,7 @@ var build = async ({
|
|
|
13888
14048
|
meta
|
|
13889
14049
|
});
|
|
13890
14050
|
legacyWorkersProject = await isLegacyWorkersProject(workPath);
|
|
13891
|
-
if (isPyprojectEntrypoint || !service && (0,
|
|
14051
|
+
if (isPyprojectEntrypoint || !service && (0, import_build_utils26.isPythonFramework)(framework)) {
|
|
13892
14052
|
subscriberDeclarations = await getPyprojectSubscribers(workPath, {
|
|
13893
14053
|
legacySchema: legacyWorkersProject
|
|
13894
14054
|
});
|
|
@@ -13904,18 +14064,21 @@ var build = async ({
|
|
|
13904
14064
|
throw err;
|
|
13905
14065
|
}
|
|
13906
14066
|
let detected;
|
|
14067
|
+
const schedulesModule = config?.schedulesModule;
|
|
13907
14068
|
const handlerFunction = typeof config?.handlerFunction === "string" ? config.handlerFunction : void 0;
|
|
13908
14069
|
if (isPyprojectEntrypoint) {
|
|
13909
14070
|
const declared = await getVercelToolsEntrypoint(workPath, repoRootPath);
|
|
13910
14071
|
if (declared) {
|
|
13911
14072
|
detected = { entrypoint: declared };
|
|
13912
14073
|
} else if (subscriberDeclarations.length === 0 && workflows.length === 0) {
|
|
13913
|
-
throw new
|
|
14074
|
+
throw new import_build_utils26.NowBuildError({
|
|
13914
14075
|
code: "PYTHON_PYPROJECT_NOTHING_TO_BUILD",
|
|
13915
14076
|
message: 'Entrypoint "pyproject.toml" declares nothing to build. Set "tool.vercel.entrypoint" for a web app and/or declare "[[tool.vercel.subscribers]]" or "[[tool.vercel.workflows]]" entries in pyproject.toml.'
|
|
13916
14077
|
});
|
|
13917
14078
|
}
|
|
13918
14079
|
entrypoint = void 0;
|
|
14080
|
+
} else if (schedulesModule && entrypoint) {
|
|
14081
|
+
detected = { entrypoint: { entrypoint, variableName: "" } };
|
|
13919
14082
|
} else {
|
|
13920
14083
|
detected = await detectPythonEntrypoint(
|
|
13921
14084
|
config.framework,
|
|
@@ -13924,7 +14087,7 @@ var build = async ({
|
|
|
13924
14087
|
filePath: entrypoint,
|
|
13925
14088
|
// For schedule-triggered jobs, the WSGI variable is always 'app' (created dynamically).
|
|
13926
14089
|
// For other services, handlerFunction is used as the entrypoint variable name.
|
|
13927
|
-
varName: service && (0,
|
|
14090
|
+
varName: service && (0, import_build_utils26.isScheduleTriggeredService)(service) ? void 0 : handlerFunction
|
|
13928
14091
|
} : void 0,
|
|
13929
14092
|
service,
|
|
13930
14093
|
repoRootPath
|
|
@@ -13945,15 +14108,15 @@ var build = async ({
|
|
|
13945
14108
|
venvPath,
|
|
13946
14109
|
meta
|
|
13947
14110
|
});
|
|
13948
|
-
if ((0,
|
|
14111
|
+
if ((0, import_build_utils26.isPythonFramework)(framework)) {
|
|
13949
14112
|
const {
|
|
13950
14113
|
cliType,
|
|
13951
14114
|
lockfileVersion,
|
|
13952
14115
|
packageJsonPackageManager,
|
|
13953
14116
|
packageJsonDevEngines,
|
|
13954
14117
|
turboSupportsCorepackHome
|
|
13955
|
-
} = await (0,
|
|
13956
|
-
spawnEnv = (0,
|
|
14118
|
+
} = await (0, import_build_utils26.scanParentDirs)(workPath, true);
|
|
14119
|
+
spawnEnv = (0, import_build_utils26.getEnvForPackageManager)({
|
|
13957
14120
|
cliType,
|
|
13958
14121
|
lockfileVersion,
|
|
13959
14122
|
packageJsonPackageManager,
|
|
@@ -13981,7 +14144,7 @@ var build = async ({
|
|
|
13981
14144
|
let projectName;
|
|
13982
14145
|
let workspacePackage;
|
|
13983
14146
|
let usedUvManagedInstall = false;
|
|
13984
|
-
await builderSpan.child(
|
|
14147
|
+
await builderSpan.child(import_build_utils26.BUILDER_INSTALLER_STEP, {
|
|
13985
14148
|
installCommand: projectInstallCommand || void 0,
|
|
13986
14149
|
runtime: "python",
|
|
13987
14150
|
"python.cache.restored": restoredCache
|
|
@@ -14001,7 +14164,7 @@ var build = async ({
|
|
|
14001
14164
|
console.log(
|
|
14002
14165
|
`Running "install" command: \`${projectInstallCommand}\`...`
|
|
14003
14166
|
);
|
|
14004
|
-
await (0,
|
|
14167
|
+
await (0, import_build_utils26.execCommand)(projectInstallCommand, {
|
|
14005
14168
|
env: pythonEnv,
|
|
14006
14169
|
cwd: workPath
|
|
14007
14170
|
});
|
|
@@ -14042,15 +14205,15 @@ var build = async ({
|
|
|
14042
14205
|
usedUvManagedInstall = true;
|
|
14043
14206
|
}
|
|
14044
14207
|
});
|
|
14045
|
-
if ((0,
|
|
14208
|
+
if ((0, import_build_utils26.isPythonFramework)(framework)) {
|
|
14046
14209
|
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
14047
14210
|
config?.buildCommand;
|
|
14048
|
-
await builderSpan.child(
|
|
14211
|
+
await builderSpan.child(import_build_utils26.BUILDER_COMPILE_STEP, {
|
|
14049
14212
|
buildCommand: projectBuildCommand || void 0
|
|
14050
14213
|
}).trace(async () => {
|
|
14051
14214
|
if (projectBuildCommand) {
|
|
14052
14215
|
console.log(`Running "${projectBuildCommand}"`);
|
|
14053
|
-
await (0,
|
|
14216
|
+
await (0, import_build_utils26.execCommand)(projectBuildCommand, {
|
|
14054
14217
|
env: pythonEnv,
|
|
14055
14218
|
cwd: workPath
|
|
14056
14219
|
});
|
|
@@ -14078,7 +14241,7 @@ var build = async ({
|
|
|
14078
14241
|
entrypoint = resolved?.entrypoint;
|
|
14079
14242
|
const isWorkersOnly = !entrypoint && isPyprojectEntrypoint && (subscriberDeclarations.length > 0 || workflows.length > 0);
|
|
14080
14243
|
if (!entrypoint && !isWorkersOnly) {
|
|
14081
|
-
throw new
|
|
14244
|
+
throw new import_build_utils26.NowBuildError({
|
|
14082
14245
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
14083
14246
|
message: "No Python entrypoint could be detected. Please specify an entrypoint file."
|
|
14084
14247
|
});
|
|
@@ -14119,7 +14282,7 @@ var build = async ({
|
|
|
14119
14282
|
env: baseEnv
|
|
14120
14283
|
});
|
|
14121
14284
|
if (localSdkSourcePaths.length > 0) {
|
|
14122
|
-
(0,
|
|
14285
|
+
(0, import_build_utils26.debug)(
|
|
14123
14286
|
`Installing vercel SDK override from ${baseEnv.VERCEL_SDK_PYTHON}: ` + localSdkSourcePaths.join(", ")
|
|
14124
14287
|
);
|
|
14125
14288
|
await uv.pip({
|
|
@@ -14149,7 +14312,7 @@ var build = async ({
|
|
|
14149
14312
|
uvLockPath
|
|
14150
14313
|
});
|
|
14151
14314
|
if (workflowMode === "workers" && workflows.length > 1) {
|
|
14152
|
-
throw new
|
|
14315
|
+
throw new import_build_utils26.NowBuildError({
|
|
14153
14316
|
code: "PYTHON_INVALID_WORKFLOW_CONFIG",
|
|
14154
14317
|
message: `"tool.vercel.workflows" declares multiple entrypoints, which requires ${QUEUE_WORKFLOW_SDK_REQUIREMENT} with a distinct namespace per Workflows registry; the installed SDK serves every workflow on the shared __wkf_* topic`
|
|
14155
14318
|
});
|
|
@@ -14230,7 +14393,7 @@ var build = async ({
|
|
|
14230
14393
|
)
|
|
14231
14394
|
);
|
|
14232
14395
|
if (overlaps) {
|
|
14233
|
-
throw new
|
|
14396
|
+
throw new import_build_utils26.NowBuildError({
|
|
14234
14397
|
code: "PYTHON_INVALID_WORKFLOW_CONFIG",
|
|
14235
14398
|
message: `workflow entrypoints "${resolved2[i].moduleName}:${resolved2[i].variableName}" and "${resolved2[j].moduleName}:${resolved2[j].variableName}" subscribe to overlapping queue topics; construct each vercel.workflow.Workflows registry with a distinct namespace`
|
|
14236
14399
|
});
|
|
@@ -14250,60 +14413,73 @@ var build = async ({
|
|
|
14250
14413
|
const capturedEnv = { ...pythonEnv };
|
|
14251
14414
|
const capturedCwd = workPath;
|
|
14252
14415
|
registerPreDeploy(async () => {
|
|
14253
|
-
await builderSpan.child(
|
|
14416
|
+
await builderSpan.child(import_build_utils26.BUILDER_PRE_DEPLOY_STEP, {
|
|
14254
14417
|
preDeployCommand
|
|
14255
14418
|
}).trace(async () => {
|
|
14256
14419
|
console.log(`Running pre-deploy command: \`${preDeployCommand}\``);
|
|
14257
|
-
await (0,
|
|
14420
|
+
await (0, import_build_utils26.execCommand)(preDeployCommand, {
|
|
14258
14421
|
env: capturedEnv,
|
|
14259
14422
|
cwd: capturedCwd
|
|
14260
14423
|
});
|
|
14261
14424
|
});
|
|
14262
14425
|
});
|
|
14263
14426
|
}
|
|
14427
|
+
let schedules;
|
|
14428
|
+
if (schedulesModule) {
|
|
14429
|
+
(0, import_assert.default)(service?.name, "a Python schedule builds as a service");
|
|
14430
|
+
schedules = await introspectSchedules({
|
|
14431
|
+
moduleName: schedulesModule.module,
|
|
14432
|
+
service: service.name,
|
|
14433
|
+
uv,
|
|
14434
|
+
venvPath,
|
|
14435
|
+
projectDir: workPath
|
|
14436
|
+
});
|
|
14437
|
+
}
|
|
14264
14438
|
const vendorDir = resolveVendorDir();
|
|
14265
14439
|
let crons;
|
|
14266
14440
|
let runtimeTrampoline;
|
|
14267
14441
|
if (entrypoint) {
|
|
14268
|
-
(0,
|
|
14442
|
+
(0, import_build_utils26.debug)("Entrypoint is", entrypoint);
|
|
14269
14443
|
if (handlerFunction) {
|
|
14270
14444
|
const entrypointPath = (0, import_path23.join)(workPath, entrypoint);
|
|
14271
14445
|
const source = await import_fs22.default.promises.readFile(entrypointPath, "utf-8");
|
|
14272
14446
|
const found = await (0, import_python_analysis16.containsTopLevelCallable)(source, handlerFunction);
|
|
14273
14447
|
if (!found) {
|
|
14274
|
-
throw new
|
|
14448
|
+
throw new import_build_utils26.NowBuildError({
|
|
14275
14449
|
code: "PYTHON_HANDLER_NOT_FOUND",
|
|
14276
14450
|
message: `Handler function "${handlerFunction}" not found in ${entrypoint}. Ensure it is defined at the module's top level.`
|
|
14277
14451
|
});
|
|
14278
14452
|
}
|
|
14279
14453
|
}
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14454
|
+
if (!schedulesModule) {
|
|
14455
|
+
const moduleName = entrypointToModule(entrypoint);
|
|
14456
|
+
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
14457
|
+
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
14458
|
+
(0, import_build_utils26.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
14459
|
+
crons = await getServiceCrons({
|
|
14460
|
+
service,
|
|
14461
|
+
entrypoint,
|
|
14462
|
+
rawEntrypoint,
|
|
14463
|
+
handlerFunction,
|
|
14464
|
+
pythonBin: getVenvPythonBin(venvPath),
|
|
14465
|
+
env: pythonEnv,
|
|
14466
|
+
workPath
|
|
14467
|
+
});
|
|
14468
|
+
const extraTrampolineEnv = [];
|
|
14469
|
+
if (crons?.length) {
|
|
14470
|
+
const json = JSON.stringify(buildCronRouteTable(crons));
|
|
14471
|
+
(0, import_assert.default)(!json.includes("\\"), `backslash in cron route table: ${json}`);
|
|
14472
|
+
extraTrampolineEnv.push(`"__VC_CRON_ROUTES": '${json}'`);
|
|
14473
|
+
}
|
|
14474
|
+
const variableName = resolved?.variableName ?? "";
|
|
14475
|
+
runtimeTrampoline = createRuntimeTrampoline({
|
|
14476
|
+
moduleName,
|
|
14477
|
+
entrypoint: entrypointWithSuffix,
|
|
14478
|
+
vendorDir,
|
|
14479
|
+
variableName,
|
|
14480
|
+
extraEnv: extraTrampolineEnv
|
|
14481
|
+
});
|
|
14298
14482
|
}
|
|
14299
|
-
const variableName = resolved?.variableName ?? "";
|
|
14300
|
-
runtimeTrampoline = createRuntimeTrampoline({
|
|
14301
|
-
moduleName,
|
|
14302
|
-
entrypoint: entrypointWithSuffix,
|
|
14303
|
-
vendorDir,
|
|
14304
|
-
variableName,
|
|
14305
|
-
extraEnv: extraTrampolineEnv
|
|
14306
|
-
});
|
|
14307
14483
|
}
|
|
14308
14484
|
const compileAllEnabled = shouldCompileAll({
|
|
14309
14485
|
isDev: meta.isDev,
|
|
@@ -14355,18 +14531,18 @@ var build = async ({
|
|
|
14355
14531
|
);
|
|
14356
14532
|
const initialFiles = {};
|
|
14357
14533
|
for (const pattern of includeFilesPatterns) {
|
|
14358
|
-
Object.assign(initialFiles, await (0,
|
|
14534
|
+
Object.assign(initialFiles, await (0, import_build_utils26.glob)(pattern, workPath));
|
|
14359
14535
|
}
|
|
14360
14536
|
Object.assign(initialFiles, cdnBundle.directoryStubs);
|
|
14361
14537
|
if (djangoStatic?.manifestRelPath) {
|
|
14362
|
-
initialFiles[djangoStatic.manifestRelPath] = new
|
|
14538
|
+
initialFiles[djangoStatic.manifestRelPath] = new import_build_utils26.FileFsRef({
|
|
14363
14539
|
fsPath: (0, import_path23.join)(workPath, djangoStatic.manifestRelPath)
|
|
14364
14540
|
});
|
|
14365
14541
|
}
|
|
14366
14542
|
const handlerPyFilename = "vc__handler__python";
|
|
14367
14543
|
if (config.framework === "fasthtml") {
|
|
14368
14544
|
const { SESSKEY = "" } = process.env;
|
|
14369
|
-
initialFiles[".sesskey"] = new
|
|
14545
|
+
initialFiles[".sesskey"] = new import_build_utils26.FileBlob({ data: `"${SESSKEY}"` });
|
|
14370
14546
|
}
|
|
14371
14547
|
const { pycachePrefix, files, installedDistributions } = await packFunctionBundle({
|
|
14372
14548
|
builderSpan,
|
|
@@ -14407,13 +14583,13 @@ var build = async ({
|
|
|
14407
14583
|
if (entrypoint && runtimeTrampoline) {
|
|
14408
14584
|
const webFiles = {
|
|
14409
14585
|
...files,
|
|
14410
|
-
[`${handlerPyFilename}.py`]: new
|
|
14586
|
+
[`${handlerPyFilename}.py`]: new import_build_utils26.FileBlob({ data: runtimeTrampoline })
|
|
14411
14587
|
};
|
|
14412
14588
|
const lambdaOptions = await getPythonLambdaOptions({
|
|
14413
14589
|
config,
|
|
14414
14590
|
entrypoint
|
|
14415
14591
|
});
|
|
14416
|
-
output = new
|
|
14592
|
+
output = new import_build_utils26.Lambda({
|
|
14417
14593
|
files: webFiles,
|
|
14418
14594
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
14419
14595
|
runtime: pythonVersion.runtime,
|
|
@@ -14444,10 +14620,10 @@ var build = async ({
|
|
|
14444
14620
|
...subscription.triggerDefaults
|
|
14445
14621
|
})
|
|
14446
14622
|
);
|
|
14447
|
-
subscriberLambdas[outputPath] = new
|
|
14623
|
+
subscriberLambdas[outputPath] = new import_build_utils26.Lambda({
|
|
14448
14624
|
files: {
|
|
14449
14625
|
...files,
|
|
14450
|
-
[`${handlerPyFilename}.py`]: new
|
|
14626
|
+
[`${handlerPyFilename}.py`]: new import_build_utils26.FileBlob({
|
|
14451
14627
|
data: createRuntimeTrampoline({
|
|
14452
14628
|
moduleName: generatedPythonPathToModule(generatedHandlerPath),
|
|
14453
14629
|
entrypoint: generatedHandlerPath,
|
|
@@ -14487,10 +14663,10 @@ var build = async ({
|
|
|
14487
14663
|
consumer,
|
|
14488
14664
|
...legacy.triggerDefaults
|
|
14489
14665
|
}));
|
|
14490
|
-
subscriberLambdas[outputPath] = new
|
|
14666
|
+
subscriberLambdas[outputPath] = new import_build_utils26.Lambda({
|
|
14491
14667
|
files: {
|
|
14492
14668
|
...files,
|
|
14493
|
-
[`${handlerPyFilename}.py`]: new
|
|
14669
|
+
[`${handlerPyFilename}.py`]: new import_build_utils26.FileBlob({
|
|
14494
14670
|
data: createRuntimeTrampoline({
|
|
14495
14671
|
moduleName: declaration.moduleName,
|
|
14496
14672
|
entrypoint: declaration.entrypoint,
|
|
@@ -14523,10 +14699,10 @@ var build = async ({
|
|
|
14523
14699
|
...subscription.triggerDefaults
|
|
14524
14700
|
})
|
|
14525
14701
|
);
|
|
14526
|
-
workflowLambdas[outputPath] = new
|
|
14702
|
+
workflowLambdas[outputPath] = new import_build_utils26.Lambda({
|
|
14527
14703
|
files: {
|
|
14528
14704
|
...files,
|
|
14529
|
-
[`${handlerPyFilename}.py`]: new
|
|
14705
|
+
[`${handlerPyFilename}.py`]: new import_build_utils26.FileBlob({
|
|
14530
14706
|
data: createRuntimeTrampoline({
|
|
14531
14707
|
moduleName: generatedPythonPathToModule(generatedHandlerPath),
|
|
14532
14708
|
entrypoint: generatedHandlerPath,
|
|
@@ -14553,10 +14729,10 @@ var build = async ({
|
|
|
14553
14729
|
consumer: getWorkflowConsumerName(workflow.name)
|
|
14554
14730
|
}
|
|
14555
14731
|
];
|
|
14556
|
-
workflowLambdas[outputPath] = new
|
|
14732
|
+
workflowLambdas[outputPath] = new import_build_utils26.Lambda({
|
|
14557
14733
|
files: {
|
|
14558
14734
|
...files,
|
|
14559
|
-
[`${handlerPyFilename}.py`]: new
|
|
14735
|
+
[`${handlerPyFilename}.py`]: new import_build_utils26.FileBlob({
|
|
14560
14736
|
data: createRuntimeTrampoline({
|
|
14561
14737
|
moduleName: workflow.moduleName,
|
|
14562
14738
|
entrypoint: workflow.entrypoint,
|
|
@@ -14582,33 +14758,78 @@ var build = async ({
|
|
|
14582
14758
|
pythonVersion,
|
|
14583
14759
|
uvLockPath,
|
|
14584
14760
|
framework: diagnosticsValues?.framework,
|
|
14585
|
-
serviceType: service ? (0,
|
|
14761
|
+
serviceType: service ? (0, import_build_utils26.getReportedServiceType)(service) : void 0
|
|
14586
14762
|
});
|
|
14587
14763
|
} catch (err) {
|
|
14588
|
-
(0,
|
|
14764
|
+
(0, import_build_utils26.debug)(
|
|
14589
14765
|
`Failed to write project manifest: ${err instanceof Error ? err.message : String(err)}`
|
|
14590
14766
|
);
|
|
14591
14767
|
}
|
|
14592
14768
|
}
|
|
14593
|
-
if (
|
|
14769
|
+
if (schedulesModule && entrypoint && schedules) {
|
|
14770
|
+
const lambdaOptions = await getPythonLambdaOptions({
|
|
14771
|
+
config,
|
|
14772
|
+
entrypoint,
|
|
14773
|
+
isScheduleEntrypoint: true
|
|
14774
|
+
});
|
|
14775
|
+
const trampoline = new import_build_utils26.FileBlob({
|
|
14776
|
+
data: createRuntimeTrampoline({
|
|
14777
|
+
moduleName: generatedPythonPathToModule(
|
|
14778
|
+
GENERATED_SCHEDULE_HANDLER_PATH
|
|
14779
|
+
),
|
|
14780
|
+
entrypoint: GENERATED_SCHEDULE_HANDLER_PATH,
|
|
14781
|
+
vendorDir,
|
|
14782
|
+
variableName: "app"
|
|
14783
|
+
})
|
|
14784
|
+
});
|
|
14785
|
+
const output2 = {};
|
|
14786
|
+
for (const fn of schedules.functions) {
|
|
14787
|
+
output2[fn.path] = new import_build_utils26.Lambda({
|
|
14788
|
+
files: {
|
|
14789
|
+
...files,
|
|
14790
|
+
[GENERATED_SCHEDULE_HANDLER_PATH]: new import_build_utils26.FileBlob({
|
|
14791
|
+
data: createScheduleHandlerModule({
|
|
14792
|
+
moduleName: schedulesModule.module,
|
|
14793
|
+
service: service.name,
|
|
14794
|
+
schedules: fn.schedules
|
|
14795
|
+
})
|
|
14796
|
+
}),
|
|
14797
|
+
[`${handlerPyFilename}.py`]: trampoline
|
|
14798
|
+
},
|
|
14799
|
+
handler: `${handlerPyFilename}.vc_handler`,
|
|
14800
|
+
runtime: pythonVersion.runtime,
|
|
14801
|
+
...lambdaOptions,
|
|
14802
|
+
...fn.maxDuration !== void 0 && { maxDuration: fn.maxDuration },
|
|
14803
|
+
...fn.regions !== void 0 && { regions: fn.regions },
|
|
14804
|
+
architecture: target.architecture,
|
|
14805
|
+
environment: { ...lambdaEnv },
|
|
14806
|
+
supportsResponseStreaming: true
|
|
14807
|
+
});
|
|
14808
|
+
}
|
|
14809
|
+
return {
|
|
14810
|
+
resultVersion: 2,
|
|
14811
|
+
result: { output: output2, schedules: schedules.schedules }
|
|
14812
|
+
};
|
|
14813
|
+
}
|
|
14814
|
+
if (!(0, import_build_utils26.isPythonFramework)(framework) && !service?.name && !isPyprojectEntrypoint) {
|
|
14594
14815
|
(0, import_assert.default)(output, "web Lambda must exist for non-service builds");
|
|
14595
14816
|
return { resultVersion: 3, result: { output } };
|
|
14596
14817
|
}
|
|
14597
14818
|
const frameworkLambdaName = framework ?? "python";
|
|
14598
14819
|
const lambdaPath = service?.name && service.type ? `_svc/${service.name}/index` : frameworkLambdaName;
|
|
14599
|
-
const staticFiles = cdnOutputDir ? await (0,
|
|
14820
|
+
const staticFiles = cdnOutputDir ? await (0, import_build_utils26.glob)("**", { cwd: cdnOutputDir }) : {};
|
|
14600
14821
|
const isNonWebService = service?.name && service.type && service.type !== "web";
|
|
14601
14822
|
const queueRoutes = queueRoutePaths.map((outputPath) => ({
|
|
14602
14823
|
src: `/${outputPath}`,
|
|
14603
14824
|
dest: `/${outputPath}`
|
|
14604
14825
|
}));
|
|
14605
14826
|
const staticOptions = fastapiStatic ? fastapiStaticOptions(installedDistributions) : void 0;
|
|
14606
|
-
const shadowingRoutes = fastapiStatic ? (0,
|
|
14827
|
+
const shadowingRoutes = fastapiStatic ? (0, import_build_utils26.staticShadowRoutes)(
|
|
14607
14828
|
fastapiStatic.discovery.shadowRoutes,
|
|
14608
14829
|
lambdaPath,
|
|
14609
14830
|
staticOptions
|
|
14610
14831
|
) : [];
|
|
14611
|
-
const fallbackRoutes = fastapiStatic ? (0,
|
|
14832
|
+
const fallbackRoutes = fastapiStatic ? (0, import_build_utils26.staticFallbackRoutes)(
|
|
14612
14833
|
fastapiStatic.copiedMounts,
|
|
14613
14834
|
fastapiStatic.discovery.mounts,
|
|
14614
14835
|
staticOptions
|
|
@@ -14664,14 +14885,14 @@ var prepareCache = async ({
|
|
|
14664
14885
|
}
|
|
14665
14886
|
} catch {
|
|
14666
14887
|
}
|
|
14667
|
-
return (0,
|
|
14888
|
+
return (0, import_build_utils26.glob)("**/.vercel/python/{.venv,services/*/.venv,cache/uv}/**", {
|
|
14668
14889
|
cwd: root,
|
|
14669
14890
|
ignore
|
|
14670
14891
|
});
|
|
14671
14892
|
};
|
|
14672
14893
|
var shouldServe = (opts) => {
|
|
14673
14894
|
const framework = opts.config.framework;
|
|
14674
|
-
if ((0,
|
|
14895
|
+
if ((0, import_build_utils26.isPythonFramework)(framework)) {
|
|
14675
14896
|
const requestPath = opts.requestPath.replace(/\/$/, "");
|
|
14676
14897
|
if (requestPath.startsWith("api") && opts.hasMatched) {
|
|
14677
14898
|
return false;
|