lol

python3Packages.wasmer*: package entire wasmer-compiler family

authored by

Sandro Jäckel and committed by
Martin Weinelt
20208cf5 5218e374

+109 -29
+82 -28
pkgs/development/python-modules/wasmer/default.nix
··· 1 - { lib 2 - , stdenv 1 + { stdenv 2 + , lib 3 3 , rustPlatform 4 + , callPackage 4 5 , fetchFromGitHub 5 6 , buildPythonPackage 6 7 , libiconv 8 + , llvm_11 9 + , libffi 10 + , libxml2 11 + , ncurses 12 + , zlib 7 13 }: 8 14 9 - buildPythonPackage rec { 10 - pname = "wasmer"; 11 - version = "1.0.0"; 15 + let 16 + common = 17 + { pname 18 + , buildAndTestSubdir 19 + , cargoHash 20 + , extraNativeBuildInputs ? [ ] 21 + , extraBuildInputs ? [ ] 22 + }: buildPythonPackage rec { 23 + inherit pname; 24 + version = "1.0.0"; 25 + format = "pyproject"; 12 26 13 - src = fetchFromGitHub { 14 - owner = "wasmerio"; 15 - repo = "wasmer-python"; 16 - rev = version; 17 - hash = "sha256-I1GfjLaPYMIHKh2m/5IQepUsJNiVUEJg49wyuuzUYtY="; 18 - }; 27 + outputs = [ "out" ] ++ lib.optional (pname == "wasmer") "testsout"; 19 28 20 - cargoDeps = rustPlatform.fetchCargoTarball { 21 - inherit src; 22 - name = "${pname}-${version}"; 23 - hash = "sha256-txOOia1C4W+nsXuXp4EytEn82CFfSmiOYwRLC4WPImc="; 24 - }; 29 + src = fetchFromGitHub { 30 + owner = "wasmerio"; 31 + repo = "wasmer-python"; 32 + rev = version; 33 + hash = "sha256-I1GfjLaPYMIHKh2m/5IQepUsJNiVUEJg49wyuuzUYtY="; 34 + }; 25 35 26 - format = "pyproject"; 36 + cargoDeps = rustPlatform.fetchCargoTarball { 37 + inherit src; 38 + name = "${pname}-${version}"; 39 + sha256 = cargoHash; 40 + }; 27 41 28 - nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ]; 42 + nativeBuildInputs = (with rustPlatform; [ cargoSetupHook maturinBuildHook ]) 43 + ++ extraNativeBuildInputs; 29 44 30 - buildInputs = lib.optionals stdenv.isDarwin [ libiconv ]; 45 + buildInputs = lib.optionals stdenv.isDarwin [ libiconv ] 46 + ++ extraBuildInputs; 31 47 32 - buildAndTestSubdir = "packages/api"; 48 + inherit buildAndTestSubdir; 33 49 34 - doCheck = false; 50 + postInstall = lib.optionalString (pname == "wasmer") '' 51 + mkdir $testsout 52 + cp -R tests $testsout/tests 53 + ''; 54 + 55 + # check in passthru.tests.pytest because all packages are required to run the tests 56 + doCheck = false; 57 + 58 + passthru.tests = lib.optionalAttrs (pname == "wasmer") { 59 + pytest = callPackage ./tests.nix { }; 60 + }; 61 + 62 + pythonImportsCheck = [ "${lib.replaceStrings ["-"] ["_"] pname}" ]; 63 + 64 + meta = with lib; { 65 + description = "Python extension to run WebAssembly binaries"; 66 + homepage = "https://github.com/wasmerio/wasmer-python"; 67 + license = licenses.mit; 68 + platforms = platforms.unix; 69 + maintainers = with maintainers; [ SuperSandro2000 ]; 70 + }; 71 + }; 72 + in 73 + rec { 74 + wasmer = common { 75 + pname = "wasmer"; 76 + buildAndTestSubdir = "packages/api"; 77 + cargoHash = "sha256-txOOia1C4W+nsXuXp4EytEn82CFfSmiOYwRLC4WPImc="; 78 + }; 35 79 36 - pythonImportsCheck = [ "wasmer" ]; 80 + wasmer-compiler-cranelift = common { 81 + pname = "wasmer-compiler-cranelift"; 82 + buildAndTestSubdir = "packages/compiler-cranelift"; 83 + cargoHash = "sha256-cHgAUwqnbQV3E5nUYGYQ48ntbIFfq4JXfU5IrSFZ3zI="; 84 + }; 85 + 86 + wasmer-compiler-llvm = common { 87 + pname = "wasmer-compiler-llvm"; 88 + buildAndTestSubdir = "packages/compiler-llvm"; 89 + cargoHash = "sha256-Jm22CC5S3pN/vdVvsGZdvtoAgPzWVLto8wavSJdxY3A="; 90 + extraNativeBuildInputs = [ llvm_11 ]; 91 + extraBuildInputs = [ libffi libxml2.out ncurses zlib ]; 92 + }; 37 93 38 - meta = with lib; { 39 - description = "Python extension to run WebAssembly binaries"; 40 - homepage = "https://github.com/wasmerio/wasmer-python"; 41 - license = licenses.mit; 42 - platforms = platforms.unix; 43 - maintainers = with maintainers; [ SuperSandro2000 ]; 94 + wasmer-compiler-singlepass = common { 95 + pname = "wasmer-compiler-singlepass"; 96 + buildAndTestSubdir = "packages/compiler-singlepass"; 97 + cargoHash = "sha256-lmqEo3+jYoN+4EEYphcoE4b84jdFcvYVycjrJ956Bh8="; 44 98 }; 45 99 }
+25
pkgs/development/python-modules/wasmer/tests.nix
··· 1 + { buildPythonPackage 2 + , wasmer 3 + , pytestCheckHook 4 + , wasmer-compiler-cranelift 5 + , wasmer-compiler-llvm 6 + , wasmer-compiler-singlepass 7 + }: 8 + 9 + buildPythonPackage rec { 10 + pname = "wasmer-tests"; 11 + inherit (wasmer) version; 12 + 13 + src = wasmer.testsout; 14 + 15 + dontBuild = true; 16 + dontInstall = true; 17 + 18 + checkInputs = [ 19 + pytestCheckHook 20 + wasmer 21 + wasmer-compiler-cranelift 22 + wasmer-compiler-llvm 23 + wasmer-compiler-singlepass 24 + ]; 25 + }
+2 -1
pkgs/top-level/python-packages.nix
··· 9319 9319 9320 9320 wasm = callPackage ../development/python-modules/wasm { }; 9321 9321 9322 - wasmer = callPackage ../development/python-modules/wasmer { }; 9322 + wasmerPackages = pkgs.recurseIntoAttrs (callPackage ../development/python-modules/wasmer { }); 9323 + inherit (self.wasmerPackages) wasmer wasmer-compiler-cranelift wasmer-compiler-llvm wasmer-compiler-singlepass; 9323 9324 9324 9325 watchdog = callPackage ../development/python-modules/watchdog { 9325 9326 inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices;