1{ stdenv, buildPythonPackage, fetchFromGitHub, pythonOlder
2, colorama, mypy, pyyaml, regex
3, dataclasses, typing
4, pytestrunner, pytest-mypy
5}:
6
7buildPythonPackage rec {
8 pname = "TatSu";
9 version = "5.0.0";
10
11 src = fetchFromGitHub {
12 owner = "neogeny";
13 repo = pname;
14 rev = "v${version}";
15 sha256 = "1c16fcxf0xjkh5py9bnj6ljb9krhrj57mkwayl1w1dvzwl5lkgj3";
16 };
17
18 # Since version 5.0.0 only >=3.8 is officially supported, but ics is not
19 # compatible with Python 3.8 due to aiohttp:
20 disabled = pythonOlder "3.7";
21 postPatch = ''
22 substituteInPlace setup.py \
23 --replace "python_requires='>=3.8'," "python_requires='>=3.7',"
24 '';
25
26 nativeBuildInputs = [ pytestrunner ];
27 propagatedBuildInputs = [ colorama mypy pyyaml regex ]
28 ++ stdenv.lib.optionals (pythonOlder "3.7") [ dataclasses ]
29 ++ stdenv.lib.optionals (pythonOlder "3.5") [ typing ];
30 checkInputs = [ pytest-mypy ];
31
32 checkPhase = ''
33 pytest test/
34 '';
35
36 meta = with stdenv.lib; {
37 description = "Generates Python parsers from grammars in a variation of EBNF";
38 longDescription = ''
39 TatSu (the successor to Grako) is a tool that takes grammars in a
40 variation of EBNF as input, and outputs memoizing (Packrat) PEG parsers in
41 Python.
42 '';
43 homepage = "https://tatsu.readthedocs.io/";
44 license = licenses.bsd2;
45 maintainers = with maintainers; [ primeos ];
46 };
47
48}