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