From bba180b8ecd20c07e03439bd3fce4fb88313ace1 Mon Sep 17 00:00:00 2001 From: squat Date: Fri, 17 Apr 2026 16:11:08 +0200 Subject: [PATCH] python3Packages.pydantic-monty: init at 0.0.13 This commit introduces a new Python package: [pydantic-monty](https://github.com/pydantic/monty), "a minimal, secure Python interpreter written in Rust for use by AI." It's an optional dependency of [fastmcp](https://github.com/PrefectHQ/fastmcp), which I'd like to add to the package. Signed-off-by: squat --- .../python-modules/pydantic-monty/default.nix | 77 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 79 insertions(+) create mode 100644 pkgs/development/python-modules/pydantic-monty/default.nix diff --git a/pkgs/development/python-modules/pydantic-monty/default.nix b/pkgs/development/python-modules/pydantic-monty/default.nix new file mode 100644 index 000000000000..35bbba47ee76 --- /dev/null +++ b/pkgs/development/python-modules/pydantic-monty/default.nix @@ -0,0 +1,77 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + pytestCheckHook, + rustPlatform, + + anyio, + dirty-equals, + inline-snapshot, + pytest-examples, + pytest-pretty, + typing-extensions, +}: + +buildPythonPackage (finalAttrs: { + pname = "pydantic-monty"; + version = "0.0.13"; + pyproject = true; + + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "pydantic"; + repo = "monty"; + tag = "v${finalAttrs.version}"; + hash = "sha256-0g0/NuwTuUfHVHE8YcVjUeZpSa+ANPWIXllu+qRXjZE="; + }; + + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (finalAttrs) pname src version; + hash = "sha256-LkTEMhz0MG6RfqejOQMdB2BZU6oxT3ZAo/N0oVlswsQ="; + }; + + dependencies = [ typing-extensions ]; + + nativeBuildInputs = [ + rustPlatform.cargoSetupHook + rustPlatform.maturinBuildHook + ]; + + maturinBuildFlags = [ + "-m" + "crates/monty-python/Cargo.toml" + ]; + + pytestFlags = [ + "--config-file" + "crates/monty-python/pyproject.toml" + ]; + + disabledTests = [ + # These tests fails because they expect to have multiple cores + # to produce a predicted speedup measurement, which we cannot + # achieve in the sandbox. + "test_parallel_exec" + ]; + + nativeCheckInputs = [ + anyio + dirty-equals + inline-snapshot + pytest-examples + pytest-pretty + pytestCheckHook + ]; + + pythonImportsCheck = [ "pydantic_monty" ]; + + meta = { + description = "Minimal, secure Python interpreter written in Rust for use by AI"; + homepage = "https://github.com/pydantic/monty"; + changelog = "https://github.com/pydantic/monty/releases/tag/${finalAttrs.src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ squat ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 19766c3d076b..f2819c9e039a 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -13580,6 +13580,8 @@ self: super: with self; { pydantic-graph = callPackage ../development/python-modules/pydantic-graph { }; + pydantic-monty = callPackage ../development/python-modules/pydantic-monty { }; + pydantic-scim = callPackage ../development/python-modules/pydantic-scim { }; pydantic-settings = callPackage ../development/python-modules/pydantic-settings { };