about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/gdtoolkit/default.nix
blob: 479b0b2c3636ba779a9794705a3ad06acecf4a27 (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
{ lib
, python3Packages
, fetchFromGitHub
, godot3-server
}:

let lark080 = python3Packages.lark.overrideAttrs (old: rec {
  # gdtoolkit needs exactly this lark version
  version = "0.8.0";
  src = fetchFromGitHub {
    owner = "lark-parser";
    repo = "lark";
    rev = version;
    hash = "sha256-KN9buVlH8hJ8t0ZP5yefeYM5vH5Gg7a7TEDGKJYpozs=";
    fetchSubmodules = true;
  };
});

in
python3Packages.buildPythonApplication rec {
  pname = "gdtoolkit";
  version = "3.3.1";

  # If we try to get using fetchPypi it requires GeoIP (but the package dont has that dep!?)
  src = fetchFromGitHub {
    owner = "Scony";
    repo = "godot-gdscript-toolkit";
    rev = version;
    sha256 = "13nnpwy550jf5qnm9ixpxl1bwfnhhbiys8vqfd25g3aim4bm3gnn";
  };

  disabled = python3Packages.pythonOlder "3.7";

  propagatedBuildInputs = [ lark080
  ] ++ (with python3Packages; [
    docopt
    pyyaml
    setuptools
  ]);

  doCheck = true;

  nativeCheckInputs = with python3Packages; [
    pytestCheckHook
    hypothesis
    godot3-server
  ];

  preCheck =
    let
      godotServerMajorVersion = lib.versions.major godot3-server.version;
      gdtoolkitMajorVersion = lib.versions.major version;
      msg = ''
        gdtoolkit major version ${gdtoolkitMajorVersion} does not match godot-server major version ${godotServerMajorVersion}!
        gdtoolkit needs a matching godot-server for its tests.
        If you see this error, you can either:
         - disable doCheck for gdtoolkit, or
         - provide a compatible godot-server version to gdtoolkit"
      '';
    in lib.throwIf (godotServerMajorVersion != gdtoolkitMajorVersion) msg ''
      # The tests want to run the installed executables
      export PATH=$out/bin:$PATH

      # gdtoolkit tries to write cache variables to $HOME/.cache
      export HOME=$TMP

      # Work around https://github.com/godotengine/godot/issues/20503
      # Without this, Godot will complain about a missing project file
      touch project.godot

      # Remove broken test case
      # (hard to skip via disabledTests since the test name contains an absolute path)
      rm tests/potential-godot-bugs/multiline-subscription-expression.gd
    '';

  pythonImportsCheck = [ "gdtoolkit" "gdtoolkit.formatter" "gdtoolkit.linter" "gdtoolkit.parser" ];

  meta = with lib; {
    description = "Independent set of tools for working with Godot's GDScript - parser, linter and formatter";
    homepage = "https://github.com/Scony/godot-gdscript-toolkit";
    license = licenses.mit;
    maintainers = with maintainers; [ shiryel tmarkus ];
  };
}