@vercel/python 6.1.2 → 6.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +55 -35
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2858,9 +2858,17 @@ async function runUvCommand(options) {
2858
2858
  });
2859
2859
  return true;
2860
2860
  } catch (err) {
2861
- throw new Error(
2861
+ const error = new Error(
2862
2862
  `Failed to run "${pretty}": ${err instanceof Error ? err.message : String(err)}`
2863
2863
  );
2864
+ if (err && typeof err === "object") {
2865
+ if ("code" in err) {
2866
+ error.code = err.code;
2867
+ } else if ("signal" in err) {
2868
+ error.code = err.signal;
2869
+ }
2870
+ }
2871
+ throw error;
2864
2872
  }
2865
2873
  }
2866
2874
  function findDir({
@@ -4254,6 +4262,8 @@ var build = async ({
4254
4262
  config
4255
4263
  }) => {
4256
4264
  const framework = config?.framework;
4265
+ let spawnEnv;
4266
+ let projectInstallCommand;
4257
4267
  workPath = await downloadFilesInWorkPath({
4258
4268
  workPath,
4259
4269
  files: originalFiles,
@@ -4276,7 +4286,7 @@ var build = async ({
4276
4286
  packageJsonPackageManager,
4277
4287
  turboSupportsCorepackHome
4278
4288
  } = await (0, import_build_utils7.scanParentDirs)(workPath, true);
4279
- const spawnEnv = (0, import_build_utils7.getEnvForPackageManager)({
4289
+ spawnEnv = (0, import_build_utils7.getEnvForPackageManager)({
4280
4290
  cliType,
4281
4291
  lockfileVersion,
4282
4292
  packageJsonPackageManager,
@@ -4286,12 +4296,9 @@ var build = async ({
4286
4296
  });
4287
4297
  const installCommand = config?.projectSettings?.installCommand;
4288
4298
  if (typeof installCommand === "string") {
4289
- if (installCommand.trim()) {
4290
- console.log(`Running "install" command: \`${installCommand}\`...`);
4291
- await (0, import_build_utils7.execCommand)(installCommand, {
4292
- env: spawnEnv,
4293
- cwd: workPath
4294
- });
4299
+ const trimmed = installCommand.trim();
4300
+ if (trimmed) {
4301
+ projectInstallCommand = trimmed;
4295
4302
  } else {
4296
4303
  console.log('Skipping "install" command...');
4297
4304
  }
@@ -4390,34 +4397,47 @@ var build = async ({
4390
4397
  pythonPath: pythonVersion.pythonPath,
4391
4398
  venvPath
4392
4399
  });
4393
- let uvPath;
4394
- try {
4395
- uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
4396
- console.log(`Using uv at "${uvPath}"`);
4397
- } catch (err) {
4398
- console.log("Failed to install or locate uv");
4399
- throw new Error(
4400
- `uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
4401
- );
4400
+ const hasCustomInstallCommand = (framework === "fastapi" || framework === "flask") && !!projectInstallCommand;
4401
+ if (hasCustomInstallCommand) {
4402
+ const baseEnv = spawnEnv || process.env;
4403
+ const pythonEnv = createVenvEnv(venvPath, baseEnv);
4404
+ pythonEnv.VERCEL_PYTHON_VENV_PATH = venvPath;
4405
+ const installCommand = projectInstallCommand;
4406
+ console.log(`Running "install" command: \`${installCommand}\`...`);
4407
+ await (0, import_build_utils7.execCommand)(installCommand, {
4408
+ env: pythonEnv,
4409
+ cwd: workPath
4410
+ });
4411
+ } else {
4412
+ let uvPath;
4413
+ try {
4414
+ uvPath = await getUvBinaryOrInstall(pythonVersion.pythonPath);
4415
+ console.log(`Using uv at "${uvPath}"`);
4416
+ } catch (err) {
4417
+ console.log("Failed to install or locate uv");
4418
+ throw new Error(
4419
+ `uv is required for this project but failed to install: ${err instanceof Error ? err.message : String(err)}`
4420
+ );
4421
+ }
4422
+ const runtimeDependencies = framework === "flask" ? ["werkzeug>=1.0.1"] : ["werkzeug>=1.0.1", "uvicorn>=0.24"];
4423
+ const { projectDir } = await ensureUvProject({
4424
+ workPath,
4425
+ entryDirectory,
4426
+ fsFiles,
4427
+ pythonPath: pythonVersion.pythonPath,
4428
+ pipPath: pythonVersion.pipPath,
4429
+ uvPath,
4430
+ venvPath,
4431
+ meta,
4432
+ runtimeDependencies
4433
+ });
4434
+ await runUvSync({
4435
+ uvPath,
4436
+ venvPath,
4437
+ projectDir,
4438
+ locked: true
4439
+ });
4402
4440
  }
4403
- const runtimeDependencies = framework === "flask" ? ["werkzeug>=1.0.1"] : ["werkzeug>=1.0.1", "uvicorn>=0.24"];
4404
- const { projectDir } = await ensureUvProject({
4405
- workPath,
4406
- entryDirectory,
4407
- fsFiles,
4408
- pythonPath: pythonVersion.pythonPath,
4409
- pipPath: pythonVersion.pipPath,
4410
- uvPath,
4411
- venvPath,
4412
- meta,
4413
- runtimeDependencies
4414
- });
4415
- await runUvSync({
4416
- uvPath,
4417
- venvPath,
4418
- projectDir,
4419
- locked: true
4420
- });
4421
4441
  const originalPyPath = (0, import_path5.join)(__dirname, "..", "vc_init.py");
4422
4442
  const originalHandlerPyContents = await readFile(originalPyPath, "utf8");
4423
4443
  (0, import_build_utils7.debug)("Entrypoint is", entrypoint);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",