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