about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pydantic/1.nix
blob: 2b268d2bf543f5dd2c343f2637d97342349487bd (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
  lib,
  buildPythonPackage,
  cython_0,
  email-validator,
  fetchFromGitHub,
  pytest-mock,
  pytest7CheckHook,
  python-dotenv,
  pythonAtLeast,
  pythonOlder,
  setuptools,
  typing-extensions,
  libxcrypt,
}:

buildPythonPackage rec {
  pname = "pydantic";
  version = "1.10.16";
  pyproject = true;

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "pydantic";
    repo = "pydantic";
    rev = "refs/tags/v${version}";
    hash = "sha256-dn/ZsxbkyK2sJxpo6IsoMBRjq1STdu+xuqHXoNG+Kzk=";
  };

  nativeBuildInputs = [
    setuptools
    cython_0
  ];

  buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];

  propagatedBuildInputs = [ typing-extensions ];

  passthru.optional-dependencies = {
    dotenv = [ python-dotenv ];
    email = [ email-validator ];
  };

  nativeCheckInputs = [
    pytest-mock
    pytest7CheckHook
  ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);

  pytestFlagsArray = [
    # https://github.com/pydantic/pydantic/issues/4817
    "-W"
    "ignore::pytest.PytestReturnNotNoneWarning"
  ];

  preCheck = ''
    export HOME=$(mktemp -d)
  '';

  disabledTests = lib.optionals (pythonAtLeast "3.12") [
    # depends on distuils
    "test_cython_function_untouched"
    # AssertionError on exact types and wording
    "test_model_subclassing_abstract_base_classes_without_implementation_raises_exception"
    "test_partial_specification_name"
    "test_secretfield"
  ];

  enableParallelBuilding = true;

  pythonImportsCheck = [ "pydantic" ];

  meta = with lib; {
    description = "Data validation and settings management using Python type hinting";
    homepage = "https://github.com/pydantic/pydantic";
    changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md";
    license = licenses.mit;
    maintainers = with maintainers; [ wd15 ];
  };
}