1{ lib
2, stdenv
3, buildPythonPackage
4, cython
5, fetchFromGitHub
6, libiconv
7, pandas
8, python
9, pythonOlder
10, readstat
11, zlib
12}:
13
14buildPythonPackage rec {
15 pname = "pyreadstat";
16 version = "1.1.9";
17 format = "setuptools";
18
19 disabled = pythonOlder "3.7";
20
21 src = fetchFromGitHub {
22 owner = "Roche";
23 repo = "pyreadstat";
24 rev = "v${version}";
25 hash = "sha256-OtvAvZTmcBTGfgp3Ddp9JJuZegr1o6c7rTMOuLwJSpk=";
26 };
27
28 nativeBuildInputs = [
29 cython
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 = "Python package to read SAS, SPSS and Stata files into pandas data frames using the readstat C library";
61 homepage = "https://github.com/Roche/pyreadstat";
62 license = licenses.asl20;
63 maintainers = with maintainers; [ swflint ];
64 };
65}