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