@vercel/python 6.47.2 → 6.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +31 -21
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4380,7 +4380,7 @@ var import_fs15 = __toESM(require("fs"));
4380
4380
  var import_path15 = require("path");
4381
4381
 
4382
4382
  // src/package-versions.ts
4383
- var VERCEL_RUNTIME_VERSION = "0.15.0";
4383
+ var VERCEL_RUNTIME_VERSION = "0.16.0";
4384
4384
  var VERCEL_WORKERS_VERSION = "0.0.25";
4385
4385
 
4386
4386
  // src/index.ts
@@ -7781,12 +7781,12 @@ var startDevServer = async (opts) => {
7781
7781
  } : void 0,
7782
7782
  service
7783
7783
  );
7784
+ let hookResult;
7784
7785
  if (detected?.entrypoint) {
7785
7786
  resolved = detected.entrypoint;
7786
7787
  } else {
7787
- const hookResult = await runFrameworkHook(framework, {
7788
+ hookResult = await runFrameworkHook(framework, {
7788
7789
  pythonEnv: env,
7789
- projectDir: (0, import_path10.join)(workPath, detected?.baseDir ?? ""),
7790
7790
  workPath,
7791
7791
  entrypoint,
7792
7792
  detected: detected ?? void 0
@@ -7945,6 +7945,9 @@ If you are using a virtual environment, activate it before running "vercel dev",
7945
7945
  if (devShim.extraPythonPath) {
7946
7946
  pathParts.push(devShim.extraPythonPath);
7947
7947
  }
7948
+ if (hookResult?.extraPythonPath) {
7949
+ pathParts.push(hookResult.extraPythonPath);
7950
+ }
7948
7951
  const existingPythonPath = env.PYTHONPATH || "";
7949
7952
  if (existingPythonPath) {
7950
7953
  pathParts.push(existingPythonPath);
@@ -8493,7 +8496,7 @@ async function getDjangoSettings(projectDir, env) {
8493
8496
  djangoVersion: parsed.django_version ?? null
8494
8497
  };
8495
8498
  }
8496
- async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir, settingsModule, djangoSettings, djangoVersion) {
8499
+ async function runDjangoCollectStatic(venvPath, workPath, djangoPath, env, outputStaticDir, settingsModule, djangoSettings, djangoVersion) {
8497
8500
  const pythonPath = getVenvPythonBin(venvPath);
8498
8501
  const storages = djangoSettings["STORAGES"];
8499
8502
  const useLegacySetting = !djangoVersion || djangoVersion[0] < 5 || djangoVersion[0] === 5 && djangoVersion[1] < 1;
@@ -8505,7 +8508,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8505
8508
  const installedApps = djangoSettings["INSTALLED_APPS"] ?? [];
8506
8509
  const staticfilesDirs = djangoSettings["STATICFILES_DIRS"] ?? [];
8507
8510
  const staticSourceDirs = [
8508
- ...installedApps.map((app) => (0, import_path13.join)(workPath, ...app.split("."), "static")),
8511
+ ...installedApps.map((app) => (0, import_path13.join)(djangoPath, ...app.split("."), "static")),
8509
8512
  // TODO: Deal with optional prefixes in STATICFILES_DIRS.
8510
8513
  ...staticfilesDirs.map((d) => Array.isArray(d) ? d[1] : d)
8511
8514
  ].filter((d) => import_fs13.default.existsSync(d));
@@ -8515,11 +8518,11 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8515
8518
  );
8516
8519
  await (0, import_execa7.default)(pythonPath, ["manage.py", "collectstatic", "--noinput"], {
8517
8520
  env: { ...env, DJANGO_SETTINGS_MODULE: settingsModule },
8518
- cwd: workPath
8521
+ cwd: djangoPath
8519
8522
  });
8520
8523
  return {
8521
8524
  staticSourceDirs,
8522
- staticRoot: staticRoot ? (0, import_path13.resolve)(workPath, staticRoot) : null,
8525
+ staticRoot: staticRoot ? (0, import_path13.resolve)(djangoPath, staticRoot) : null,
8523
8526
  cdnOutputDir: null,
8524
8527
  manifestRelPath: null
8525
8528
  };
@@ -8533,7 +8536,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8533
8536
  const staticUrlPath = staticUrl.replace(/^\/|\/$/g, "") || "static";
8534
8537
  const staticOutputDir = (0, import_path13.join)(outputStaticDir, staticUrlPath);
8535
8538
  await import_fs13.default.promises.mkdir(staticOutputDir, { recursive: true });
8536
- const shimPath = (0, import_path13.join)(workPath, "_vercel_collectstatic_settings.py");
8539
+ const shimPath = (0, import_path13.join)(djangoPath, "_vercel_collectstatic_settings.py");
8537
8540
  const shimLines = [
8538
8541
  `from ${settingsModule} import *`,
8539
8542
  `STATIC_ROOT = ${JSON.stringify(staticOutputDir)}`
@@ -8549,7 +8552,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8549
8552
  ...env,
8550
8553
  DJANGO_SETTINGS_MODULE: "_vercel_collectstatic_settings"
8551
8554
  },
8552
- cwd: workPath
8555
+ cwd: djangoPath
8553
8556
  });
8554
8557
  } finally {
8555
8558
  await import_fs13.default.promises.unlink(shimPath).catch(() => {
@@ -8562,7 +8565,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8562
8565
  let manifestRelPath = null;
8563
8566
  if (MANIFEST_STORAGE_BACKENDS.includes(storageBackend) && staticRoot) {
8564
8567
  const manifestSrc = (0, import_path13.join)(staticOutputDir, "staticfiles.json");
8565
- const resolvedStaticRoot = (0, import_path13.resolve)(workPath, staticRoot);
8568
+ const resolvedStaticRoot = (0, import_path13.resolve)(djangoPath, staticRoot);
8566
8569
  const manifestDest = (0, import_path13.join)(resolvedStaticRoot, "staticfiles.json");
8567
8570
  await import_fs13.default.promises.mkdir(resolvedStaticRoot, { recursive: true });
8568
8571
  await import_fs13.default.promises.copyFile(manifestSrc, manifestDest);
@@ -8571,7 +8574,7 @@ async function runDjangoCollectStatic(venvPath, workPath, env, outputStaticDir,
8571
8574
  }
8572
8575
  return {
8573
8576
  staticSourceDirs,
8574
- staticRoot: staticRoot ? (0, import_path13.resolve)(workPath, staticRoot) : null,
8577
+ staticRoot: staticRoot ? (0, import_path13.resolve)(djangoPath, staticRoot) : null,
8575
8578
  cdnOutputDir: outputStaticDir,
8576
8579
  manifestRelPath
8577
8580
  };
@@ -8807,18 +8810,22 @@ async function runFrameworkHook(framework, ctx) {
8807
8810
  var frameworkHooks = {
8808
8811
  django: async ({
8809
8812
  pythonEnv,
8810
- projectDir,
8811
8813
  workPath,
8812
8814
  venvPath,
8813
8815
  detected
8814
8816
  }) => {
8815
- if (detected?.baseDir === void 0) {
8816
- (0, import_build_utils19.debug)("Django hook: no manage.py detected, skipping");
8817
- return;
8817
+ let baseDir = detected?.baseDir;
8818
+ if (baseDir === void 0) {
8819
+ if (!import_fs15.default.existsSync((0, import_path15.join)(workPath, "manage.py"))) {
8820
+ (0, import_build_utils19.debug)("Django hook: no manage.py detected, skipping");
8821
+ return;
8822
+ }
8823
+ baseDir = "";
8818
8824
  }
8825
+ const djangoPath = (0, import_path15.join)(workPath, baseDir);
8819
8826
  let settingsResult;
8820
8827
  try {
8821
- settingsResult = await getDjangoSettings(projectDir, pythonEnv);
8828
+ settingsResult = await getDjangoSettings(djangoPath, pythonEnv);
8822
8829
  } catch (err) {
8823
8830
  let detail;
8824
8831
  if (err?.code === "ENOENT") {
@@ -8829,7 +8836,7 @@ Hint: activate a venv or run with \`uv run vercel dev\``;
8829
8836
  }
8830
8837
  throw new import_build_utils19.NowBuildError({
8831
8838
  code: "DJANGO_SETTINGS_FAILED",
8832
- message: `Failed to read Django application settings from ${projectDir}/manage.py:
8839
+ message: `Failed to read Django application settings from ${djangoPath}/manage.py:
8833
8840
  ${detail}`
8834
8841
  });
8835
8842
  }
@@ -8839,7 +8846,6 @@ ${detail}`
8839
8846
  console.log(`Django ${djangoVersion.join(".")} detected`);
8840
8847
  }
8841
8848
  let resolvedEntrypoint;
8842
- const baseDir = detected?.baseDir ?? "";
8843
8849
  const asgiApp = djangoSettings["ASGI_APPLICATION"];
8844
8850
  if (typeof asgiApp === "string") {
8845
8851
  const parts = asgiApp.split(".");
@@ -8867,6 +8873,7 @@ ${detail}`
8867
8873
  djangoStatic = await runDjangoCollectStatic(
8868
8874
  venvPath,
8869
8875
  workPath,
8876
+ djangoPath,
8870
8877
  pythonEnv,
8871
8878
  outputStaticDir,
8872
8879
  settingsModule,
@@ -8874,7 +8881,11 @@ ${detail}`
8874
8881
  djangoVersion
8875
8882
  );
8876
8883
  }
8877
- return { entrypoint: resolvedEntrypoint, djangoStatic };
8884
+ return {
8885
+ entrypoint: resolvedEntrypoint,
8886
+ djangoStatic,
8887
+ extraPythonPath: baseDir ? (0, import_path15.join)(workPath, baseDir) : void 0
8888
+ };
8878
8889
  }
8879
8890
  };
8880
8891
  function createRuntimeTrampoline({
@@ -9262,7 +9273,6 @@ var build = async ({
9262
9273
  }
9263
9274
  const hookResult = await runFrameworkHook(framework, {
9264
9275
  pythonEnv,
9265
- projectDir: (0, import_path15.join)(workPath, entryDirectory),
9266
9276
  workPath,
9267
9277
  venvPath,
9268
9278
  entrypoint,
@@ -9577,7 +9587,7 @@ var build = async ({
9577
9587
  if (!(0, import_build_utils19.isPythonFramework)(framework) && !service?.name) {
9578
9588
  return { resultVersion: 3, result: { output } };
9579
9589
  }
9580
- const lambdaPath = service?.name ? `_svc/${service.name}/index` : "index";
9590
+ const lambdaPath = service?.name && service.type ? `_svc/${service.name}/index` : "index";
9581
9591
  const staticFiles = djangoStatic?.cdnOutputDir ? await (0, import_build_utils19.glob)("**", { cwd: djangoStatic.cdnOutputDir }) : {};
9582
9592
  const isNonWebService = service?.name && service.type && service.type !== "web";
9583
9593
  const routes = isNonWebService ? void 0 : [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.47.2",
3
+ "version": "6.48.0",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -37,8 +37,8 @@
37
37
  "vitest": "2.1.4",
38
38
  "which": "3.0.0",
39
39
  "@vercel/error-utils": "2.2.0",
40
- "@vercel/build-utils": "13.32.1",
41
- "@vercel/python-runtime": "0.15.0"
40
+ "@vercel/build-utils": "13.32.2",
41
+ "@vercel/python-runtime": "0.16.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "node ../../utils/build-builder.mjs",