nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 cargo,
6 rustPlatform,
7 rustc,
8 typing-extensions,
9 pytestCheckHook,
10 hypothesis,
11 inline-snapshot,
12 pytest-benchmark,
13 pytest-run-parallel,
14 pytest-timeout,
15 pytest-mock,
16 dirty-equals,
17 pydantic,
18 typing-inspection,
19}:
20
21let
22 pydantic-core = buildPythonPackage rec {
23 pname = "pydantic-core";
24 version = "2.41.5";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "pydantic";
29 repo = "pydantic-core";
30 tag = "v${version}";
31 hash = "sha256-oIYHLSep8tWOXEaUybXG8Gv9WBoPGQ1Aj7QyqYksvMw=";
32 };
33
34 cargoDeps = rustPlatform.fetchCargoVendor {
35 inherit pname version src;
36 hash = "sha256-Kvc0a34C6oGc9oS/iaPaazoVUWn5ABUgrmPa/YocV+Y=";
37 };
38
39 nativeBuildInputs = [
40 cargo
41 rustPlatform.cargoSetupHook
42 rustPlatform.maturinBuildHook
43 rustc
44 ];
45
46 dependencies = [ typing-extensions ];
47
48 pythonImportsCheck = [ "pydantic_core" ];
49
50 # escape infinite recursion with pydantic via inline-snapshot
51 doCheck = false;
52 passthru.tests.pytest = pydantic-core.overridePythonAttrs { doCheck = true; };
53
54 nativeCheckInputs = [
55 pytestCheckHook
56 hypothesis
57 inline-snapshot
58 pytest-timeout
59 dirty-equals
60 pytest-benchmark
61 pytest-mock
62 pytest-run-parallel
63 typing-inspection
64 ];
65
66 meta = {
67 changelog = "https://github.com/pydantic/pydantic-core/releases/tag/${src.tag}";
68 description = "Core validation logic for pydantic written in rust";
69 homepage = "https://github.com/pydantic/pydantic-core";
70 license = lib.licenses.mit;
71 inherit (pydantic.meta) maintainers;
72 };
73 };
74in
75pydantic-core