summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/kicad-python/default.nix
blob: b0c3eb382e73a0cb87716a155a229b3243527ee6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  lib,
  buildPythonPackage,
  fetchFromGitLab,
  poetry-core,
  protoletariat,
  mypy-protobuf,
  pkgs,
  protobuf,
  pynng,
  pytestCheckHook,
  gitMinimal,
  pythonOlder,
  typing-extensions,
}:
buildPythonPackage (finalAttrs: {
  pname = "kicad-python";
  version = "0.4.0";
  pyproject = true;

  src = fetchFromGitLab {
    owner = "kicad/code";
    repo = "kicad-python";
    tag = finalAttrs.version;
    hash = "sha256-M2vJ/lSwc1XjrG661ayNIOZKJitmy/UPM2SesQI1xYE=";
    fetchSubmodules = true;
  };

  build-system = [
    poetry-core
    protoletariat
  ];

  dependencies = [
    protobuf
    pynng
    mypy-protobuf
  ]
  ++ (lib.optional (pythonOlder "3.13") typing-extensions);

  nativeBuildInputs = [
    pkgs.protobuf
    mypy-protobuf
    gitMinimal
  ];

  pythonRelaxDeps = [ "protobuf" ];

  # fixes: FileExistsError: File already exists .../kipy/__init__.py
  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail 'script =' "#"
  '';

  preBuild = ''
    python build.py
  '';

  pythonImportsCheck = [ "kipy" ];

  nativeCheckInputs = [ pytestCheckHook ];

  meta = {
    description = "KiCad API Python Bindings";
    homepage = "https://kicad.org/";
    downloadPage = "https://gitlab.com/kicad/code/kicad-python";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ sigmanificient ];
  };
})