1{ lib
2, buildPythonPackage
3, python
4, fetchFromGitHub
5, mkdocs
6, twine
7, arpeggio
8, click
9, future
10, setuptools
11, callPackage
12, gprof2dot
13, html5lib
14, jinja2
15, psutil
16, pytestCheckHook
17}:
18
19let
20 textx = buildPythonPackage rec {
21 pname = "textx";
22 version = "3.0.0";
23 format = "setuptools";
24
25 src = fetchFromGitHub {
26 owner = pname;
27 repo = pname;
28 rev = version;
29 hash = "sha256-uZlO82dKtWQQR5+Q7dWk3+ZoUzAjDJ8qzC4UMLCtnBk=";
30 };
31
32 postPatch = ''
33 substituteInPlace setup.cfg --replace "click >=7.0, <8.0" "click >=7.0"
34 '';
35
36 outputs = [
37 "out"
38 "testout"
39 ];
40
41 nativeBuildInputs = [
42 mkdocs
43 twine
44 ];
45
46 propagatedBuildInputs = [
47 arpeggio
48 click
49 future
50 setuptools
51 ];
52
53 postInstall = ''
54 # FileNotFoundError: [Errno 2] No such file or directory: '$out/lib/python3.10/site-packages/textx/textx.tx
55 cp "$src/textx/textx.tx" "$out/${python.sitePackages}/${pname}/"
56
57 # Install tests as the tests output.
58 mkdir $testout
59 cp -r tests $testout/tests
60 '';
61
62 pythonImportsCheck = [
63 "textx"
64 ];
65
66 # Circular dependencies, do tests in passthru.tests instead.
67 doCheck = false;
68
69 passthru.tests = {
70 textxTests = callPackage ./tests.nix {
71 inherit
72 textx-data-dsl
73 textx-example-project
74 textx-flow-codegen
75 textx-flow-dsl
76 textx-types-dsl;
77 };
78 };
79
80 meta = with lib; {
81 description = "Domain-specific languages and parsers in Python";
82 homepage = "https://github.com/textx/textx/";
83 license = licenses.mit;
84 maintainers = with maintainers; [ yuu ];
85 };
86 };
87
88 textx-data-dsl = buildPythonPackage rec {
89 pname = "textx-data-dsl";
90 version = "1.0.0";
91 inherit (textx) src;
92 # `format` isn't included in the output of `mk-python-derivation`.
93 # So can't inherit format: `error: attribute 'format' missing`.
94 format = "setuptools";
95 pathToSourceRoot = "tests/functional/registration/projects/data_dsl";
96 sourceRoot = "${src.name}/" + pathToSourceRoot;
97 propagatedBuildInputs = [
98 textx
99 textx-types-dsl
100 ];
101 meta = with lib; {
102 inherit (textx.meta) license maintainers;
103 description = "Sample textX language for testing";
104 homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
105 };
106 };
107
108 textx-flow-codegen = buildPythonPackage rec {
109 pname = "textx-flow-codegen";
110 version = "1.0.0";
111 inherit (textx) src;
112 format = "setuptools";
113 pathToSourceRoot = "tests/functional/registration/projects/flow_codegen";
114 sourceRoot = "${src.name}/" + pathToSourceRoot;
115 propagatedBuildInputs = [
116 click
117 textx
118 ];
119 meta = with lib; {
120 inherit (textx.meta) license maintainers;
121 description = "Sample textX language for testing";
122 homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
123 };
124 };
125
126 textx-flow-dsl = buildPythonPackage rec {
127 pname = "textx-flow-dsl";
128 version = "1.0.0";
129 inherit (textx) src;
130 format = "setuptools";
131 pathToSourceRoot = "tests/functional/registration/projects/flow_dsl";
132 sourceRoot = "${src.name}/" + pathToSourceRoot;
133 propagatedBuildInputs = [
134 textx
135 ];
136 meta = with lib; {
137 inherit (textx.meta) license maintainers;
138 description = "Sample textX language for testing";
139 homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
140 };
141 };
142
143 textx-types-dsl = buildPythonPackage rec {
144 pname = "textx-types-dsl";
145 version = "1.0.0";
146 inherit (textx) src;
147 format = "setuptools";
148 pathToSourceRoot = "tests/functional/registration/projects/types_dsl";
149 sourceRoot = "${src.name}/" + pathToSourceRoot;
150 propagatedBuildInputs = [
151 textx
152 ];
153 meta = with lib; {
154 inherit (textx.meta) license maintainers;
155 description = "Sample textX language for testing";
156 homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
157 };
158 };
159
160 textx-example-project = buildPythonPackage rec {
161 pname = "textx-example-project";
162 version = "1.0.0";
163 inherit (textx) src;
164 format = "setuptools";
165 pathToSourceRoot = "tests/functional/subcommands/example_project";
166 sourceRoot = "${src.name}/" + pathToSourceRoot;
167 propagatedBuildInputs = [
168 textx
169 ];
170 meta = with lib; {
171 inherit (textx.meta) license maintainers;
172 description = "Sample textX sub-command for testing";
173 homepage = textx.homepage + "tree/${version}/" + pathToSourceRoot;
174 };
175 };
176in
177 textx