1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 hatchling,
9 hatch-fancy-pypi-readme,
10
11 # native dependencies
12 libxcrypt,
13
14 # dependencies
15 annotated-types,
16 pydantic-core,
17 typing-extensions,
18
19 # tests
20 cloudpickle,
21 email-validator,
22 dirty-equals,
23 jsonschema,
24 pytestCheckHook,
25 pytest-mock,
26 eval-type-backport,
27 rich,
28}:
29
30buildPythonPackage rec {
31 pname = "pydantic";
32 version = "2.9.2";
33 pyproject = true;
34
35 disabled = pythonOlder "3.8";
36
37 src = fetchFromGitHub {
38 owner = "pydantic";
39 repo = "pydantic";
40 rev = "refs/tags/v${version}";
41 hash = "sha256-Eb/9k9bNizRyGhjbW/LAE/2R0Ino4DIRDy5ZrQuzJ7o=";
42 };
43
44 buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
45
46 build-system = [
47 hatch-fancy-pypi-readme
48 hatchling
49 ];
50
51 dependencies = [
52 annotated-types
53 pydantic-core
54 typing-extensions
55 ];
56
57 optional-dependencies = {
58 email = [ email-validator ];
59 };
60
61 nativeCheckInputs =
62 [
63 cloudpickle
64 dirty-equals
65 jsonschema
66 pytest-mock
67 pytestCheckHook
68 rich
69 ]
70 ++ lib.flatten (lib.attrValues optional-dependencies)
71 ++ lib.optionals (pythonOlder "3.10") [ eval-type-backport ];
72
73 preCheck = ''
74 export HOME=$(mktemp -d)
75 substituteInPlace pyproject.toml \
76 --replace-fail "'--benchmark-columns', 'min,mean,stddev,outliers,rounds,iterations'," "" \
77 --replace-fail "'--benchmark-group-by', 'group'," "" \
78 --replace-fail "'--benchmark-warmup', 'on'," "" \
79 --replace-fail "'--benchmark-disable'," ""
80 '';
81
82 pytestFlagsArray = [
83 # suppress warnings with pytest>=8
84 "-Wignore::pydantic.warnings.PydanticDeprecatedSince20"
85 "-Wignore::pydantic.json_schema.PydanticJsonSchemaWarning"
86 ];
87
88 disabledTests = [
89 # disable failing test with pytest>=8
90 "test_assert_raises_validation_error"
91 ];
92
93 disabledTestPaths = [
94 "tests/benchmarks"
95
96 # avoid cyclic dependency
97 "tests/test_docs.py"
98 ];
99
100 pythonImportsCheck = [ "pydantic" ];
101
102 meta = with lib; {
103 description = "Data validation and settings management using Python type hinting";
104 homepage = "https://github.com/pydantic/pydantic";
105 changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md";
106 license = licenses.mit;
107 maintainers = with maintainers; [ wd15 ];
108 };
109}