1{ stdenv 2, lib 3, buildPythonPackage 4, fetchFromGitHub 5, cargo 6, rustPlatform 7, rustc 8, libiconv 9, typing-extensions 10, pytestCheckHook 11, hypothesis 12, pytest-timeout 13, pytest-mock 14, dirty-equals 15}: 16 17let 18 pydantic-core = buildPythonPackage rec { 19 pname = "pydantic-core"; 20 version = "2.6.3"; 21 format = "pyproject"; 22 23 src = fetchFromGitHub { 24 owner = "pydantic"; 25 repo = "pydantic-core"; 26 rev = "refs/tags/v${version}"; 27 hash = "sha256-bEVACTlzELXPoCtEHMR1s87KJn/qnE0lO1O4RmdjmPM="; 28 }; 29 30 patches = [ 31 ./01-remove-benchmark-flags.patch 32 ]; 33 34 cargoDeps = rustPlatform.fetchCargoTarball { 35 inherit src; 36 name = "${pname}-${version}"; 37 hash = "sha256-h9SmMLg/W11h/SQz8Te5OoCKdyG6Fctc5ftqbVQFSwU="; 38 }; 39 40 nativeBuildInputs = [ 41 cargo 42 rustPlatform.cargoSetupHook 43 rustPlatform.maturinBuildHook 44 rustc 45 typing-extensions 46 ]; 47 48 buildInputs = lib.optionals stdenv.isDarwin [ 49 libiconv 50 ]; 51 52 propagatedBuildInputs = [ 53 typing-extensions 54 ]; 55 56 pythonImportsCheck = [ "pydantic_core" ]; 57 58 # escape infinite recursion with pydantic via dirty-equals 59 doCheck = false; 60 passthru.tests.pytest = pydantic-core.overrideAttrs { doCheck = true; }; 61 62 nativeCheckInputs = [ 63 pytestCheckHook 64 hypothesis 65 pytest-timeout 66 dirty-equals 67 pytest-mock 68 ]; 69 70 disabledTests = [ 71 # RecursionError: maximum recursion depth exceeded while calling a Python object 72 "test_recursive" 73 ]; 74 75 disabledTestPaths = [ 76 # no point in benchmarking in nixpkgs build farm 77 "tests/benchmarks" 78 ]; 79 80 meta = with lib; { 81 description = "Core validation logic for pydantic written in rust"; 82 homepage = "https://github.com/pydantic/pydantic-core"; 83 license = licenses.mit; 84 maintainers = with maintainers; [ blaggacao ]; 85 }; 86 }; 87in pydantic-core