1{ lib
2, python3Packages
3, fetchFromGitHub
4, godot-server
5}:
6
7let lark080 = python3Packages.lark.overrideAttrs (old: rec {
8 # gdtoolkit needs exactly this lark version
9 version = "0.8.0";
10 src = fetchFromGitHub {
11 owner = "lark-parser";
12 repo = "lark";
13 rev = version;
14 hash = "sha256-KN9buVlH8hJ8t0ZP5yefeYM5vH5Gg7a7TEDGKJYpozs=";
15 fetchSubmodules = true;
16 };
17});
18
19in
20python3Packages.buildPythonApplication rec {
21 pname = "gdtoolkit";
22 version = "3.3.1";
23
24 # If we try to get using fetchPypi it requires GeoIP (but the package dont has that dep!?)
25 src = fetchFromGitHub {
26 owner = "Scony";
27 repo = "godot-gdscript-toolkit";
28 rev = version;
29 sha256 = "13nnpwy550jf5qnm9ixpxl1bwfnhhbiys8vqfd25g3aim4bm3gnn";
30 };
31
32 disabled = python3Packages.pythonOlder "3.7";
33
34 propagatedBuildInputs = [ lark080
35 ] ++ (with python3Packages; [
36 docopt
37 pyyaml
38 setuptools
39 ]);
40
41 doCheck = true;
42
43 nativeCheckInputs = with python3Packages; [
44 pytestCheckHook
45 hypothesis
46 godot-server
47 ];
48
49 preCheck =
50 let
51 godotServerMajorVersion = lib.versions.major godot-server.version;
52 gdtoolkitMajorVersion = lib.versions.major version;
53 msg = ''
54 gdtoolkit major version ${gdtoolkitMajorVersion} does not match godot-server major version ${godotServerMajorVersion}!
55 gdtoolkit needs a matching godot-server for its tests.
56 If you see this error, you can either:
57 - disable doCheck for gdtoolkit, or
58 - provide a compatible godot-server version to gdtoolkit"
59 '';
60 in lib.throwIf (godotServerMajorVersion != gdtoolkitMajorVersion) msg ''
61 # The tests want to run the installed executables
62 export PATH=$out/bin:$PATH
63
64 # gdtoolkit tries to write cache variables to $HOME/.cache
65 export HOME=$TMP
66
67 # Work around https://github.com/godotengine/godot/issues/20503
68 # Without this, Godot will complain about a missing project file
69 touch project.godot
70
71 # Remove broken test case
72 # (hard to skip via disabledTests since the test name contains an absolute path)
73 rm tests/potential-godot-bugs/multiline-subscription-expression.gd
74 '';
75
76 pythonImportsCheck = [ "gdtoolkit" "gdtoolkit.formatter" "gdtoolkit.linter" "gdtoolkit.parser" ];
77
78 meta = with lib; {
79 description = "Independent set of tools for working with Godot's GDScript - parser, linter and formatter";
80 homepage = "https://github.com/Scony/godot-gdscript-toolkit";
81 license = licenses.mit;
82 maintainers = with maintainers; [ shiryel tmarkus ];
83 };
84}