Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.7.4"; 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-S4FZUnOsKC8J0xyTeXhMmCACCma+VfCSmrE6sYAnpok="; 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 passthru.optional-dependencies = { 58 email = [ email-validator ]; 59 }; 60 61 nativeCheckInputs = 62 [ 63 cloudpickle 64 dirty-equals 65 faker 66 pytest-mock 67 pytestCheckHook 68 ] 69 ++ lib.flatten (lib.attrValues passthru.optional-dependencies) 70 ++ lib.optionals (pythonOlder "3.10") [ eval-type-backport ]; 71 72 preCheck = '' 73 export HOME=$(mktemp -d) 74 substituteInPlace pyproject.toml \ 75 --replace-fail "'--benchmark-columns', 'min,mean,stddev,outliers,rounds,iterations'," "" \ 76 --replace-fail "'--benchmark-group-by', 'group'," "" \ 77 --replace-fail "'--benchmark-warmup', 'on'," "" \ 78 --replace-fail "'--benchmark-disable'," "" 79 ''; 80 81 pytestFlagsArray = [ 82 # suppress warnings with pytest>=8 83 "-Wignore::pydantic.warnings.PydanticDeprecatedSince20" 84 "-Wignore::pydantic.json_schema.PydanticJsonSchemaWarning" 85 ]; 86 87 disabledTests = [ 88 # disable failing test with pytest>=8 89 "test_assert_raises_validation_error" 90 ]; 91 92 disabledTestPaths = [ 93 "tests/benchmarks" 94 95 # avoid cyclic dependency 96 "tests/test_docs.py" 97 ]; 98 99 pythonImportsCheck = [ "pydantic" ]; 100 101 meta = with lib; { 102 description = "Data validation and settings management using Python type hinting"; 103 homepage = "https://github.com/pydantic/pydantic"; 104 changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md"; 105 license = licenses.mit; 106 maintainers = with maintainers; [ wd15 ]; 107 }; 108}