Unverified Commit ec2d6a5b authored by Yt's avatar Yt Committed by GitHub
Browse files

aider-chat: add optional dependencies for help and browser support (#393339)

parents d2c98293 2164766a
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
{
  python3Packages,
  withPlaywright ? false,
}:

if withPlaywright then
  python3Packages.toPythonApplication python3Packages.aider-chat.passthru.withPlaywright
else
  python3Packages.toPythonApplication python3Packages.aider-chat
+76 −15
Original line number Diff line number Diff line
@@ -6,9 +6,18 @@
  gitMinimal,
  portaudio,
  playwright-driver,
  symlinkJoin,
  nltk-data,
}:

let
  aider-nltk-data = symlinkJoin {
    name = "aider-nltk-data";
    paths = [
      nltk-data.punkt_tab
      nltk-data.stopwords
    ];
  };
  python3 = python312.override {
    self = python3;
    packageOverrides = _: super: { tree-sitter = super.tree-sitter_0_21; };
@@ -161,8 +170,12 @@ let
      ];

    makeWrapperArgs = [
      "--set AIDER_CHECK_UPDATE false"
      "--set AIDER_ANALYTICS false"
      "--set"
      "AIDER_CHECK_UPDATE"
      "false"
      "--set"
      "AIDER_ANALYTICS"
      "false"
    ];

    preCheck = ''
@@ -177,23 +190,71 @@ let
        pyee
        typing-extensions
      ];
      browser = [
        streamlit
      ];
      help = [
        llama-index-core
        llama-index-embeddings-huggingface
        torch
        nltk
      ];
      bedrock = [
        boto3
      ];
    };

    passthru = {
      withPlaywright = aider-chat.overridePythonAttrs (
      withOptional =
        {
          withPlaywright ? false,
          withBrowser ? false,
          withHelp ? false,
          withBedrock ? false,
          withAll ? false,
          ...
        }:
        aider-chat.overridePythonAttrs (
          {
            dependencies,
            makeWrapperArgs,
            propagatedBuildInputs ? [ ],
            ...
          }:
          let
            playwrightDeps =
              if withPlaywright || withAll then aider-chat.optional-dependencies.playwright else [ ];
            browserDeps = if withBrowser || withAll then aider-chat.optional-dependencies.browser else [ ];
            helpDeps = if withHelp || withAll then aider-chat.optional-dependencies.help else [ ];
            bedrockDeps = if withBedrock || withAll then aider-chat.optional-dependencies.bedrock else [ ];

            playwrightInputs = if withPlaywright || withAll then [ playwright-driver.browsers ] else [ ];
            playwrightArgs =
              if withPlaywright || withAll then
                [
                  "--set"
                  "PLAYWRIGHT_BROWSERS_PATH"
                  "${playwright-driver.browsers}"
                  "--set"
                  "PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS"
                  "true"
                ]
              else
                [ ];
            helpArgs =
              if withHelp || withAll then
                [
                  "--set"
                  "NLTK_DATA"
                  "${aider-nltk-data}"
                ]
              else
                [ ];
          in
          {
          dependencies = dependencies ++ aider-chat.optional-dependencies.playwright;
          propagatedBuildInputs = propagatedBuildInputs ++ [ playwright-driver.browsers ];
          makeWrapperArgs = makeWrapperArgs ++ [
            "--set PLAYWRIGHT_BROWSERS_PATH ${playwright-driver.browsers}"
            "--set PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true"
          ];
            dependencies = dependencies ++ playwrightDeps ++ browserDeps ++ helpDeps ++ bedrockDeps;
            propagatedBuildInputs = propagatedBuildInputs ++ playwrightInputs;
            makeWrapperArgs = makeWrapperArgs ++ playwrightArgs ++ helpArgs;
          }
        );
    };
+12 −0
Original line number Diff line number Diff line
@@ -170,6 +170,18 @@ with pkgs;
    } ../build-support/setup-hooks/add-bin-to-path.sh
  ) { };
  aider-chat = with python3Packages; toPythonApplication aider-chat;
  aider-chat-with-playwright = with python3Packages; toPythonApplication (aider-chat.withOptional { withPlaywright = true; });
  aider-chat-with-browser = with python3Packages; toPythonApplication (aider-chat.withOptional { withBrowser = true; });
  aider-chat-with-help = with python3Packages; toPythonApplication (aider-chat.withOptional { withHelp = true; });
  aider-chat-with-bedrock = with python3Packages; toPythonApplication (aider-chat.withOptional { withBedrock = true; });
  aider-chat-full = with python3Packages; toPythonApplication (aider-chat.withOptional { withAll = true; });
  autoreconfHook = callPackage (
    { makeSetupHook, autoconf, automake, gettext, libtool }:
    makeSetupHook {