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-GmzcxS5LhB0j5Qovoo4Bbm2fYdbqkYjUVV6hibBAoPY=";
21 "311-x86_64-linux" = "sha256-NzVYuAPYwsV/xhOxEAeuWBOfGaPN3UQ6DeXXtTIeWWE=";
22 "312-x86_64-linux" = "sha256-ztVDC836f8s6a9xEczF2FYy4d7Nb3SM8rILiW0zJTpI=";
23 "313-x86_64-linux" = "sha256-UrVG8Hayw78hfGDwXeQSTMEZfOkvjoJufsc64yQHSlo=";
24 "310-aarch64-linux" = "sha256-lQQbVaLshtH2aQUS0Yg1gbGPL09Gw9l4lK6wrC22r38=";
25 "311-aarch64-linux" = "sha256-ZcOhoqNaG1N0A/NkA9JYyqtHflZLwPZBCblBzHe08gM=";
26 "312-aarch64-linux" = "sha256-h6l6NLBHXdx9KvxA5d1/jRJSKqge37zMs5Yoz1kUVNU=";
27 "313-aarch64-linux" = "sha256-YnbiebRetdm5XE3z55ViVfQU/UsSjS3hbYrs3obDY1c";
28 "310-aarch64-darwin" = "sha256-uWG7u3ocakjkwUBqmMrr60AEYeLnWgi23wwBMpQDehU=";
29 "311-aarch64-darwin" = "sha256-9A5zvNwzPfs/f+D88CO8vsQVM8mFZldxj/duzhoZAuA=";
30 "312-aarch64-darwin" = "sha256-06JP62GV8cIiFillwBB8n/VtMizKI+GfDmZjb264DxQ=";
31 "313-aarch64-darwin" = "sha256-3ohD+zRiiZ3nvN7qzLkjA6nWEAa8NjZN60qI30YyC6Q=";
32 };
33in
34buildPythonPackage rec {
35 pname = "tensorstore";
36 version = "0.1.71";
37 format = "wheel";
38
39 # The source build involves some wonky Bazel stuff.
40 src = fetchPypi {
41 inherit pname version;
42 format = "wheel";
43 python = "cp${pythonVersionNoDot}";
44 abi = "cp${pythonVersionNoDot}";
45 dist = "cp${pythonVersionNoDot}";
46 platform = systemToPlatform.${stdenv.system} or (throw "unsupported system");
47 hash =
48 hashes."${pythonVersionNoDot}-${stdenv.system}"
49 or (throw "unsupported system/python version combination");
50 };
51
52 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
53
54 dependencies = [
55 ml-dtypes
56 numpy
57 ];
58
59 pythonImportsCheck = [ "tensorstore" ];
60
61 meta = {
62 description = "Library for reading and writing large multi-dimensional arrays";
63 homepage = "https://google.github.io/tensorstore";
64 changelog = "https://github.com/google/tensorstore/releases/tag/v${version}";
65 license = lib.licenses.asl20;
66 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
67 maintainers = with lib.maintainers; [ samuela ];
68 };
69}