1{
2 buildPythonPackage,
3 eliot,
4 fetchPypi,
5 google-search-results,
6 jinja2,
7 lib,
8 manifest-ml,
9 openai,
10 pytestCheckHook,
11 pythonAtLeast,
12 pythonRelaxDepsHook,
13}:
14
15buildPythonPackage rec {
16 pname = "minichain";
17 version = "0.3.3";
18 format = "setuptools";
19
20 # See https://github.com/NixOS/nixpkgs/pull/248195#issuecomment-1687398702.
21 disabled = pythonAtLeast "3.11";
22
23 # See https://github.com/srush/MiniChain/issues/23 and https://github.com/NixOS/nixpkgs/issues/248185 as to why we
24 # don't fetchFromGitHub.
25 src = fetchPypi {
26 inherit pname version;
27 hash = "sha256-+mju1Mz/aojROpiOVzv6WoRNTrhgCub4yyYLEWcHWh0=";
28 };
29
30 # See https://github.com/srush/MiniChain/issues/24.
31 postPatch = ''
32 substituteInPlace ./minichain/__init__.py --replace "from .gradio import GradioConf, show" ""
33 '';
34
35 nativeBuildInputs = [ pythonRelaxDepsHook ];
36
37 pythonRemoveDeps = [
38 # Only used in the examples:
39 "datasets"
40 "faiss-cpu"
41 "jinja2-highlight"
42 "trio"
43
44 # Not used anywhere:
45 "eliot-tree"
46
47 # Not yet packaged in nixpkgs:
48 "gradio"
49 ];
50
51 # Some of these could be made optional. Certain packages are used by certain backends.
52 propagatedBuildInputs = [
53 eliot
54 google-search-results
55 jinja2
56 manifest-ml
57 openai
58 ];
59
60 # As of 0.3.3, the PyPI distribution does not include any tests.
61 doCheck = false;
62
63 pythonImportsCheck = [ "minichain" ];
64
65 nativeCheckInputs = [ pytestCheckHook ];
66
67 meta = with lib; {
68 description = "A tiny library for coding with large language models";
69 homepage = "https://srush-minichain.hf.space";
70 changelog = "https://github.com/srush/MiniChain/releases/tag/v${version}";
71 license = licenses.mit;
72 maintainers = with maintainers; [ samuela ];
73 };
74}