summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/arro3/default.nix
blob: dcf3f038fdbbc79a88598da60d488e545af72541 (plain)
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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  rustPlatform,
  pytestCheckHook,
  geoarrow-types,
  pyarrow,
  numpy,
  pandas,
}:
let
  version = "0.5.1";

  src = fetchFromGitHub {
    owner = "kylebarron";
    repo = "arro3";
    tag = "py-v${version}";
    hash = "sha256-RTr+mf5slfxxvXp9cwPuy08AZUswPtIIRz+vngdg/k0=";
  };

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit version src;
    pname = "arro3-vendor";
    hash = "sha256-YQA8Z86Ul8yAHncMgYrGmNe10KSpubHjaokCjaqTAxo=";
  };

  commonMeta = {
    homepage = "https://github.com/kylebarron/arro3";
    changelog = "https://github.com/kylebarron/arro3/releases/tag/py-v${version}";
    license = lib.licenses.asl20;
    maintainers = [ lib.maintainers.mslingsby ];
  };

  buildArro3Package =
    {
      pname,
      subdir,
      description,
      pythonImportsCheck,
      dependencies ? [ ],
    }:
    buildPythonPackage rec {
      inherit
        pname
        version
        src
        cargoDeps
        dependencies
        pythonImportsCheck
        ;
      pyproject = true;

      sourceRoot = "${src.name}/${subdir}";
      cargoRoot = "..";

      nativeBuildInputs = with rustPlatform; [
        cargoSetupHook
        maturinBuildHook
      ];

      env = {
        CARGO_TARGET_DIR = "./target";
      };

      # Avoid infinite recursion in tests.
      # arro3-core tests depends on arro3-compute and arro3-compute depends on arro3-core
      passthru.tests = { inherit arro3-tests; };

      meta = commonMeta // {
        inherit description;
      };
    };

  arro3-core = buildArro3Package {
    pname = "arro3-core";
    subdir = "arro3-core";
    description = "Core library for representing Arrow data in Python";
    pythonImportsCheck = [ "arro3.core" ];
  };

  arro3-compute = buildArro3Package {
    pname = "arro3-compute";
    subdir = "arro3-compute";
    description = "Rust-based compute kernels for Arrow in Python";
    pythonImportsCheck = [ "arro3.compute" ];
    dependencies = [ arro3-core ];
  };

  arro3-io = buildArro3Package {
    pname = "arro3-io";
    subdir = "arro3-io";
    description = "Rust-based readers and writers for Arrow in Python";
    pythonImportsCheck = [ "arro3.io" ];
    dependencies = [ arro3-core ];
  };

  arro3-tests = buildPythonPackage {
    pname = "arro3-tests";
    version = arro3-core.version;

    pyproject = false;
    dontBuild = true;
    dontInstall = true;

    inherit src;

    nativeCheckInputs = [
      pytestCheckHook
      geoarrow-types
      pandas
      pyarrow
      numpy
      arro3-core
      arro3-compute
      arro3-io
    ];
  };
in
{
  inherit arro3-core arro3-io arro3-compute;
}