Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / llm / default.nix
blob5626da5e3858ece654558f38e1f4f4b53a017c52
1 { lib
2 , buildPythonApplication
3 , buildPythonPackage
4 , fetchFromGitHub
5 , makeWrapper
6 , pytestCheckHook
7 , python3
8 , pythonOlder
9 , ruff
10 , setuptools
12 let
13   llm = buildPythonPackage rec {
14     pname = "llm";
15     version = "0.13.1";
16     pyproject = true;
18     disabled = pythonOlder "3.8";
20     src = fetchFromGitHub {
21       owner = "simonw";
22       repo = "llm";
23       rev = "refs/tags/${version}";
24       hash = "sha256-Nq6pduzl8IK+nA3pctst/W4ux7+P6mBFTEHMF+vtBQw=";
25     };
27     patches = [
28       ./001-disable-install-uninstall-commands.patch
29     ];
31     nativeBuildInputs = [
32       setuptools
33     ];
35     propagatedBuildInputs = with python3.pkgs; [
36       click-default-group
37       numpy
38       openai
39       pip
40       pluggy
41       pydantic
42       python-ulid
43       pyyaml
44       setuptools # for pkg_resources
45       sqlite-migrate
46       sqlite-utils
47     ];
49     nativeCheckInputs = with python3.pkgs; [
50       cogapp
51       numpy
52       pytest-httpx
53       pytestCheckHook
54     ];
56     doCheck = true;
58     pytestFlagsArray = [
59       "-svv"
60       "tests/"
61     ];
63     pythonImportsCheck = [
64       "llm"
65     ];
67     passthru = {inherit withPlugins;};
69     meta = with lib; {
70       homepage = "https://github.com/simonw/llm";
71       description = "Access large language models from the command-line";
72       changelog = "https://github.com/simonw/llm/releases/tag/${version}";
73       license = licenses.asl20;
74       mainProgram = "llm";
75       maintainers = with maintainers; [aldoborrero];
76     };
77   };
79   withPlugins = plugins: buildPythonApplication {
80     inherit (llm) pname version;
81     format = "other";
83     disabled = pythonOlder "3.8";
85     dontUnpack = true;
86     dontBuild = true;
87     doCheck = false;
89     nativeBuildInputs = [
90       makeWrapper
91     ];
93     installPhase = ''
94       makeWrapper ${llm}/bin/llm $out/bin/llm \
95         --prefix PYTHONPATH : "${llm}/${python3.sitePackages}:$PYTHONPATH"
96       ln -sfv ${llm}/lib $out/lib
97     '';
99     propagatedBuildInputs = llm.propagatedBuildInputs ++ plugins;
101     passthru = llm.passthru // {
102       withPlugins = morePlugins: withPlugins (morePlugins ++ plugins);
103     };
105     inherit (llm) meta;
106   };
108   llm