-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathflake.nix
More file actions
157 lines (145 loc) · 4.44 KB
/
Copy pathflake.nix
File metadata and controls
157 lines (145 loc) · 4.44 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
{
description = "OpenMed reproducible package and development shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
outputs =
{ self, nixpkgs }:
let
supportedSystems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
packages = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312;
version = builtins.elemAt (
builtins.match
''.*__version__ = "([^"]+)".*''
(builtins.replaceStrings [ "\n" ] [ " " ] (builtins.readFile ./openmed/__about__.py))
) 0;
in
rec {
openmed = python.pkgs.buildPythonPackage {
pname = "openmed";
inherit version;
pyproject = true;
src = self;
build-system = [ python.pkgs.hatchling ];
dependencies = with python.pkgs; [
faker
jieba
pysbd
pyyaml
];
# The full suite runs in the development shell in nix.yml. Keeping
# package checks import-only avoids pulling development tools into
# the runtime closure.
doCheck = false;
pythonImportsCheck = [ "openmed" ];
meta = {
description = "Local-first clinical NLP and de-identification toolkit";
homepage = "https://github.com/maziyarpanahi/openmed";
license = pkgs.lib.licenses.asl20;
mainProgram = "openmed";
};
};
default = openmed;
}
);
devShells = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python312;
openmed = self.packages.${system}.openmed;
# The generated service stubs require grpcio >= 1.81.1. Keep the
# runtime and code generator paired until that patch release lands
# in the pinned nixpkgs branch.
grpcio = python.pkgs.grpcio.overridePythonAttrs (_: {
version = "1.81.1";
src = pkgs.fetchPypi {
pname = "grpcio";
version = "1.81.1";
hash = "sha256-b6EKdnFDpegujqq1ORivDNiQmleif4yyKIuAphOsZxs=";
};
});
grpcio-tools = python.pkgs.grpcio-tools.overridePythonAttrs (_: {
version = "1.81.1";
src = pkgs.fetchPypi {
pname = "grpcio_tools";
version = "1.81.1";
hash = "sha256-oio4cBgJJ/3YTisn0HnvW39fjGEQGBtnNq/BekY0gfE=";
};
dependencies = [
grpcio
python.pkgs.protobuf
python.pkgs.setuptools
];
});
devPythonPackages =
(with python.pkgs; [
brotli
cryptography
dask
duckdb
fastapi
fonttools
fsspec
huggingface-hub
httpx
hypothesis
jsonschema
mypy
numpy
opencc
opentelemetry-api
opentelemetry-exporter-otlp-proto-http
opentelemetry-sdk
pandas
pillow
pyarrow
polars
protobuf
pytest
pytest-cov
pytest-timeout
python-dateutil
rich
typer
])
++ [
grpcio
grpcio-tools
openmed
];
pythonPath = python.pkgs.makePythonPath devPythonPackages;
in
{
default = pkgs.mkShell {
packages =
[
python
pkgs.pre-commit
pkgs.ruff
]
++ devPythonPackages;
# Use the unwrapped interpreter so subprocess sandbox checks see
# the real standard-library prefix rather than a symlink farm.
shellHook = ''
export PYTHONPATH="${pythonPath}''${PYTHONPATH:+:}$PYTHONPATH"
'';
};
}
);
checks = forAllSystems (system: {
package = self.packages.${system}.openmed;
dev-shell = self.devShells.${system}.default;
});
};
}