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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
{
lib,
stdenv,
buildPythonPackage,
python,
pythonAtLeast,
pythonOlder,
arrow-cpp,
cffi,
cloudpickle,
cmake,
cython_0,
fsspec,
hypothesis,
numpy,
pandas,
pytestCheckHook,
pytest-lazy-fixture,
pkg-config,
setuptools,
setuptools-scm,
oldest-supported-numpy,
}:
let
zero_or_one = cond: if cond then 1 else 0;
in
buildPythonPackage rec {
pname = "pyarrow";
inherit (arrow-cpp) version src;
pyproject = true;
disabled = pythonOlder "3.7";
sourceRoot = "${src.name}/python";
nativeBuildInputs = [
cmake
cython_0
pkg-config
setuptools
setuptools-scm
oldest-supported-numpy
];
buildInputs = [ arrow-cpp ];
propagatedBuildInputs = [
cffi
numpy
];
checkInputs = [
cloudpickle
fsspec
];
nativeCheckInputs = [
hypothesis
pandas
pytestCheckHook
pytest-lazy-fixture
];
PYARROW_BUILD_TYPE = "release";
PYARROW_WITH_DATASET = zero_or_one true;
PYARROW_WITH_FLIGHT = zero_or_one arrow-cpp.enableFlight;
PYARROW_WITH_HDFS = zero_or_one true;
PYARROW_WITH_PARQUET = zero_or_one true;
PYARROW_WITH_PARQUET_ENCRYPTION = zero_or_one true;
PYARROW_WITH_S3 = zero_or_one arrow-cpp.enableS3;
PYARROW_WITH_GCS = zero_or_one arrow-cpp.enableGcs;
PYARROW_BUNDLE_ARROW_CPP_HEADERS = zero_or_one false;
PYARROW_CMAKE_OPTIONS = [ "-DCMAKE_INSTALL_RPATH=${ARROW_HOME}/lib" ];
ARROW_HOME = arrow-cpp;
PARQUET_HOME = arrow-cpp;
ARROW_TEST_DATA = lib.optionalString doCheck arrow-cpp.ARROW_TEST_DATA;
doCheck = true;
dontUseCmakeConfigure = true;
__darwinAllowLocalNetworking = true;
preBuild = ''
export PYARROW_PARALLEL=$NIX_BUILD_CORES
'';
postInstall = ''
# copy the pyarrow C++ header files to the appropriate location
pyarrow_include="$out/${python.sitePackages}/pyarrow/include"
mkdir -p "$pyarrow_include/arrow/python"
find "$PWD/pyarrow/src/arrow" -type f -name '*.h' -exec cp {} "$pyarrow_include/arrow/python" \;
'';
pytestFlagsArray =
[
# A couple of tests are missing fixture imports, luckily pytest offers a
# clean solution.
"--fixtures pyarrow/tests/conftest.py"
# Deselect a single test because pyarrow prints a 2-line error message where
# only a single line is expected. The additional line of output comes from
# the glog library which is an optional dependency of arrow-cpp that is
# enabled in nixpkgs.
# Upstream Issue: https://issues.apache.org/jira/browse/ARROW-11393
"--deselect=pyarrow/tests/test_memory.py::test_env_var"
# these tests require access to s3 via the internet
"--deselect=pyarrow/tests/test_fs.py::test_resolve_s3_region"
"--deselect=pyarrow/tests/test_fs.py::test_s3_real_aws"
"--deselect=pyarrow/tests/test_fs.py::test_s3_real_aws_region_selection"
"--deselect=pyarrow/tests/test_fs.py::test_s3_options"
# Flaky test
"--deselect=pyarrow/tests/test_flight.py::test_roundtrip_errors"
"--deselect=pyarrow/tests/test_pandas.py::test_threaded_pandas_import"
# Flaky test, works locally but not on Hydra
"--deselect=pyarrow/tests/test_csv.py::TestThreadedCSVTableRead::test_cancellation"
# expects arrow-cpp headers to be bundled
"--deselect=pyarrow/tests/test_cpp_internals.py::test_pyarrow_include"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# Requires loopback networking
"--deselect=pyarrow/tests/test_ipc.py::test_socket_"
"--deselect=pyarrow/tests/test_flight.py::test_never_sends_data"
"--deselect=pyarrow/tests/test_flight.py::test_large_descriptor"
"--deselect=pyarrow/tests/test_flight.py::test_large_metadata_client"
"--deselect=pyarrow/tests/test_flight.py::test_none_action_side_effect"
# fails to compile
"--deselect=pyarrow/tests/test_cython.py::test_cython_api"
]
++ lib.optionals (pythonAtLeast "3.11") [
# Repr output is printing number instead of enum name so these tests fail
"--deselect=pyarrow/tests/test_fs.py::test_get_file_info"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
# this test requires local networking
"--deselect=pyarrow/tests/test_fs.py::test_filesystem_from_uri_gcs"
];
disabledTests = [ "GcsFileSystem" ];
dontUseSetuptoolsCheck = true;
preCheck =
''
shopt -s extglob
rm -r pyarrow/!(conftest.py|tests)
mv pyarrow/conftest.py pyarrow/tests/parent_conftest.py
substituteInPlace pyarrow/tests/conftest.py --replace ..conftest .parent_conftest
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# OSError: [Errno 24] Too many open files
ulimit -n 1024
'';
pythonImportsCheck =
[ "pyarrow" ]
++ map (module: "pyarrow.${module}") [
"compute"
"csv"
"dataset"
"feather"
"flight"
"fs"
"json"
"parquet"
];
meta = with lib; {
description = "Cross-language development platform for in-memory data";
homepage = "https://arrow.apache.org/";
license = licenses.asl20;
platforms = platforms.unix;
maintainers = with maintainers; [
veprbl
cpcloud
];
};
}
|