1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 pythonAtLeast,
7 python,
8 fetchPypi,
9 autoPatchelfHook,
10
11 # dependencies
12 click,
13 filelock,
14 jsonschema,
15 msgpack,
16 packaging,
17 protobuf,
18 pyyaml,
19 requests,
20 watchfiles,
21
22 # optional-dependencies
23 # cgraph
24 cupy,
25 # client
26 grpcio,
27 # data
28 fsspec,
29 numpy,
30 pandas,
31 pyarrow,
32 # default
33 aiohttp,
34 aiohttp-cors,
35 colorful,
36 opencensus,
37 prometheus-client,
38 pydantic,
39 py-spy,
40 smart-open,
41 virtualenv,
42 # observability
43 memray,
44 opentelemetry-api,
45 opentelemetry-sdk,
46 opentelemetry-exporter-otlp,
47 # rllib
48 dm-tree,
49 gymnasium,
50 lz4,
51 # ormsgpack,
52 scipy,
53 typer,
54 rich,
55 # serve
56 fastapi,
57 starlette,
58 uvicorn,
59 # serve-grpc
60 pyopenssl,
61 # tune
62 tensorboardx,
63}:
64
65let
66 pname = "ray";
67 version = "2.49.2";
68in
69buildPythonPackage rec {
70 inherit pname version;
71 format = "wheel";
72
73 disabled = pythonOlder "3.9" || pythonAtLeast "3.14";
74
75 src =
76 let
77 pyShortVersion = "cp${builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion}";
78 platforms = {
79 aarch64-darwin = "macosx_12_0_arm64";
80 aarch64-linux = "manylinux2014_aarch64";
81 x86_64-darwin = "macosx_12_0_x86_64";
82 x86_64-linux = "manylinux2014_x86_64";
83 };
84 # ./pkgs/development/python-modules/ray/prefetch.sh
85 # Results are in ./ray-hashes.nix
86 hashes = {
87 x86_64-linux = {
88 cp310 = "sha256-dFZodq979OSOpLmzt1s02wU9EGTMTUsWcNxM549olK8=";
89 cp311 = "sha256-VAd93jOMX/ujSaSrYbcjUqPDvmnqW08bQ22Y1AsxJ2M=";
90 cp312 = "sha256-LsqqUfWIzN2ithVjqL44Q79l36qoOiQFiKMH9Ou4JHE=";
91 cp313 = "sha256-t9ghTP+G3wRP7HJ+7qvMw7/JsCcdKNYbqSwJ8NEn0B0=";
92 };
93 aarch64-linux = {
94 cp310 = "sha256-6uB7P+1F9bBBqL+Xlc0m+tJGS+USbv1EfkSEkFoptnc=";
95 cp311 = "sha256-6tqd2JzNpkOjxsLLpwFrWYmEMtEm4Qs4/tUtdBZTZPQ=";
96 cp312 = "sha256-3Q2NhkHRQvr+bYPofTwZvVY30h40YI0/9prXHqPi9GI=";
97 cp313 = "sha256-tMeGlojFGOkC97Yojt7CNlq00opGQpHm0KcEDH0Btfc=";
98 };
99 x86_64-darwin = {
100 cp310 = "sha256-PkQb8qzX82jPRRMnUgZsXDuD2IzV+Fdi5wN3S7pPK20=";
101 cp311 = "sha256-ns6VehOYX3u/QHf0/wIEMU1+malB+V3/Kha0U9U3bcM=";
102 cp312 = "sha256-Z4TgduRBgiLvjuO2qL/rhn2Hl4A7Jbz8zjvzvFQUvvE=";
103 cp313 = "sha256-svTw/tk2+vaI6H/9zJNWwDRRPAAlmi8ahYnjRfz728A=";
104 };
105 aarch64-darwin = {
106 cp310 = "sha256-CL7EZ1drwDDYvQY4AE4bjgdViJKTSREpiKS9SShoTow=";
107 cp311 = "sha256-T7n5v2L9XJLSLaIM0qrLSt4fsjAzdl+pJ08KDFC8QvY=";
108 cp312 = "sha256-1tYS3lxjQbd2/HXt7uW2mLtK9+6Eov8wVSsyqebkp3I=";
109 cp313 = "sha256-Li/iD6kFYuc2MNqf95MtPtZQfnMpHE2b31ZlN66d7d8=";
110 };
111 };
112 in
113 fetchPypi {
114 inherit pname version format;
115 dist = pyShortVersion;
116 python = pyShortVersion;
117 abi = pyShortVersion;
118 platform = platforms.${stdenv.hostPlatform.system} or { };
119 sha256 = hashes.${stdenv.hostPlatform.system}.${pyShortVersion} or { };
120 };
121
122 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
123 autoPatchelfHook
124 ];
125
126 dependencies = [
127 click
128 filelock
129 jsonschema
130 msgpack
131 packaging
132 protobuf
133 pyyaml
134 requests
135 watchfiles
136 ];
137
138 optional-dependencies = lib.fix (self: {
139 adag = self.cgraph;
140 air = lib.unique (self.data ++ self.serve ++ self.tune ++ self.train);
141 all = lib.unique (
142 self.adag
143 ++ self.air
144 ++ self.cgraph
145 ++ self.client
146 ++ self.data
147 ++ self.default
148 ++ self.observability
149 ++ self.rllib
150 ++ self.serve
151 ++ self.train
152 ++ self.tune
153 );
154 cgraph = [
155 cupy
156 ];
157 client = [ grpcio ];
158 data = [
159 fsspec
160 numpy
161 pandas
162 pyarrow
163 ];
164 default = [
165 aiohttp
166 aiohttp-cors
167 colorful
168 grpcio
169 opencensus
170 prometheus-client
171 pydantic
172 py-spy
173 requests
174 smart-open
175 virtualenv
176 ];
177 observability = [
178 memray
179 opentelemetry-api
180 opentelemetry-sdk
181 opentelemetry-exporter-otlp
182 ];
183 rllib = [
184 dm-tree
185 gymnasium
186 lz4
187 # ormsgpack
188 pyyaml
189 scipy
190 typer
191 rich
192 ];
193 serve = lib.unique (
194 [
195 fastapi
196 requests
197 starlette
198 uvicorn
199 watchfiles
200 ]
201 ++ self.default
202 );
203 serve-grpc = lib.unique (
204 [
205 grpcio
206 pyopenssl
207 ]
208 ++ self.serve
209 );
210 train = self.tune;
211 tune = [
212 fsspec
213 pandas
214 pyarrow
215 requests
216 tensorboardx
217 ];
218 });
219
220 postInstall = ''
221 chmod +x $out/${python.sitePackages}/ray/core/src/ray/{gcs/gcs_server,raylet/raylet}
222 '';
223
224 pythonImportsCheck = [ "ray" ];
225
226 meta = {
227 description = "Unified framework for scaling AI and Python applications";
228 homepage = "https://github.com/ray-project/ray";
229 changelog = "https://github.com/ray-project/ray/releases/tag/ray-${version}";
230 license = lib.licenses.asl20;
231 maintainers = with lib.maintainers; [ billhuang ];
232 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
233 platforms = [
234 "aarch64-darwin"
235 "aarch64-linux"
236 "x86_64-darwin"
237 "x86_64-linux"
238 ];
239 };
240}