1{
2 lib,
3 buildPythonPackage,
4 runCommand,
5 fetchFromGitHub,
6 rustPlatform,
7 maturin,
8 protobuf_30,
9}:
10buildPythonPackage rec {
11 pname = "pyluwen";
12 version = "0.7.11";
13 pyproject = true;
14
15 src = fetchFromGitHub {
16 owner = "tenstorrent";
17 repo = "luwen";
18 tag = "v${version}";
19 hash = "sha256-eQpKEeuy0mVrmu8ssAOWBcXi7zutStu+RbZOEF/IJ98=";
20 };
21
22 cargoDeps = rustPlatform.fetchCargoVendor {
23 inherit src;
24 hash = "sha256-INzF8ORkrmPQMJbGSNm5QkfMOgE+HJ3taU1EZ9i+HJg=";
25 };
26
27 sourceRoot = "${src.name}/crates/${pname}";
28
29 prePatch = ''
30 chmod -R u+w ../../
31 cd ../../
32 '';
33
34 postPatch = ''
35 cd ../$sourceRoot
36 cp --no-preserve=ownership,mode ../../Cargo.lock .
37 sed -i '0,/version = /{s/version = "*.*.*"/version = "${version}"/g}' Cargo.toml
38 '';
39
40 nativeBuildInputs = with rustPlatform; [
41 cargoSetupHook
42 maturinBuildHook
43 protobuf_30
44 ];
45
46 build-system = [ maturin ];
47
48 meta = {
49 description = "Tenstorrent system interface library";
50 homepage = "https://github.com/tenstorrent/luwen";
51 maintainers = with lib.maintainers; [ RossComputerGuy ];
52 license = with lib.licenses; [ asl20 ];
53 };
54}