From 3d8eb0e6d1aa8c7e52012d73f69ddf0a02445698 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 4 May 2026 12:29:02 +0200 Subject: [PATCH] python3Packages.wasmtime: init at 44.0.0 Python WebAssembly runtime powered by Wasmtime https://github.com/bytecodealliance/wasmtime-py --- .../python-modules/wasmtime/default.nix | 83 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 85 insertions(+) create mode 100644 pkgs/development/python-modules/wasmtime/default.nix diff --git a/pkgs/development/python-modules/wasmtime/default.nix b/pkgs/development/python-modules/wasmtime/default.nix new file mode 100644 index 000000000000..0d6385e2d5ee --- /dev/null +++ b/pkgs/development/python-modules/wasmtime/default.nix @@ -0,0 +1,83 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + python, + pkgs, + pycparser, + pytest-mypy, + pytestCheckHook, + setuptools-git-versioning, + setuptools, + writableTmpDirAsHomeHook, +}: + +buildPythonPackage (finalAttrs: { + pname = "wasmtime"; + version = "44.0.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "bytecodealliance"; + repo = "wasmtime-py"; + tag = finalAttrs.version; + hash = "sha256-7K0j4jMsRB7/wNIj0pXxFTy0y7aN37wgCD1XKM92Ayw="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace-fail "setuptools-git-versioning>=2.0,<3" "setuptools-git-versioning" \ + --replace-fail 'build-backend = "backend"' 'build-backend = "setuptools.build_meta"' + + substituteInPlace ci/cbindgen.py \ + --replace-fail "'-D__builtin_va_list=int'," "'-D__builtin_va_list=int', '-Dnullptr_t=void*'," + + sed -i '/^backend-path = \[/,/^\]/d' pyproject.toml + + # Use nixpkgs' wasmtime instead of downloading prebuilt C API artifacts. + mkdir -p wasmtime/linux-x86_64 wasmtime/linux-aarch64 + ln -s ${lib.getLib pkgs.wasmtime}/lib/libwasmtime.so wasmtime/linux-x86_64/_libwasmtime.so + ln -s ${lib.getLib pkgs.wasmtime}/lib/libwasmtime.so wasmtime/linux-aarch64/_libwasmtime.so + ''; + + build-system = [ + setuptools + setuptools-git-versioning + ]; + + buildInputs = [ pkgs.wasmtime ]; + + postInstall = '' + # Ensure the installed module can find the shared library at runtime + mkdir -p "$out/${python.sitePackages}/wasmtime/linux-x86_64" + mkdir -p "$out/${python.sitePackages}/wasmtime/linux-aarch64" + ln -sf ${lib.getLib pkgs.wasmtime}/lib/libwasmtime.so "$out/${python.sitePackages}/wasmtime/linux-x86_64/_libwasmtime.so" + ln -sf ${lib.getLib pkgs.wasmtime}/lib/libwasmtime.so "$out/${python.sitePackages}/wasmtime/linux-aarch64/_libwasmtime.so" + ''; + + nativeCheckInputs = [ + pycparser + pytest-mypy + pytestCheckHook + writableTmpDirAsHomeHook + ]; + + disabledTestPaths = [ + "ci/cbindgen.py" + ]; + + pythonImportsCheck = [ "wasmtime" ]; + + preCheck = '' + # cbindgen.py checks bindings against C headers during test collection. + ln -s ${lib.getDev pkgs.wasmtime}/include wasmtime/include + ''; + + meta = { + description = "Python WebAssembly runtime powered by Wasmtime"; + homepage = "https://github.com/bytecodealliance/wasmtime-py"; + changelog = "https://github.com/bytecodealliance/wasmtime-py/releases/tag/{${finalAttrs.src.tag}}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ fab ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0f03e26a4ce5..626f12dc1151 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -21071,6 +21071,8 @@ self: super: with self; { wasmerPackages = lib.recurseIntoAttrs (callPackage ../development/python-modules/wasmer { }); + wasmtime = callPackage ../development/python-modules/wasmtime { }; + wasserstein = callPackage ../development/python-modules/wasserstein { }; wassima = callPackage ../development/python-modules/wassima { };