1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, jinja2
6, poetry-core
7, round
8, graphviz
9, inkscape
10, imagemagick
11, pytestCheckHook
12, typed-ast
13}:
14
15buildPythonPackage rec {
16 pname = "diagrams";
17 version = "0.23.3";
18 format = "pyproject";
19
20 disabled = pythonOlder "3.7";
21
22 src = fetchFromGitHub {
23 owner = "mingrammer";
24 repo = pname;
25 rev = "refs/tags/v${version}";
26 hash = "sha256-4b+jmR56y2VV0XxD6FCmNpDB0UKH9+FqcTQuU2jRCXo=";
27 };
28
29 postPatch = ''
30 substituteInPlace pyproject.toml \
31 --replace 'graphviz = ">=0.13.2,<0.20.0"' 'graphviz = "*"'
32 '';
33
34 preConfigure = ''
35 patchShebangs autogen.sh
36 ./autogen.sh
37 '';
38
39 patches = [
40 # The build-system section is missing
41 ./build_poetry.patch
42 ./remove-black-requirement.patch
43 ];
44
45 # Despite living in 'tool.poetry.dependencies',
46 # these are only used at build time to process the image resource files
47 nativeBuildInputs = [
48 inkscape imagemagick
49 jinja2
50 poetry-core
51 round
52 ];
53
54 propagatedBuildInputs = [
55 graphviz
56 typed-ast
57 ];
58
59 nativeCheckInputs = [
60 pytestCheckHook
61 ];
62
63 pythonImportsCheck = [
64 "diagrams"
65 ];
66
67 meta = with lib; {
68 description = "Diagram as Code";
69 homepage = "https://diagrams.mingrammer.com/";
70 changelog = "https://github.com/mingrammer/diagrams/releases/tag/v${version}";
71 license = licenses.mit;
72 maintainers = with maintainers; [ addict3d ];
73 };
74}