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