1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cython,
6 fetchFromGitHub,
7 libiconv,
8 pandas,
9 python,
10 pythonOlder,
11 readstat,
12 zlib,
13}:
14
15buildPythonPackage rec {
16 pname = "pyreadstat";
17 version = "1.2.6";
18 format = "setuptools";
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "Roche";
24 repo = "pyreadstat";
25 rev = "refs/tags/v${version}";
26 hash = "sha256-VcPpGRrE/5udNijodO88Lw69JPOm6ZN7BZb4xD34srQ=";
27 };
28
29 nativeBuildInputs = [ cython ];
30
31 buildInputs = [ zlib ] ++ lib.optionals stdenv.isDarwin [ libiconv ];
32
33 propagatedBuildInputs = [
34 readstat
35 pandas
36 ];
37
38 pythonImportsCheck = [ "pyreadstat" ];
39
40 preCheck = ''
41 export HOME=$(mktemp -d);
42 '';
43
44 checkPhase = ''
45 runHook preCheck
46
47 ${python.interpreter} tests/test_basic.py
48
49 runHook postCheck
50 '';
51
52 meta = with lib; {
53 description = "Module to read SAS, SPSS and Stata files into pandas data frames";
54 homepage = "https://github.com/Roche/pyreadstat";
55 changelog = "https://github.com/Roche/pyreadstat/blob/v${version}/change_log.md";
56 license = licenses.asl20;
57 maintainers = with maintainers; [ swflint ];
58 };
59}