Skip to content

Commit 1d0a97c

Browse files
committed
build(nix): Exclude gguf-py from devShells
1 parent 2b51e13 commit 1d0a97c

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

.devops/nix/package.nix

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,27 @@ let
6363
suffices != [ ]
6464
) ", accelerated with ${strings.concatStringsSep ", " suffices}";
6565

66+
mapToPythonPackages = ps: packages: map (package: ps.${package}) packages;
67+
6668
# TODO: package the Python in this repository in a Nix-like way.
6769
# It'd be nice to migrate to buildPythonPackage, as well as ensure this repo
6870
# is PEP 517-compatible, and ensure the correct .dist-info is generated.
6971
# https://peps.python.org/pep-0517/
70-
llama-python = python3.withPackages (ps: [
71-
ps.numpy
72-
ps.sentencepiece
73-
gguf-py
74-
]);
72+
llama-python-base-deps = [
73+
"numpy"
74+
"sentencepiece"
75+
];
7576

7677
# TODO(Green-Sky): find a better way to opt-into the heavy ml python runtime
77-
llama-python-extra = python3.withPackages (ps: [
78-
ps.numpy
79-
ps.sentencepiece
80-
ps.tiktoken
81-
ps.torchWithoutCuda
82-
ps.transformers
83-
]);
78+
llama-python-full-deps = llama-python-base-deps ++ [
79+
"tiktoken"
80+
"torchWithoutCuda"
81+
"transformers"
82+
];
83+
84+
llama-python-base-with-gguf = python3.withPackages (
85+
ps: (mapToPythonPackages ps llama-python-base-deps) ++ [ gguf-py ]
86+
);
8487

8588
# apple_sdk is supposed to choose sane defaults, no need to handle isAarch64
8689
# separately
@@ -148,7 +151,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
148151
# TODO: Package up each Python script or service appropriately.
149152
# If we were to migrate to buildPythonPackage and prepare the `pyproject.toml`,
150153
# we could make those *.py into setuptools' entrypoints
151-
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python}/bin/python"
154+
substituteInPlace ./*.py --replace "/usr/bin/env python" "${llama-python-base-with-gguf}/bin/python"
152155
'';
153156

154157
nativeBuildInputs =
@@ -233,7 +236,10 @@ effectiveStdenv.mkDerivation (finalAttrs: {
233236
shell = mkShell {
234237
name = "shell-${finalAttrs.finalPackage.name}";
235238
description = "contains numpy and sentencepiece";
236-
buildInputs = [ llama-python ];
239+
buildInputs = [
240+
python3.withPackages
241+
(ps: mapToPythonPackages ps llama-python-base-deps)
242+
];
237243
inputsFrom = [ finalAttrs.finalPackage ];
238244
shellHook = ''
239245
addToSearchPath "LD_LIBRARY_PATH" "${lib.getLib effectiveStdenv.cc.cc}/lib"
@@ -243,7 +249,10 @@ effectiveStdenv.mkDerivation (finalAttrs: {
243249
shell-extra = mkShell {
244250
name = "shell-extra-${finalAttrs.finalPackage.name}";
245251
description = "contains numpy, sentencepiece, torchWithoutCuda, and transformers";
246-
buildInputs = [ llama-python-extra ];
252+
buildInputs = [
253+
python3.withPackages
254+
(ps: mapToPythonPackages ps llama-python-full-deps)
255+
];
247256
inputsFrom = [ finalAttrs.finalPackage ];
248257
};
249258
};

0 commit comments

Comments
 (0)