summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ezdxf/default.nix
blob: 1b3d99e467bef28242e58e20a6e0e2604075921b (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pyparsing,
  typing-extensions,
  pytestCheckHook,
  setuptools,
  cython,
  numpy,
  fonttools,
  pillow,
  pyside6,
  matplotlib,
  pymupdf,
  pyqt5,
  withGui ? false,
  qt6,
  librecad,
  gitUpdater,
}:

buildPythonPackage rec {
  version = "1.4.3";
  pname = "ezdxf";

  pyproject = true;

  src = fetchFromGitHub {
    owner = "mozman";
    repo = "ezdxf";
    tag = "v${version}";
    hash = "sha256-v/xW/Tg3OgzwvSNy3cfkxzf6R33ZvW4VE8k7MB+rM+w=";
  };

  nativeBuildInputs = lib.optionals withGui [ qt6.wrapQtAppsHook ];

  dependencies = [
    pyparsing
    typing-extensions
    numpy
    fonttools
  ]
  ++ lib.optionals withGui ([ qt6.qtbase ] ++ optional-dependencies.draw);

  optional-dependencies = {
    draw = [
      pyside6
      matplotlib
      pymupdf
      pillow
    ];
    draw5 = [
      pyqt5
      matplotlib
      pymupdf
      pillow
    ];
  };

  build-system = [
    setuptools
    cython
  ];

  dontWrapQtApps = true;

  preFixup = lib.optionalString withGui ''
    makeWrapperArgs+=("''${qtWrapperArgs[@]}")
  '';

  checkInputs = [ pillow ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [
    "ezdxf"
    "ezdxf.addons"
  ];

  preCheck = ''
    ln -s "${librecad}/${
      if stdenv.hostPlatform.isDarwin then
        "Applications/LibreCAD.app/Contents/Resources"
      else
        "share/librecad"
    }/fonts" fonts/librecad
  '';

  # The default updateScript of Python packages does not filter prerelease versions.
  passthru.updateScript = gitUpdater {
    rev-prefix = "v";
    allowedVersions = "^[0-9]+\\.[0-9]+\\.[0-9]+$";
  };

  meta = {
    description = "Python package to read and write DXF drawings (interface to the DXF file format)";
    mainProgram = "ezdxf";
    homepage = "https://ezdxf.mozman.at/";
    changelog = "https://github.com/mozman/ezdxf/blob/${src.rev}/notes/pages/CHANGELOG.md";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ hodapp ];
    platforms = lib.platforms.unix;
  };
}