about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/textx/default.nix
blob: e169cbdb9b81e0888521f75ea9a1f1cfd4b997c9 (plain) (blame)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
{ lib
, buildPythonPackage
, python
, fetchFromGitHub
, mkdocs
, twine
, arpeggio
, click
, future
, setuptools
, callPackage
, gprof2dot
, html5lib
, jinja2
, psutil
, pytestCheckHook
}:

let
  textx = buildPythonPackage rec {
    pname = "textx";
    version = "3.0.0";
    format = "setuptools";

    src = fetchFromGitHub {
      owner = pname;
      repo = pname;
      rev = version;
      hash = "sha256-uZlO82dKtWQQR5+Q7dWk3+ZoUzAjDJ8qzC4UMLCtnBk=";
    };

    postPatch = ''
      substituteInPlace setup.cfg --replace "click >=7.0, <8.0" "click >=7.0"
    '';

    outputs = [
      "out"
      "testout"
    ];

    nativeBuildInputs = [
      mkdocs
      twine
    ];

    propagatedBuildInputs = [
      arpeggio
      click
      future
      setuptools
    ];

    postInstall = ''
      # FileNotFoundError: [Errno 2] No such file or directory: '$out/lib/python3.10/site-packages/textx/textx.tx
      cp "$src/textx/textx.tx" "$out/${python.sitePackages}/${pname}/"

      # Install tests as the tests output.
      mkdir $testout
      cp -r tests $testout/tests
    '';

    pythonImportsCheck = [
      "textx"
    ];

    # Circular dependencies, do tests in passthru.tests instead.
    doCheck = false;

    passthru.tests = {
      textxTests = callPackage ./tests.nix {
        inherit
          textx-data-dsl
          textx-example-project
          textx-flow-codegen
          textx-flow-dsl
          textx-types-dsl;
       };
    };

    meta = with lib; {
      description = "Domain-specific languages and parsers in Python";
      homepage = "https://github.com/textx/textx/";
      license = licenses.mit;
      maintainers = with maintainers; [ yuu ];
    };
  };

  textx-data-dsl = buildPythonPackage rec {
    pname = "textx-data-dsl";
    version = "1.0.0";
    inherit (textx) src;
    # `format` isn't included in the output of `mk-python-derivation`.
    # So can't inherit format: `error: attribute 'format' missing`.
    format = "setuptools";
    pathToSourceRoot = "tests/functional/registration/projects/data_dsl";
    sourceRoot = "${src.name}/" + pathToSourceRoot;
    propagatedBuildInputs = [
      textx
      textx-types-dsl
    ];
    meta = with lib; {
      inherit (textx.meta) license maintainers;
      description = "Sample textX language for testing";
      homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
    };
  };

  textx-flow-codegen = buildPythonPackage rec {
    pname = "textx-flow-codegen";
    version = "1.0.0";
    inherit (textx) src;
    format = "setuptools";
    pathToSourceRoot = "tests/functional/registration/projects/flow_codegen";
    sourceRoot = "${src.name}/" + pathToSourceRoot;
    propagatedBuildInputs = [
      click
      textx
    ];
    meta = with lib; {
      inherit (textx.meta) license maintainers;
      description = "Sample textX language for testing";
      homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
    };
  };

  textx-flow-dsl = buildPythonPackage rec {
    pname = "textx-flow-dsl";
    version = "1.0.0";
    inherit (textx) src;
    format = "setuptools";
    pathToSourceRoot = "tests/functional/registration/projects/flow_dsl";
    sourceRoot = "${src.name}/" + pathToSourceRoot;
    propagatedBuildInputs = [
      textx
    ];
    meta = with lib; {
      inherit (textx.meta) license maintainers;
      description = "Sample textX language for testing";
      homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
    };
  };

  textx-types-dsl = buildPythonPackage rec {
    pname = "textx-types-dsl";
    version = "1.0.0";
    inherit (textx) src;
    format = "setuptools";
    pathToSourceRoot = "tests/functional/registration/projects/types_dsl";
    sourceRoot = "${src.name}/" + pathToSourceRoot;
    propagatedBuildInputs = [
      textx
    ];
    meta = with lib; {
      inherit (textx.meta) license maintainers;
      description = "Sample textX language for testing";
      homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
    };
  };

  textx-example-project = buildPythonPackage rec {
    pname = "textx-example-project";
    version = "1.0.0";
    inherit (textx) src;
    format = "setuptools";
    pathToSourceRoot = "tests/functional/subcommands/example_project";
    sourceRoot = "${src.name}/" + pathToSourceRoot;
    propagatedBuildInputs = [
      textx
    ];
    meta = with lib; {
      inherit (textx.meta) license maintainers;
      description = "Sample textX sub-command for testing";
      homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
    };
  };
in
  textx