1{
2 lib,
3 buildPythonPackage,
4 cython_0,
5 email-validator,
6 fetchFromGitHub,
7 pytest-mock,
8 pytest7CheckHook,
9 python-dotenv,
10 pythonAtLeast,
11 pythonOlder,
12 setuptools,
13 typing-extensions,
14 libxcrypt,
15}:
16
17buildPythonPackage rec {
18 pname = "pydantic";
19 version = "1.10.16";
20 pyproject = true;
21
22 disabled = pythonOlder "3.7";
23
24 src = fetchFromGitHub {
25 owner = "pydantic";
26 repo = "pydantic";
27 rev = "refs/tags/v${version}";
28 hash = "sha256-dn/ZsxbkyK2sJxpo6IsoMBRjq1STdu+xuqHXoNG+Kzk=";
29 };
30
31 nativeBuildInputs = [
32 setuptools
33 cython_0
34 ];
35
36 buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ];
37
38 propagatedBuildInputs = [ typing-extensions ];
39
40 passthru.optional-dependencies = {
41 dotenv = [ python-dotenv ];
42 email = [ email-validator ];
43 };
44
45 nativeCheckInputs = [
46 pytest-mock
47 pytest7CheckHook
48 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
49
50 pytestFlagsArray = [
51 # https://github.com/pydantic/pydantic/issues/4817
52 "-W"
53 "ignore::pytest.PytestReturnNotNoneWarning"
54 ];
55
56 preCheck = ''
57 export HOME=$(mktemp -d)
58 '';
59
60 disabledTests = lib.optionals (pythonAtLeast "3.12") [
61 # depends on distuils
62 "test_cython_function_untouched"
63 # AssertionError on exact types and wording
64 "test_model_subclassing_abstract_base_classes_without_implementation_raises_exception"
65 "test_partial_specification_name"
66 "test_secretfield"
67 ];
68
69 enableParallelBuilding = true;
70
71 pythonImportsCheck = [ "pydantic" ];
72
73 meta = with lib; {
74 description = "Data validation and settings management using Python type hinting";
75 homepage = "https://github.com/pydantic/pydantic";
76 changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md";
77 license = licenses.mit;
78 maintainers = with maintainers; [ wd15 ];
79 };
80}