1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitLab,
5 poetry-core,
6 protoletariat,
7 mypy-protobuf,
8 pkgs,
9 protobuf,
10 pynng,
11 pytestCheckHook,
12 gitMinimal,
13 pythonOlder,
14 typing-extensions,
15}:
16buildPythonPackage rec {
17 pname = "kicad-python";
18 version = "0.4.0";
19 pyproject = true;
20
21 src = fetchFromGitLab {
22 owner = "kicad/code";
23 repo = "kicad-python";
24 tag = version;
25 hash = "sha256-M2vJ/lSwc1XjrG661ayNIOZKJitmy/UPM2SesQI1xYE=";
26 fetchSubmodules = true;
27 };
28
29 build-system = [
30 poetry-core
31 protoletariat
32 ];
33
34 dependencies = [
35 protobuf
36 pynng
37 mypy-protobuf
38 ]
39 ++ (lib.optional (pythonOlder "3.13") typing-extensions);
40
41 nativeBuildInputs = [
42 pkgs.protobuf
43 mypy-protobuf
44 gitMinimal
45 ];
46
47 pythonRelaxDeps = [ "protobuf" ];
48
49 # fixes: FileExistsError: File already exists .../kipy/__init__.py
50 postPatch = ''
51 substituteInPlace pyproject.toml \
52 --replace-fail 'script =' "#"
53 '';
54
55 preBuild = ''
56 python build.py
57 '';
58
59 pythonImportsCheck = [ "kipy" ];
60
61 nativeCheckInputs = [ pytestCheckHook ];
62
63 meta = {
64 description = "KiCad API Python Bindings";
65 homepage = "https://kicad.org/";
66 downloadPage = "https://gitlab.com/kicad/code/kicad-python";
67 license = lib.licenses.mit;
68 maintainers = with lib.maintainers; [ sigmanificient ];
69 };
70}