-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
214 lines (198 loc) · 6.22 KB
/
Copy pathflake.nix
File metadata and controls
214 lines (198 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# TODO: reintroduce the dbg macro somehow
{
description = "PANNA: Playground for Approximate Nearest Neighbor Algorithms";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.hl = {
url = "github:pamburus/hl";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.flake-utils = {
url = "github:numtide/flake-utils";
};
inputs.sigmod-hdbscan = {
url = "github:FrancescoMonaco/hdbscan";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
hl,
flake-utils,
sigmod-hdbscan,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {inherit system;};
hl-bin = hl.packages.${system}.default;
python = pkgs.python312.override {
# make the override recursive so `python.pkgs` / `python.withPackages`
# use the patched package set below.
self = python;
packageOverrides = pyfinal: pyprev: {
# Patched pynndescent that counts the number of metric distance
# evaluations performed during NNDescent graph construction and
# querying (this is the subroutine fast_hdbscan uses for
# non-euclidean / high-dimensional metrics). The patch exposes
# `pynndescent.distance_count()` and `pynndescent.reset_distance_count()`.
pynndescent = pyprev.pynndescent.overridePythonAttrs (old: {
patches = (old.patches or []) ++ [./pynndescent-count-distances.patch];
doCheck = false;
});
};
};
fast-hdbscan = import ./nix/fast-hdbscan.nix {
inherit python;
patch = ./fast-hdbscan-exact-mst.patch;
};
densired = import ./nix/densired.nix {inherit python;};
hssl = import ./nix/hssl.nix {inherit pkgs python;};
mlpack = import ./nix/mlpack.nix {inherit pkgs;};
pymlpack = import ./nix/pymlpack.nix {inherit pkgs python;};
ensmallen = import ./nix/ensmallen.nix {inherit pkgs;};
tree-similarity = import ./nix/tree-similarity.nix {inherit pkgs;};
panna-python = python.pkgs.buildPythonPackage {
pname = "panna";
version = "0.0.1";
pyproject = true;
# Only the files the wheel build actually reads: everything else in
# CMakeLists.txt sits behind `if (NOT SKBUILD)`. Keeping `results/`
# (20MB, churns constantly) out of the source means editing scripts
# or committing experiment output no longer triggers a full rebuild.
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./CMakeLists.txt
./pyproject.toml
./README.md
./include
./external
./python
];
};
GIT_COMMIT_HASH = self.rev or "dirty";
# as stated here, one should disable the cmake setup:
# https://discourse.nixos.org/t/building-python-package-with-scikit-build-core-and-cmake-dependencies-die-python/69665/2
dontUseCmakeConfigure = true;
dontUseCmakeBuild = true;
dontUseCmakeInstall = true;
build-system = with python.pkgs; [
scikit-build-core
nanobind
];
dependencies = with python.pkgs; [
numpy
h5py
];
buildInputs = with pkgs; [
python.pkgs.build
catch2_3
cereal
hdf5
highfive
];
nativeBuildInputs = with pkgs; [
cmake
git
ninja
nanobench
];
};
# the Python interpreter with all the packages we need
python-interpreter =
python.withPackages
(ppkgs:
with ppkgs; [
numpy
pandas
polars
pyarrow
h5py
tqdm
requests
panna-python
fast-hdbscan
densired
hssl
icecream
sigmod-hdbscan.packages.${system}.default
scikit-learn
scipy
matplotlib
certifi
filelock
pymlpack
]);
container = pkgs.singularity-tools.buildImage {
name = "panna";
runScript = "#!${pkgs.stdenv.shell}\npython $@";
contents = [
python-interpreter
pkgs.cacert
pkgs.coreutils-full
];
diskSize = 1024 * 10; # necessary to fit the packages, otherwise the build fails
};
in {
packages.default = panna-python;
packages.container = container;
packages.python = python-interpreter;
devShells.default = (pkgs.mkShell.override {stdenv = pkgs.clangStdenv;}) {
venvDir = ".venv";
packages = with pkgs; [
gcc
lldb
clang-tools
python.pkgs.venvShellHook
(
python.withPackages
(ps:
with ps; [
build
marimo
numpy
pandas
polars
pyarrow
matplotlib
seaborn
filelock
umap-learn
h5py
nanobind
icecream
great-tables
scikit-build-core
certifi
sigmod-hdbscan.packages.${system}.default
])
)
hdf5
sqlite-interactive
cmake
just
bear # To generate compile_commands.json files
llvmPackages.openmp
llvmPackages.libcxx
rr
gdbgui
valgrind
highfive
samply
boost
cereal
catch2_3
fast-hdbscan
densired
hssl
ensmallen
mlpack
armadillo
hl-bin
tree-similarity
nanobench
];
NIX_ENFORCE_NO_NATIVE = false;
};
}
);
}