1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 fetchpatch, 6 pythonOlder, 7 8 # build-system 9 hatchling, 10 hatch-fancy-pypi-readme, 11 12 # native dependencies 13 libxcrypt, 14 15 # dependencies 16 annotated-types, 17 pydantic-core, 18 typing-extensions, 19 20 # tests 21 cloudpickle, 22 email-validator, 23 dirty-equals, 24 faker, 25 pytestCheckHook, 26 pytest-mock, 27 eval-type-backport, 28}: 29 30buildPythonPackage rec { 31 pname = "pydantic"; 32 version = "2.6.3"; 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-neTdG/IcXopCmevzFY5/XDlhPHmOb6dhyAnzaobmeG8="; 42 }; 43 44 patches = [ 45 (fetchpatch { 46 # https://github.com/pydantic/pydantic/pull/8678 47 name = "fix-pytest8-compatibility.patch"; 48 url = "https://github.com/pydantic/pydantic/commit/825a6920e177a3b65836c13c7f37d82b810ce482.patch"; 49 hash = "sha256-Dap5DtDzHw0jS/QUo5CRI9sLDJ719GRyC4ZNDWEdzus="; 50 }) 51 ]; 52 53 buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ]; 54 55 build-system = [ 56 hatch-fancy-pypi-readme 57 hatchling 58 ]; 59 60 dependencies = [ 61 annotated-types 62 pydantic-core 63 typing-extensions 64 ]; 65 66 passthru.optional-dependencies = { 67 email = [ email-validator ]; 68 }; 69 70 nativeCheckInputs = 71 [ 72 cloudpickle 73 dirty-equals 74 faker 75 pytest-mock 76 pytestCheckHook 77 ] 78 ++ lib.flatten (lib.attrValues passthru.optional-dependencies) 79 ++ lib.optionals (pythonOlder "3.10") [ eval-type-backport ]; 80 81 preCheck = '' 82 export HOME=$(mktemp -d) 83 substituteInPlace pyproject.toml \ 84 --replace "'--benchmark-columns', 'min,mean,stddev,outliers,rounds,iterations'," "" \ 85 --replace "'--benchmark-group-by', 'group'," "" \ 86 --replace "'--benchmark-warmup', 'on'," "" \ 87 --replace "'--benchmark-disable'," "" 88 ''; 89 90 pytestFlagsArray = [ 91 # suppress warnings with pytest>=8 92 "-Wignore::pydantic.warnings.PydanticDeprecatedSince20" 93 "-Wignore::pydantic.json_schema.PydanticJsonSchemaWarning" 94 ]; 95 96 disabledTests = [ 97 # disable failing test with pytest>=8 98 "test_assert_raises_validation_error" 99 ]; 100 101 disabledTestPaths = [ 102 "tests/benchmarks" 103 104 # avoid cyclic dependency 105 "tests/test_docs.py" 106 ]; 107 108 pythonImportsCheck = [ "pydantic" ]; 109 110 meta = with lib; { 111 description = "Data validation and settings management using Python type hinting"; 112 homepage = "https://github.com/pydantic/pydantic"; 113 changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md"; 114 license = licenses.mit; 115 maintainers = with maintainers; [ wd15 ]; 116 }; 117}