1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 hatchling,
9 hatch-fancy-pypi-readme,
10
11 # dependencies
12 annotated-types,
13 pydantic-core,
14 typing-extensions,
15 typing-inspection,
16
17 # tests
18 cloudpickle,
19 email-validator,
20 dirty-equals,
21 jsonschema,
22 pytestCheckHook,
23 pytest-codspeed,
24 pytest-mock,
25 pytest-run-parallel,
26 eval-type-backport,
27 rich,
28}:
29
30buildPythonPackage rec {
31 pname = "pydantic";
32 version = "2.11.7";
33 pyproject = true;
34
35 disabled = pythonOlder "3.8";
36
37 src = fetchFromGitHub {
38 owner = "pydantic";
39 repo = "pydantic";
40 tag = "v${version}";
41 hash = "sha256-5EQwbAqRExApJvVUJ1C6fsEC1/rEI6/bQEQkStqgf/Q=";
42 };
43
44 postPatch = ''
45 sed -i "/--benchmark/d" pyproject.toml
46 '';
47
48 build-system = [
49 hatch-fancy-pypi-readme
50 hatchling
51 ];
52
53 dependencies = [
54 annotated-types
55 pydantic-core
56 typing-extensions
57 typing-inspection
58 ];
59
60 optional-dependencies = {
61 email = [ email-validator ];
62 };
63
64 nativeCheckInputs = [
65 cloudpickle
66 dirty-equals
67 jsonschema
68 pytest-codspeed
69 pytest-mock
70 pytest-run-parallel
71 pytestCheckHook
72 rich
73 ]
74 ++ lib.flatten (lib.attrValues optional-dependencies)
75 ++ lib.optionals (pythonOlder "3.10") [ eval-type-backport ];
76
77 preCheck = ''
78 export HOME=$(mktemp -d)
79 '';
80
81 disabledTestPaths = [
82 "tests/benchmarks"
83
84 # avoid cyclic dependency
85 "tests/test_docs.py"
86 ];
87
88 pythonImportsCheck = [ "pydantic" ];
89
90 meta = with lib; {
91 description = "Data validation and settings management using Python type hinting";
92 homepage = "https://github.com/pydantic/pydantic";
93 changelog = "https://github.com/pydantic/pydantic/blob/${src.tag}/HISTORY.md";
94 license = licenses.mit;
95 maintainers = with maintainers; [ wd15 ];
96 };
97}