at master 3.1 kB view raw
1{ 2 stdenv, 3 lib, 4 rustPlatform, 5 callPackage, 6 fetchFromGitHub, 7 buildPythonPackage, 8 pythonAtLeast, 9 libiconv, 10 libffi, 11 libxml2, 12 llvm, 13 ncurses, 14 zlib, 15}: 16 17let 18 common = 19 { 20 pname, 21 buildAndTestSubdir, 22 cargoHash, 23 extraNativeBuildInputs ? [ ], 24 extraBuildInputs ? [ ], 25 }: 26 buildPythonPackage rec { 27 inherit pname; 28 version = "1.2.0"; 29 format = "pyproject"; 30 31 outputs = [ "out" ] ++ lib.optional (pname == "wasmer") "testsout"; 32 33 src = fetchFromGitHub { 34 owner = "wasmerio"; 35 repo = "wasmer-python"; 36 rev = version; 37 hash = "sha256-Iu28LMDNmtL2r7gJV5Vbb8HZj18dlkHe+mw/Y1L8YKE="; 38 }; 39 40 cargoDeps = rustPlatform.fetchCargoVendor { 41 inherit pname version src; 42 hash = cargoHash; 43 }; 44 45 nativeBuildInputs = 46 (with rustPlatform; [ 47 cargoSetupHook 48 maturinBuildHook 49 ]) 50 ++ extraNativeBuildInputs; 51 52 postPatch = '' 53 # Workaround for metadata, that maturin 0.14 does not accept in Cargo.toml anymore 54 substituteInPlace ${buildAndTestSubdir}/Cargo.toml \ 55 --replace "package.metadata.maturin" "broken" 56 ''; 57 58 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ] ++ extraBuildInputs; 59 60 inherit buildAndTestSubdir; 61 62 postInstall = lib.optionalString (pname == "wasmer") '' 63 mkdir $testsout 64 cp -R tests $testsout/tests 65 ''; 66 67 # check in passthru.tests.pytest because all packages are required to run the tests 68 doCheck = false; 69 70 passthru.tests = lib.optionalAttrs (pname == "wasmer") { pytest = callPackage ./tests.nix { }; }; 71 72 pythonImportsCheck = [ "${lib.replaceStrings [ "-" ] [ "_" ] pname}" ]; 73 74 meta = with lib; { 75 # https://github.com/wasmerio/wasmer-python/issues/778 76 broken = pythonAtLeast "3.12"; 77 description = "Python extension to run WebAssembly binaries"; 78 homepage = "https://github.com/wasmerio/wasmer-python"; 79 license = licenses.mit; 80 platforms = platforms.unix; 81 maintainers = [ ]; 82 }; 83 }; 84in 85{ 86 wasmer = common { 87 pname = "wasmer"; 88 buildAndTestSubdir = "packages/api"; 89 cargoHash = "sha256-oHyjzEqv88e2CHhWhKjUh6K0UflT9Y1JD//3oiE/UBQ="; 90 }; 91 92 wasmer-compiler-cranelift = common { 93 pname = "wasmer-compiler-cranelift"; 94 buildAndTestSubdir = "packages/compiler-cranelift"; 95 cargoHash = "sha256-oHyjzEqv88e2CHhWhKjUh6K0UflT9Y1JD//3oiE/UBQ="; 96 }; 97 98 wasmer-compiler-llvm = common { 99 pname = "wasmer-compiler-llvm"; 100 buildAndTestSubdir = "packages/compiler-llvm"; 101 cargoHash = "sha256-oHyjzEqv88e2CHhWhKjUh6K0UflT9Y1JD//3oiE/UBQ="; 102 extraNativeBuildInputs = [ llvm ]; 103 extraBuildInputs = [ 104 libffi 105 libxml2.out 106 ncurses 107 zlib 108 ]; 109 }; 110 111 wasmer-compiler-singlepass = common { 112 pname = "wasmer-compiler-singlepass"; 113 buildAndTestSubdir = "packages/compiler-singlepass"; 114 cargoHash = "sha256-oHyjzEqv88e2CHhWhKjUh6K0UflT9Y1JD//3oiE/UBQ="; 115 }; 116}