1{
2 autoPatchelfHook,
3 buildPythonPackage,
4 fetchPypi,
5 lib,
6 ml-dtypes,
7 numpy,
8 python,
9 stdenv,
10}:
11
12let
13 pythonVersionNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
14 systemToPlatform = {
15 "aarch64-linux" = "manylinux_2_17_aarch64.manylinux2014_aarch64";
16 "x86_64-linux" = "manylinux_2_17_x86_64.manylinux2014_x86_64";
17 "aarch64-darwin" = "macosx_11_0_arm64";
18 };
19 hashes = {
20 "310-x86_64-linux" = "sha256-oB68FjYzmRARWpbajQuLpAzWwg9CCji4tLZRFCsztjk=";
21 "311-x86_64-linux" = "sha256-kGEecBu7b3TFGUIRirI9q2W3nipiQwsh/1OB92RqDB4=";
22 "312-x86_64-linux" = "sha256-Vw8sT5kahSN20BQs3MOYesSUZqk4CuvfZR1z5nAO7g8=";
23 "310-aarch64-linux" = "sha256-Ocfg3VArM/14a06cpMuJDYP/MIo9rCvtFO4Cd3AahA4=";
24 "311-aarch64-linux" = "sha256-hegFeV3m0jpjTXNU6ue/3kGe1Cy+Pfeh4GDe96dvL7o=";
25 "312-aarch64-linux" = "sha256-O0VVtSqSEd4dqjmaXMTRvf/Bcc9YR7zzbz9N/8GVcXk=";
26 "310-aarch64-darwin" = "sha256-2vuVxmJMx/GeaHgzUS6rRdysQFHreVzZ5IT5YSDUJro=";
27 "311-aarch64-darwin" = "sha256-0xRVDSDE9upz2yU7mzpa3Y6l6M5FWOMAPKWBC8eY3Eo=";
28 "312-aarch64-darwin" = "sha256-i2TmLOl2aHD5iyzF6YpjbHKFmBGPx5ixPYyNKKQfRNM=";
29 };
30in
31buildPythonPackage rec {
32 pname = "tensorstore";
33 version = "0.1.65";
34 format = "wheel";
35
36 # The source build involves some wonky Bazel stuff.
37 src = fetchPypi {
38 inherit pname version;
39 format = "wheel";
40 python = "cp${pythonVersionNoDot}";
41 abi = "cp${pythonVersionNoDot}";
42 dist = "cp${pythonVersionNoDot}";
43 platform = systemToPlatform.${stdenv.system} or (throw "unsupported system");
44 hash =
45 hashes."${pythonVersionNoDot}-${stdenv.system}"
46 or (throw "unsupported system/python version combination");
47 };
48
49 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
50
51 dependencies = [
52 ml-dtypes
53 numpy
54 ];
55
56 pythonImportsCheck = [ "tensorstore" ];
57
58 meta = {
59 description = "Library for reading and writing large multi-dimensional arrays";
60 homepage = "https://google.github.io/tensorstore";
61 changelog = "https://github.com/google/tensorstore/releases/tag/v${version}";
62 license = lib.licenses.asl20;
63 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
64 maintainers = with lib.maintainers; [ samuela ];
65 };
66}