summary refs log tree commit diff
path: root/pkgs/development/python-modules/dataclasses-serialization/default.nix
blob: a52135ddaf6fe78fb06062ca91c1e4e8a81885f6 (plain) (blame)
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
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, more-properties
, typing-inspect
, toolz
, toposort
, bson
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "dataclasses-serialization";
  version = "1.3.1";

  # upstream requires >= 3.6 but only 3.7 includes dataclasses
  disabled = pythonOlder "3.7";

  format = "setuptools";

  src = fetchFromGitHub {
    owner = "madman-bob";
    repo = "python-dataclasses-serialization";
    rev = version;
    hash = "sha256-jLMR2D01KgzHHRP0zduMBJt8xgBmIquWLCjZYLo2/AA=";
  };

  postPatch = ''
    mv pypi_upload/setup.py .
    substituteInPlace setup.py \
      --replace "project_root = Path(__file__).parents[1]" "project_root = Path(__file__).parents[0]"

    # dataclasses is included in Python 3.7
    substituteInPlace requirements.txt \
      --replace dataclasses ""

    # https://github.com/madman-bob/python-dataclasses-serialization/issues/16
    sed -i '/(\(Dict\|List\)/d' tests/test_json.py tests/test_bson.py
  '';

  propagatedBuildInputs = [
    more-properties
    typing-inspect
    toolz
    toposort
  ];

  nativeCheckInputs = [
    bson
    pytestCheckHook
  ];

  pythonImportsCheck = [
    "dataclasses_serialization.bson"
    "dataclasses_serialization.json"
    "dataclasses_serialization.serializer_base"
  ];

  meta = {
    description = "Serialize/deserialize Python dataclasses to various other data formats";
    homepage = "https://github.com/madman-bob/python-dataclasses-serialization";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ dotlambda ];
  };
}