@vercel/python 6.0.3 → 6.0.4
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 +135 -45
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2751,7 +2751,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
2751
2751
|
var import_fs5 = __toESM(require("fs"));
|
|
2752
2752
|
var import_util = require("util");
|
|
2753
2753
|
var import_path5 = require("path");
|
|
2754
|
-
var
|
|
2754
|
+
var import_build_utils7 = require("@vercel/build-utils");
|
|
2755
2755
|
|
|
2756
2756
|
// src/install.ts
|
|
2757
2757
|
var import_execa = __toESM(require_execa());
|
|
@@ -3071,7 +3071,7 @@ async function exportRequirementsFromPipfile({
|
|
|
3071
3071
|
}
|
|
3072
3072
|
|
|
3073
3073
|
// src/index.ts
|
|
3074
|
-
var
|
|
3074
|
+
var import_build_utils8 = require("@vercel/build-utils");
|
|
3075
3075
|
|
|
3076
3076
|
// src/version.ts
|
|
3077
3077
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
@@ -3204,7 +3204,7 @@ function isInstalled2({ pipPath, pythonPath }) {
|
|
|
3204
3204
|
var import_child_process = require("child_process");
|
|
3205
3205
|
var import_fs4 = require("fs");
|
|
3206
3206
|
var import_path4 = require("path");
|
|
3207
|
-
var
|
|
3207
|
+
var import_build_utils6 = require("@vercel/build-utils");
|
|
3208
3208
|
|
|
3209
3209
|
// src/entrypoint.ts
|
|
3210
3210
|
var import_fs2 = __toESM(require("fs"));
|
|
@@ -3334,6 +3334,8 @@ async function detectPythonEntrypoint(framework, workPath, configuredEntrypoint)
|
|
|
3334
3334
|
// src/utils.ts
|
|
3335
3335
|
var import_fs3 = __toESM(require("fs"));
|
|
3336
3336
|
var import_path3 = require("path");
|
|
3337
|
+
var import_execa2 = __toESM(require_execa());
|
|
3338
|
+
var import_build_utils5 = require("@vercel/build-utils");
|
|
3337
3339
|
var isInVirtualEnv = () => {
|
|
3338
3340
|
return process.env.VIRTUAL_ENV;
|
|
3339
3341
|
};
|
|
@@ -3354,6 +3356,51 @@ function useVirtualEnv(workPath, env, systemPython) {
|
|
|
3354
3356
|
}
|
|
3355
3357
|
return { pythonCmd };
|
|
3356
3358
|
}
|
|
3359
|
+
async function runPyprojectScript(workPath, scriptNames, env) {
|
|
3360
|
+
const pyprojectPath = (0, import_path3.join)(workPath, "pyproject.toml");
|
|
3361
|
+
if (!import_fs3.default.existsSync(pyprojectPath))
|
|
3362
|
+
return false;
|
|
3363
|
+
let pyproject = null;
|
|
3364
|
+
try {
|
|
3365
|
+
pyproject = await (0, import_build_utils5.readConfigFile)(pyprojectPath);
|
|
3366
|
+
} catch {
|
|
3367
|
+
console.error("Failed to parse pyproject.toml");
|
|
3368
|
+
return false;
|
|
3369
|
+
}
|
|
3370
|
+
const scripts = pyproject?.tool?.vercel?.scripts || {};
|
|
3371
|
+
const candidates = typeof scriptNames === "string" ? [scriptNames] : Array.from(scriptNames);
|
|
3372
|
+
const scriptToRun = candidates.find((name) => Boolean(scripts[name]));
|
|
3373
|
+
if (!scriptToRun)
|
|
3374
|
+
return false;
|
|
3375
|
+
const systemPython = process.platform === "win32" ? "python" : "python3";
|
|
3376
|
+
const finalEnv = { ...process.env, ...env };
|
|
3377
|
+
const { pythonCmd } = useVirtualEnv(workPath, finalEnv, systemPython);
|
|
3378
|
+
const uvPath = await getUvBinaryOrInstall(pythonCmd);
|
|
3379
|
+
const scriptCommand = scripts[scriptToRun];
|
|
3380
|
+
if (typeof scriptCommand === "string" && scriptCommand.trim()) {
|
|
3381
|
+
const uvDir = (0, import_path3.dirname)(uvPath);
|
|
3382
|
+
finalEnv.PATH = `${uvDir}${import_path3.delimiter}${finalEnv.PATH || ""}`;
|
|
3383
|
+
if (/^\s*uv(\s|$)/i.test(scriptCommand)) {
|
|
3384
|
+
console.log(`Executing: ${scriptCommand}`);
|
|
3385
|
+
await (0, import_build_utils5.execCommand)(scriptCommand, {
|
|
3386
|
+
cwd: workPath,
|
|
3387
|
+
env: finalEnv
|
|
3388
|
+
});
|
|
3389
|
+
return true;
|
|
3390
|
+
}
|
|
3391
|
+
const args = process.platform === "win32" ? ["run", "cmd", "/d", "/s", "/c", scriptCommand] : ["run", "sh", "-lc", scriptCommand];
|
|
3392
|
+
console.log(
|
|
3393
|
+
`Executing: ${uvPath} ${args.map((a) => /\s/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a).join(" ")}`
|
|
3394
|
+
);
|
|
3395
|
+
await (0, import_execa2.default)(uvPath, args, {
|
|
3396
|
+
cwd: workPath,
|
|
3397
|
+
stdio: "inherit",
|
|
3398
|
+
env: finalEnv
|
|
3399
|
+
});
|
|
3400
|
+
return true;
|
|
3401
|
+
}
|
|
3402
|
+
return false;
|
|
3403
|
+
}
|
|
3357
3404
|
|
|
3358
3405
|
// src/start-dev-server.ts
|
|
3359
3406
|
function silenceNodeWarnings() {
|
|
@@ -3398,12 +3445,12 @@ function installGlobalCleanupHandlers() {
|
|
|
3398
3445
|
try {
|
|
3399
3446
|
process.kill(info.pid, "SIGTERM");
|
|
3400
3447
|
} catch (err) {
|
|
3401
|
-
(0,
|
|
3448
|
+
(0, import_build_utils6.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
|
|
3402
3449
|
}
|
|
3403
3450
|
try {
|
|
3404
3451
|
process.kill(info.pid, "SIGKILL");
|
|
3405
3452
|
} catch (err) {
|
|
3406
|
-
(0,
|
|
3453
|
+
(0, import_build_utils6.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
|
|
3407
3454
|
}
|
|
3408
3455
|
PERSISTENT_SERVERS.delete(key);
|
|
3409
3456
|
}
|
|
@@ -3411,7 +3458,7 @@ function installGlobalCleanupHandlers() {
|
|
|
3411
3458
|
try {
|
|
3412
3459
|
restoreWarnings();
|
|
3413
3460
|
} catch (err) {
|
|
3414
|
-
(0,
|
|
3461
|
+
(0, import_build_utils6.debug)(`Error restoring warnings: ${err}`);
|
|
3415
3462
|
}
|
|
3416
3463
|
restoreWarnings = null;
|
|
3417
3464
|
}
|
|
@@ -3437,10 +3484,10 @@ function createDevAsgiShim(workPath, modulePath) {
|
|
|
3437
3484
|
const template = (0, import_fs4.readFileSync)(templatePath, "utf8");
|
|
3438
3485
|
const shimSource = template.replace(/__VC_DEV_MODULE_PATH__/g, modulePath);
|
|
3439
3486
|
(0, import_fs4.writeFileSync)(shimPath, shimSource, "utf8");
|
|
3440
|
-
(0,
|
|
3487
|
+
(0, import_build_utils6.debug)(`Prepared Python dev static shim at ${shimPath}`);
|
|
3441
3488
|
return ASGI_SHIM_MODULE;
|
|
3442
3489
|
} catch (err) {
|
|
3443
|
-
(0,
|
|
3490
|
+
(0, import_build_utils6.debug)(`Failed to prepare dev static shim: ${err?.message || err}`);
|
|
3444
3491
|
return null;
|
|
3445
3492
|
}
|
|
3446
3493
|
}
|
|
@@ -3453,10 +3500,10 @@ function createDevWsgiShim(workPath, modulePath) {
|
|
|
3453
3500
|
const template = (0, import_fs4.readFileSync)(templatePath, "utf8");
|
|
3454
3501
|
const shimSource = template.replace(/__VC_DEV_MODULE_PATH__/g, modulePath);
|
|
3455
3502
|
(0, import_fs4.writeFileSync)(shimPath, shimSource, "utf8");
|
|
3456
|
-
(0,
|
|
3503
|
+
(0, import_build_utils6.debug)(`Prepared Python dev WSGI shim at ${shimPath}`);
|
|
3457
3504
|
return WSGI_SHIM_MODULE;
|
|
3458
3505
|
} catch (err) {
|
|
3459
|
-
(0,
|
|
3506
|
+
(0, import_build_utils6.debug)(`Failed to prepare dev WSGI shim: ${err?.message || err}`);
|
|
3460
3507
|
return null;
|
|
3461
3508
|
}
|
|
3462
3509
|
}
|
|
@@ -3476,7 +3523,7 @@ var startDevServer = async (opts) => {
|
|
|
3476
3523
|
);
|
|
3477
3524
|
if (!entry) {
|
|
3478
3525
|
const searched = framework === "fastapi" ? FASTAPI_CANDIDATE_ENTRYPOINTS.join(", ") : FLASK_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
3479
|
-
throw new
|
|
3526
|
+
throw new import_build_utils6.NowBuildError({
|
|
3480
3527
|
code: "PYTHON_ENTRYPOINT_NOT_FOUND",
|
|
3481
3528
|
message: `No ${framework} entrypoint found. Define a valid application entrypoint in one of the following locations: ${searched} or add an 'app' script in pyproject.toml.`,
|
|
3482
3529
|
link: `https://vercel.com/docs/frameworks/backend/${framework?.toLowerCase()}#exporting-the-${framework?.toLowerCase()}-application`,
|
|
@@ -3526,7 +3573,7 @@ var startDevServer = async (opts) => {
|
|
|
3526
3573
|
let pythonCmd = systemPython;
|
|
3527
3574
|
const venv = isInVirtualEnv();
|
|
3528
3575
|
if (venv) {
|
|
3529
|
-
(0,
|
|
3576
|
+
(0, import_build_utils6.debug)(`Running in virtualenv at ${venv}`);
|
|
3530
3577
|
} else {
|
|
3531
3578
|
const { pythonCmd: venvPythonCmd, venvRoot } = useVirtualEnv(
|
|
3532
3579
|
workPath,
|
|
@@ -3535,9 +3582,9 @@ var startDevServer = async (opts) => {
|
|
|
3535
3582
|
);
|
|
3536
3583
|
pythonCmd = venvPythonCmd;
|
|
3537
3584
|
if (venvRoot) {
|
|
3538
|
-
(0,
|
|
3585
|
+
(0, import_build_utils6.debug)(`Using virtualenv at ${venvRoot}`);
|
|
3539
3586
|
} else {
|
|
3540
|
-
(0,
|
|
3587
|
+
(0, import_build_utils6.debug)("No virtualenv found");
|
|
3541
3588
|
try {
|
|
3542
3589
|
const yellow = "\x1B[33m";
|
|
3543
3590
|
const reset = "\x1B[0m";
|
|
@@ -3560,7 +3607,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
3560
3607
|
}
|
|
3561
3608
|
const moduleToRun = devShimModule || modulePath;
|
|
3562
3609
|
const argv = ["-u", "-m", moduleToRun];
|
|
3563
|
-
(0,
|
|
3610
|
+
(0, import_build_utils6.debug)(`Starting ASGI dev server: ${pythonCmd} ${argv.join(" ")}`);
|
|
3564
3611
|
const child = (0, import_child_process.spawn)(pythonCmd, argv, {
|
|
3565
3612
|
cwd: workPath,
|
|
3566
3613
|
env,
|
|
@@ -3638,7 +3685,7 @@ If you are using a virtual environment, activate it before running "vercel dev",
|
|
|
3638
3685
|
}
|
|
3639
3686
|
const moduleToRun = devShimModule || modulePath;
|
|
3640
3687
|
const argv = ["-u", "-m", moduleToRun];
|
|
3641
|
-
(0,
|
|
3688
|
+
(0, import_build_utils6.debug)(`Starting Flask dev server: ${pythonCmd} ${argv.join(" ")}`);
|
|
3642
3689
|
const child = (0, import_child_process.spawn)(pythonCmd, argv, {
|
|
3643
3690
|
cwd: workPath,
|
|
3644
3691
|
env,
|
|
@@ -3748,13 +3795,13 @@ async function downloadFilesInWorkPath({
|
|
|
3748
3795
|
files,
|
|
3749
3796
|
meta = {}
|
|
3750
3797
|
}) {
|
|
3751
|
-
(0,
|
|
3752
|
-
let downloadedFiles = await (0,
|
|
3798
|
+
(0, import_build_utils7.debug)("Downloading user files...");
|
|
3799
|
+
let downloadedFiles = await (0, import_build_utils7.download)(files, workPath, meta);
|
|
3753
3800
|
if (meta.isDev) {
|
|
3754
3801
|
const { devCacheDir = (0, import_path5.join)(workPath, ".now", "cache") } = meta;
|
|
3755
3802
|
const destCache = (0, import_path5.join)(devCacheDir, (0, import_path5.basename)(entrypoint, ".py"));
|
|
3756
|
-
await (0,
|
|
3757
|
-
downloadedFiles = await (0,
|
|
3803
|
+
await (0, import_build_utils7.download)(downloadedFiles, destCache);
|
|
3804
|
+
downloadedFiles = await (0, import_build_utils7.glob)("**", destCache);
|
|
3758
3805
|
workPath = destCache;
|
|
3759
3806
|
}
|
|
3760
3807
|
return workPath;
|
|
@@ -3782,7 +3829,50 @@ var build = async ({
|
|
|
3782
3829
|
console.log('Failed to create "setup.cfg" file');
|
|
3783
3830
|
throw err;
|
|
3784
3831
|
}
|
|
3785
|
-
|
|
3832
|
+
if (framework === "fastapi" || framework === "flask") {
|
|
3833
|
+
const {
|
|
3834
|
+
cliType,
|
|
3835
|
+
lockfileVersion,
|
|
3836
|
+
packageJsonPackageManager,
|
|
3837
|
+
turboSupportsCorepackHome
|
|
3838
|
+
} = await (0, import_build_utils7.scanParentDirs)(workPath, true);
|
|
3839
|
+
const spawnEnv = (0, import_build_utils7.getEnvForPackageManager)({
|
|
3840
|
+
cliType,
|
|
3841
|
+
lockfileVersion,
|
|
3842
|
+
packageJsonPackageManager,
|
|
3843
|
+
env: process.env,
|
|
3844
|
+
turboSupportsCorepackHome,
|
|
3845
|
+
projectCreatedAt: config?.projectSettings?.createdAt
|
|
3846
|
+
});
|
|
3847
|
+
const installCommand = config?.projectSettings?.installCommand;
|
|
3848
|
+
if (typeof installCommand === "string") {
|
|
3849
|
+
if (installCommand.trim()) {
|
|
3850
|
+
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
3851
|
+
await (0, import_build_utils7.execCommand)(installCommand, {
|
|
3852
|
+
env: spawnEnv,
|
|
3853
|
+
cwd: workPath
|
|
3854
|
+
});
|
|
3855
|
+
} else {
|
|
3856
|
+
console.log('Skipping "install" command...');
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
const projectBuildCommand = config?.projectSettings?.buildCommand ?? // fallback if provided directly on config (some callers set this)
|
|
3860
|
+
config?.buildCommand;
|
|
3861
|
+
if (projectBuildCommand) {
|
|
3862
|
+
console.log(`Running "${projectBuildCommand}"`);
|
|
3863
|
+
await (0, import_build_utils7.execCommand)(projectBuildCommand, {
|
|
3864
|
+
env: spawnEnv,
|
|
3865
|
+
cwd: workPath
|
|
3866
|
+
});
|
|
3867
|
+
} else {
|
|
3868
|
+
await runPyprojectScript(
|
|
3869
|
+
workPath,
|
|
3870
|
+
["vercel-build", "now-build", "build"],
|
|
3871
|
+
spawnEnv
|
|
3872
|
+
);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
let fsFiles = await (0, import_build_utils7.glob)("**", workPath);
|
|
3786
3876
|
if ((framework === "fastapi" || framework === "flask") && (!fsFiles[entrypoint] || !entrypoint.endsWith(".py"))) {
|
|
3787
3877
|
const detected = await detectPythonEntrypoint(
|
|
3788
3878
|
config.framework,
|
|
@@ -3790,13 +3880,13 @@ var build = async ({
|
|
|
3790
3880
|
entrypoint
|
|
3791
3881
|
);
|
|
3792
3882
|
if (detected) {
|
|
3793
|
-
(0,
|
|
3883
|
+
(0, import_build_utils7.debug)(
|
|
3794
3884
|
`Resolved Python entrypoint to "${detected}" (configured "${entrypoint}" not found).`
|
|
3795
3885
|
);
|
|
3796
3886
|
entrypoint = detected;
|
|
3797
3887
|
} else {
|
|
3798
3888
|
const searchedList = framework === "fastapi" ? FASTAPI_CANDIDATE_ENTRYPOINTS.join(", ") : FLASK_CANDIDATE_ENTRYPOINTS.join(", ");
|
|
3799
|
-
throw new
|
|
3889
|
+
throw new import_build_utils7.NowBuildError({
|
|
3800
3890
|
code: `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`,
|
|
3801
3891
|
message: `No ${framework} entrypoint found. Define a valid application entrypoint in one of the following locations: ${searchedList} or add an 'app' script in pyproject.toml.`,
|
|
3802
3892
|
link: `https://vercel.com/docs/frameworks/backend/${framework}#exporting-the-${framework}-application`,
|
|
@@ -3825,20 +3915,20 @@ var build = async ({
|
|
|
3825
3915
|
if (pyprojectDir) {
|
|
3826
3916
|
let requiresPython;
|
|
3827
3917
|
try {
|
|
3828
|
-
const pyproject = await (0,
|
|
3918
|
+
const pyproject = await (0, import_build_utils8.readConfigFile)((0, import_path5.join)(pyprojectDir, "pyproject.toml"));
|
|
3829
3919
|
requiresPython = pyproject?.project?.["requires-python"];
|
|
3830
3920
|
} catch (err) {
|
|
3831
|
-
(0,
|
|
3921
|
+
(0, import_build_utils7.debug)("Failed to parse pyproject.toml", err);
|
|
3832
3922
|
}
|
|
3833
3923
|
const VERSION_REGEX = /\b\d+\.\d+\b/;
|
|
3834
3924
|
const exact = requiresPython?.trim().match(VERSION_REGEX)?.[0];
|
|
3835
3925
|
if (exact) {
|
|
3836
3926
|
declaredPythonVersion = { version: exact, source: "pyproject.toml" };
|
|
3837
|
-
(0,
|
|
3927
|
+
(0, import_build_utils7.debug)(
|
|
3838
3928
|
`Found Python version ${exact} in pyproject.toml (requires-python: "${requiresPython}")`
|
|
3839
3929
|
);
|
|
3840
3930
|
} else if (requiresPython) {
|
|
3841
|
-
(0,
|
|
3931
|
+
(0, import_build_utils7.debug)(
|
|
3842
3932
|
`Could not parse Python version from pyproject.toml requires-python: "${requiresPython}"`
|
|
3843
3933
|
);
|
|
3844
3934
|
}
|
|
@@ -3848,7 +3938,7 @@ var build = async ({
|
|
|
3848
3938
|
const json = await readFile((0, import_path5.join)(pipfileLockDir, "Pipfile.lock"), "utf8");
|
|
3849
3939
|
lock = JSON.parse(json);
|
|
3850
3940
|
} catch (err) {
|
|
3851
|
-
throw new
|
|
3941
|
+
throw new import_build_utils7.NowBuildError({
|
|
3852
3942
|
code: "INVALID_PIPFILE_LOCK",
|
|
3853
3943
|
message: "Unable to parse Pipfile.lock"
|
|
3854
3944
|
});
|
|
@@ -3856,14 +3946,14 @@ var build = async ({
|
|
|
3856
3946
|
const pyFromLock = lock?._meta?.requires?.python_version;
|
|
3857
3947
|
if (pyFromLock) {
|
|
3858
3948
|
declaredPythonVersion = { version: pyFromLock, source: "Pipfile.lock" };
|
|
3859
|
-
(0,
|
|
3949
|
+
(0, import_build_utils7.debug)(`Found Python version ${pyFromLock} in Pipfile.lock`);
|
|
3860
3950
|
}
|
|
3861
3951
|
}
|
|
3862
3952
|
const pythonVersion = getSupportedPythonVersion({
|
|
3863
3953
|
isDev: meta.isDev,
|
|
3864
3954
|
declaredPythonVersion
|
|
3865
3955
|
});
|
|
3866
|
-
fsFiles = await (0,
|
|
3956
|
+
fsFiles = await (0, import_build_utils7.glob)("**", workPath);
|
|
3867
3957
|
const requirementsTxt = (0, import_path5.join)(entryDirectory, "requirements.txt");
|
|
3868
3958
|
const vendorBaseDir = (0, import_path5.join)(
|
|
3869
3959
|
workPath,
|
|
@@ -3908,7 +3998,7 @@ var build = async ({
|
|
|
3908
3998
|
`uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
|
|
3909
3999
|
);
|
|
3910
4000
|
}
|
|
3911
|
-
(0,
|
|
4001
|
+
(0, import_build_utils7.debug)("Failed to install uv", err);
|
|
3912
4002
|
}
|
|
3913
4003
|
await installRequirement({
|
|
3914
4004
|
pythonPath: pythonVersion.pythonPath,
|
|
@@ -3934,7 +4024,7 @@ var build = async ({
|
|
|
3934
4024
|
}
|
|
3935
4025
|
let installedFromProjectFiles = false;
|
|
3936
4026
|
if (uvLockDir) {
|
|
3937
|
-
(0,
|
|
4027
|
+
(0, import_build_utils7.debug)('Found "uv.lock"');
|
|
3938
4028
|
if (pyprojectDir) {
|
|
3939
4029
|
const exportedReq = await exportRequirementsFromUv(pyprojectDir, uvPath, {
|
|
3940
4030
|
locked: true
|
|
@@ -3950,10 +4040,10 @@ var build = async ({
|
|
|
3950
4040
|
});
|
|
3951
4041
|
installedFromProjectFiles = true;
|
|
3952
4042
|
} else {
|
|
3953
|
-
(0,
|
|
4043
|
+
(0, import_build_utils7.debug)('Skipping uv export because "pyproject.toml" was not found');
|
|
3954
4044
|
}
|
|
3955
4045
|
} else if (pyprojectDir) {
|
|
3956
|
-
(0,
|
|
4046
|
+
(0, import_build_utils7.debug)('Found "pyproject.toml"');
|
|
3957
4047
|
if (hasReqLocal || hasReqGlobal) {
|
|
3958
4048
|
console.log(
|
|
3959
4049
|
"Detected both pyproject.toml and requirements.txt but no lockfile; using pyproject.toml"
|
|
@@ -3973,9 +4063,9 @@ var build = async ({
|
|
|
3973
4063
|
});
|
|
3974
4064
|
installedFromProjectFiles = true;
|
|
3975
4065
|
} else if (pipfileLockDir || pipfileDir) {
|
|
3976
|
-
(0,
|
|
4066
|
+
(0, import_build_utils7.debug)(`Found ${pipfileLockDir ? '"Pipfile.lock"' : '"Pipfile"'}`);
|
|
3977
4067
|
if (hasReqLocal || hasReqGlobal) {
|
|
3978
|
-
(0,
|
|
4068
|
+
(0, import_build_utils7.debug)('Skipping Pipfile export because "requirements.txt" exists');
|
|
3979
4069
|
} else {
|
|
3980
4070
|
const exportedReq = await exportRequirementsFromPipfile({
|
|
3981
4071
|
pythonPath: pythonVersion.pythonPath,
|
|
@@ -3997,7 +4087,7 @@ var build = async ({
|
|
|
3997
4087
|
}
|
|
3998
4088
|
}
|
|
3999
4089
|
if (!installedFromProjectFiles && fsFiles[requirementsTxt]) {
|
|
4000
|
-
(0,
|
|
4090
|
+
(0, import_build_utils7.debug)('Found local "requirements.txt"');
|
|
4001
4091
|
const requirementsTxtPath = fsFiles[requirementsTxt].fsPath;
|
|
4002
4092
|
await installRequirementsFile({
|
|
4003
4093
|
pythonPath: pythonVersion.pythonPath,
|
|
@@ -4009,7 +4099,7 @@ var build = async ({
|
|
|
4009
4099
|
meta
|
|
4010
4100
|
});
|
|
4011
4101
|
} else if (!installedFromProjectFiles && fsFiles["requirements.txt"]) {
|
|
4012
|
-
(0,
|
|
4102
|
+
(0, import_build_utils7.debug)('Found global "requirements.txt"');
|
|
4013
4103
|
const requirementsTxtPath = fsFiles["requirements.txt"].fsPath;
|
|
4014
4104
|
await installRequirementsFile({
|
|
4015
4105
|
pythonPath: pythonVersion.pythonPath,
|
|
@@ -4023,12 +4113,12 @@ var build = async ({
|
|
|
4023
4113
|
}
|
|
4024
4114
|
const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
|
|
4025
4115
|
const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
|
|
4026
|
-
(0,
|
|
4116
|
+
(0, import_build_utils7.debug)("Entrypoint is", entrypoint);
|
|
4027
4117
|
const moduleName = entrypoint.replace(/\//g, ".").replace(/\.py$/i, "");
|
|
4028
4118
|
const vendorDir = resolveVendorDir();
|
|
4029
4119
|
const suffix = meta.isDev && !entrypoint.endsWith(".py") ? ".py" : "";
|
|
4030
4120
|
const entrypointWithSuffix = `${entrypoint}${suffix}`;
|
|
4031
|
-
(0,
|
|
4121
|
+
(0, import_build_utils7.debug)("Entrypoint with suffix is", entrypointWithSuffix);
|
|
4032
4122
|
const handlerPyContents = originalHandlerPyContents.replace(/__VC_HANDLER_MODULE_NAME/g, moduleName).replace(/__VC_HANDLER_ENTRYPOINT/g, entrypointWithSuffix).replace(/__VC_HANDLER_VENDOR_DIR/g, vendorDir);
|
|
4033
4123
|
const predefinedExcludes = [
|
|
4034
4124
|
".git/**",
|
|
@@ -4054,11 +4144,11 @@ var build = async ({
|
|
|
4054
4144
|
cwd: workPath,
|
|
4055
4145
|
ignore: config && typeof config.excludeFiles === "string" ? [...predefinedExcludes, config.excludeFiles] : predefinedExcludes
|
|
4056
4146
|
};
|
|
4057
|
-
const files = await (0,
|
|
4147
|
+
const files = await (0, import_build_utils7.glob)("**", globOptions);
|
|
4058
4148
|
try {
|
|
4059
4149
|
const cachedVendorAbs = (0, import_path5.join)(vendorBaseDir, resolveVendorDir());
|
|
4060
4150
|
if (import_fs5.default.existsSync(cachedVendorAbs)) {
|
|
4061
|
-
const vendorFiles = await (0,
|
|
4151
|
+
const vendorFiles = await (0, import_build_utils7.glob)("**", cachedVendorAbs, resolveVendorDir());
|
|
4062
4152
|
for (const [p, f] of Object.entries(vendorFiles)) {
|
|
4063
4153
|
files[p] = f;
|
|
4064
4154
|
}
|
|
@@ -4068,12 +4158,12 @@ var build = async ({
|
|
|
4068
4158
|
throw err;
|
|
4069
4159
|
}
|
|
4070
4160
|
const handlerPyFilename = "vc__handler__python";
|
|
4071
|
-
files[`${handlerPyFilename}.py`] = new
|
|
4161
|
+
files[`${handlerPyFilename}.py`] = new import_build_utils7.FileBlob({ data: handlerPyContents });
|
|
4072
4162
|
if (config.framework === "fasthtml") {
|
|
4073
4163
|
const { SESSKEY = "" } = process.env;
|
|
4074
|
-
files[".sesskey"] = new
|
|
4164
|
+
files[".sesskey"] = new import_build_utils7.FileBlob({ data: `"${SESSKEY}"` });
|
|
4075
4165
|
}
|
|
4076
|
-
const output = new
|
|
4166
|
+
const output = new import_build_utils7.Lambda({
|
|
4077
4167
|
files,
|
|
4078
4168
|
handler: `${handlerPyFilename}.vc_handler`,
|
|
4079
4169
|
runtime: pythonVersion.runtime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@types/jest": "27.4.1",
|
|
22
22
|
"@types/node": "14.18.33",
|
|
23
23
|
"@types/which": "3.0.0",
|
|
24
|
-
"@vercel/build-utils": "13.0.
|
|
24
|
+
"@vercel/build-utils": "13.0.1",
|
|
25
25
|
"cross-env": "7.0.3",
|
|
26
26
|
"execa": "^1.0.0",
|
|
27
27
|
"fs-extra": "11.1.1",
|